refactor(agent): capture subagent runtime before spawn

This commit is contained in:
chengyongru
2026-07-10 17:54:34 +08:00
committed by Xubin Ren
parent 198fd9f869
commit af85c356b8
16 changed files with 261 additions and 132 deletions
+4 -1
View File
@@ -8,14 +8,16 @@ import pytest
from nanobot.agent.runner import AgentRunResult
from nanobot.agent.subagent import SubagentManager, SubagentStatus
from nanobot.bus.queue import MessageBus
from nanobot.providers.base import GenerationSettings
from nanobot.utils.llm_runtime import LLMRuntime
@pytest.mark.asyncio
async def test_subagent_forwards_resolver_to_agent_run_spec(tmp_path: Path) -> None:
provider = MagicMock()
provider.get_default_model.return_value = "m"
provider.generation = GenerationSettings()
mgr = SubagentManager(
provider=provider,
workspace=tmp_path,
bus=MessageBus(),
max_tool_result_chars=64,
@@ -39,6 +41,7 @@ async def test_subagent_forwards_resolver_to_agent_run_spec(tmp_path: Path) -> N
"lbl",
{"channel": "cli", "chat_id": "direct", "session_key": "cli:direct"},
status,
LLMRuntime.capture(provider, "m", context_window_tokens=128_000),
)
mgr.runner.run.assert_called_once()
spec = mgr.runner.run.call_args[0][0]