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

+13 -2
View File
@@ -15,6 +15,10 @@ from nanobot import __logo__, __version__
from nanobot.agent.hook import AgentHook, AgentRunHookContext
from nanobot.agent.hooks import create_file_edit_activity_hook
from nanobot.agent.loop import AgentLoop
from nanobot.agent.tools.image_generation import (
register_image_generation_tool,
reload_image_generation_tool,
)
from nanobot.agent.tools.mcp import MCPProvider
from nanobot.agent.tools.registry import ToolRegistry
from nanobot.cli import terminal as cli_terminal
@@ -377,7 +381,6 @@ def _run_gateway(
load_provider_snapshot,
)
from nanobot.providers.fallback_provider import FallbackProvider
from nanobot.providers.image_generation import image_gen_provider_configs
from nanobot.session.manager import SessionManager
from nanobot.session.recovery import RecoveryCoordinator
from nanobot.session.webui_turns import (
@@ -476,6 +479,7 @@ def _run_gateway(
)
tools = ToolRegistry()
register_image_generation_tool(config, tools, workspace=config.workspace_path)
mcp_provider = MCPProvider.from_config(config, tools)
recovery = RecoveryCoordinator(
@@ -492,7 +496,6 @@ def _run_gateway(
context_window_tokens=provider_snapshot.context_window_tokens,
cron_service=cron,
session_manager=session_manager,
image_generation_provider_configs=image_gen_provider_configs(config),
provider_snapshot_loader=_load_gateway_provider_snapshot,
preset_catalog_loader=load_model_preset_catalog,
turn_delivery_factory=turn_delivery_factory,
@@ -716,6 +719,13 @@ def _run_gateway(
agent.context.skills.disabled_skills = set(disabled_skills)
agent.subagents.disabled_skills = set(disabled_skills)
async def _webui_image_generation_reload() -> dict[str, Any]:
return await reload_image_generation_tool(
config_path=Path(config_path),
workspace=agent.workspace,
registry=tools,
)
# Create channel manager (forwards SessionManager so the WebSocket channel
# can serve the embedded webui's REST surface).
channels = ChannelManager(
@@ -733,6 +743,7 @@ def _run_gateway(
webui_runtime_capabilities=webui_runtime_capabilities,
webui_mcp_runtime_status=mcp_provider.runtime_status,
webui_mcp_reload=mcp_provider.reload,
webui_image_generation_reload=_webui_image_generation_reload,
webui_skill_state_action=_webui_skill_state_action,
webui_recovery_action=recovery.handle_action,
webui_subagent_manager=agent.subagents,