feat(spawn): allow per-subagent sampling temperature (#3969)
This commit is contained in:
@@ -94,6 +94,39 @@ async def test_subagent_uses_configured_max_iterations(tmp_path):
|
||||
mgr.runner.run.assert_awaited_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_spawn_forwards_temperature_to_run_spec(tmp_path):
|
||||
"""A temperature passed to spawn() should reach the AgentRunSpec."""
|
||||
from nanobot.agent.subagent import SubagentManager
|
||||
from nanobot.bus.queue import MessageBus
|
||||
|
||||
bus = MessageBus()
|
||||
provider = MagicMock()
|
||||
provider.get_default_model.return_value = "test-model"
|
||||
mgr = SubagentManager(
|
||||
provider=provider,
|
||||
workspace=tmp_path,
|
||||
bus=bus,
|
||||
max_tool_result_chars=_MAX_TOOL_RESULT_CHARS,
|
||||
)
|
||||
mgr._announce_result = AsyncMock()
|
||||
|
||||
seen = {}
|
||||
|
||||
async def fake_run(spec):
|
||||
seen["temperature"] = spec.temperature
|
||||
return SimpleNamespace(
|
||||
stop_reason="done", final_content="done", error=None, tool_events=[],
|
||||
)
|
||||
|
||||
mgr.runner.run = AsyncMock(side_effect=fake_run)
|
||||
|
||||
await mgr.spawn(task="do task", temperature=0.9)
|
||||
await asyncio.gather(*mgr._running_tasks.values(), return_exceptions=True)
|
||||
|
||||
assert seen["temperature"] == 0.9
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_spawn_tool_rejects_when_at_concurrency_limit(tmp_path):
|
||||
"""SpawnTool should return an error string when the concurrency limit is reached."""
|
||||
|
||||
@@ -64,6 +64,7 @@ async def test_spawn_tool_keeps_task_local_context() -> None:
|
||||
origin_chat_id: str,
|
||||
session_key: str,
|
||||
origin_message_id: str | None = None,
|
||||
temperature: float | None = None,
|
||||
) -> str:
|
||||
seen.append((origin_channel, origin_chat_id, session_key))
|
||||
return f"{origin_channel}:{origin_chat_id}:{task}"
|
||||
@@ -176,6 +177,7 @@ async def test_spawn_tool_basic_set_context_and_execute() -> None:
|
||||
origin_chat_id,
|
||||
session_key,
|
||||
origin_message_id=None,
|
||||
temperature=None,
|
||||
):
|
||||
seen.append((origin_channel, origin_chat_id, session_key))
|
||||
return f"ok: {task}"
|
||||
@@ -208,6 +210,7 @@ async def test_spawn_tool_default_values_without_set_context() -> None:
|
||||
origin_chat_id,
|
||||
session_key,
|
||||
origin_message_id=None,
|
||||
temperature=None,
|
||||
):
|
||||
seen.append((origin_channel, origin_chat_id, session_key))
|
||||
return "ok"
|
||||
|
||||
Reference in New Issue
Block a user