feat(subagent): add session-owned task messaging and cancellation (#5985)

let's go!
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-05 05:16:33 +08:00
1 parent f75470e72f
commit 6ff96f2a8f
93 files changed
+5632 -1156

No files matched your search

+12 -14
View File
@@ -8,7 +8,7 @@ import pytest
from nanobot.agent.memory import Consolidator
from nanobot.agent.runner import AgentRunResult
from nanobot.agent.subagent import SubagentManager, SubagentStatus
from nanobot.agent.subagent import SubagentManager
from nanobot.agent.tools.filesystem import FileToolsConfig
from nanobot.bus.queue import MessageBus
from nanobot.config.schema import ToolsConfig
@@ -39,6 +39,10 @@ async def test_subagent_uses_tool_loader():
assert tools.has("write_file")
assert not tools.has("message")
assert not tools.has("spawn")
assert not tools.has("subagent")
assert not tools.has("send_session_message")
assert not tools.has("read_session")
assert not tools.has("my")
@pytest.mark.asyncio
@@ -152,22 +156,16 @@ async def test_subagent_keeps_project_runtime_scope_with_agent_owned_tools(tmp_p
return_value=AgentRunResult(final_content="ok", messages=[], stop_reason="completed")
)
manager._announce_result = AsyncMock()
status = SubagentStatus(
task_id="t1",
label="label",
task_description="task",
started_at=0.0,
)
await manager._run_subagent(
"t1",
"task",
"label",
{"channel": "websocket", "chat_id": "direct"},
status,
_runtime(provider),
await manager.spawn(
task="task",
label="label",
origin_channel="websocket",
origin_chat_id="direct",
runtime=_runtime(provider),
workspace_scope=build_workspace_scope(project, "restricted"),
)
await asyncio.gather(*manager._running_tasks.values(), return_exceptions=True)
spec = manager.runner.run.call_args.args[0]
assert spec.workspace == project