refactor(agent): simplify subagent concurrency with rejection over semaphore
Replace the asyncio.Semaphore queueing approach with a simple count check in SpawnTool.execute(). When the concurrency limit is reached, the tool returns an error string so the agent can perceive the reason and adjust its behavior instead of silently queueing. - Remove max_concurrent_subagents parameter threading through AgentLoop, commands.py, and nanobot.py - SubagentManager reads the limit directly from AgentDefaults - SpawnTool checks get_running_count() before calling spawn() - Simplify tests to verify rejection behavior
This commit is contained in:
@@ -49,6 +49,11 @@ async def test_spawn_tool_keeps_task_local_context() -> None:
|
||||
release = asyncio.Event()
|
||||
|
||||
class _Manager:
|
||||
max_concurrent_subagents = 1
|
||||
|
||||
def get_running_count(self) -> int:
|
||||
return 0
|
||||
|
||||
async def spawn(
|
||||
self,
|
||||
*,
|
||||
@@ -156,6 +161,11 @@ async def test_spawn_tool_basic_set_context_and_execute() -> None:
|
||||
seen: list[tuple[str, str, str]] = []
|
||||
|
||||
class _Manager:
|
||||
max_concurrent_subagents = 1
|
||||
|
||||
def get_running_count(self) -> int:
|
||||
return 0
|
||||
|
||||
async def spawn(
|
||||
self,
|
||||
*,
|
||||
@@ -183,6 +193,11 @@ async def test_spawn_tool_default_values_without_set_context() -> None:
|
||||
seen: list[tuple[str, str, str]] = []
|
||||
|
||||
class _Manager:
|
||||
max_concurrent_subagents = 1
|
||||
|
||||
def get_running_count(self) -> int:
|
||||
return 0
|
||||
|
||||
async def spawn(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user