refactor(agent): compose image tools in application runtimes (#6172)

* refactor(agent): move image configuration ownership into tools

* refactor(agent): compose image tools in application runtimes
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-12 17:42:45 +08:00
1 parent e148296d5c
commit 105b772203
22 files changed
+269 -236

No files matched your search

+6 -5
View File
@@ -25,6 +25,7 @@ def _router(
config_path: Path | None = None,
mcp_runtime_status: Callable[[], Mapping[str, str]] | None = None,
mcp_reload: Callable[[], Awaitable[dict[str, object]]] | None = None,
image_generation_reload: Callable[[], Awaitable[dict[str, object]]] | None = None,
rename_model_preset: Callable[[str, str], int] | None = None,
refresh_runtime_config: Callable[[], None] | None = None,
) -> WebUISettingsRouter:
@@ -47,6 +48,7 @@ def _router(
runtime_capabilities={},
mcp_runtime_status=mcp_runtime_status,
mcp_reload=mcp_reload,
image_generation_reload=image_generation_reload,
mcp_oauth_redirect_uri=lambda _request: "https://gateway.example/auth/mcp/callback",
)
@@ -657,7 +659,7 @@ async def test_reverting_web_reader_preserves_unrelated_restart_reason(tmp_path)
@pytest.mark.parametrize("enabled", [False, True])
async def test_image_switch_round_trip_clears_restart(tmp_path, monkeypatch, enabled):
async def test_image_switch_round_trip_clears_restart(tmp_path, enabled):
from nanobot.config.loader import save_config
from nanobot.config.schema import Config
@@ -666,11 +668,10 @@ async def test_image_switch_round_trip_clears_restart(tmp_path, monkeypatch, ena
config.tools.image_generation.enabled = enabled
config_path = tmp_path / "config.json"
save_config(config, config_path)
monkeypatch.setattr(
"nanobot.webui.settings_routes.request_image_generation_reload",
AsyncMock(return_value={"ok": False, "requires_restart": True}),
router = _router(
config_path=config_path,
image_generation_reload=AsyncMock(return_value={"ok": False, "requires_restart": True}),
)
router = _router(config_path=config_path)
router.logger.warning = MagicMock()
path = "/api/settings/image-generation/update"
changed = await router.dispatch(None, _mutation_request(path, {"enabled": not enabled}), path)