fix(agent): align LLM wall timeout with sustained goals for main + subagents
Centralize runner_wall_llm_timeout_s in session goal_state metadata helpers so spawned subagents inherit the same policy as AgentLoop without coupling to long_task. Pass optional resolver into SubagentManager and add tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
Xubin Ren
co-authored by
Cursor
parent
cf09a8d691
commit
e804f2fddb
@@ -0,0 +1,46 @@
|
||||
"""Subagent forwards loop-provided LLM wall-timeout resolver into AgentRunSpec."""
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from nanobot.agent.runner import AgentRunResult
|
||||
from nanobot.agent.subagent import SubagentManager, SubagentStatus
|
||||
from nanobot.bus.queue import MessageBus
|
||||
|
||||
|
||||
@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"
|
||||
mgr = SubagentManager(
|
||||
provider=provider,
|
||||
workspace=tmp_path,
|
||||
bus=MessageBus(),
|
||||
max_tool_result_chars=64,
|
||||
llm_wall_timeout_for_session=lambda sk: 0.0 if sk == "cli:direct" else None,
|
||||
)
|
||||
|
||||
mgr.runner.run = AsyncMock(
|
||||
return_value=AgentRunResult(final_content="ok", messages=[], stop_reason="completed")
|
||||
)
|
||||
mgr._announce_result = AsyncMock()
|
||||
|
||||
status = SubagentStatus(
|
||||
task_id="t1",
|
||||
label="lbl",
|
||||
task_description="task",
|
||||
started_at=0.0,
|
||||
)
|
||||
await mgr._run_subagent(
|
||||
"t1",
|
||||
"task",
|
||||
"lbl",
|
||||
{"channel": "cli", "chat_id": "direct", "session_key": "cli:direct"},
|
||||
status,
|
||||
)
|
||||
mgr.runner.run.assert_called_once()
|
||||
spec = mgr.runner.run.call_args[0][0]
|
||||
assert spec.session_key == "cli:direct"
|
||||
assert spec.llm_timeout_s == 0.0
|
||||
Reference in New Issue
Block a user