mirror of
https://github.com/usestrix/strix.git
synced 2026-08-21 02:45:31 +02:00
fix(core): tell the parent when an interactive subagent parks
Parking is self-service only for the root, which the user is watching. A parked child owes its parent a report it can no longer send, so the parent would wait out its full timeout for nothing.
This commit is contained in:
@@ -891,6 +891,54 @@ async def test_interactive_recovery_exhaustion_parks_instead_of_crashing(
|
||||
assert coordinator.statuses["root"] == "waiting"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_interactive_subagent_exhaustion_tells_its_parent(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""The user only talks to the root, so a parked child must report up.
|
||||
|
||||
Otherwise a parent blocked in wait_for_message burns its whole timeout
|
||||
waiting for a completion report the child can no longer send.
|
||||
"""
|
||||
coordinator = AgentCoordinator()
|
||||
await coordinator.register("root", "strix", parent_id=None)
|
||||
await coordinator.register("child", "recon", parent_id="root")
|
||||
calls: list[Any] = []
|
||||
monkeypatch.setattr(
|
||||
execution,
|
||||
"_run_cycle_parked",
|
||||
_scripted_cycle(coordinator, "child", ["running"], calls),
|
||||
)
|
||||
|
||||
await _drive(coordinator, "child", interactive=True)
|
||||
|
||||
assert coordinator.statuses["child"] == "waiting"
|
||||
pending, items = await coordinator.consume_pending("root", include_items=True)
|
||||
assert pending == 1
|
||||
notice = str(items[0])
|
||||
assert "child" in notice
|
||||
assert "parked" in notice
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_interactive_root_exhaustion_notifies_nobody(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""A parked root is self-service: the user is already watching it."""
|
||||
coordinator = AgentCoordinator()
|
||||
await coordinator.register("root", "strix", parent_id=None)
|
||||
monkeypatch.setattr(
|
||||
execution,
|
||||
"_run_cycle_parked",
|
||||
_scripted_cycle(coordinator, "root", ["running"], []),
|
||||
)
|
||||
|
||||
await _drive(coordinator, "root", interactive=True)
|
||||
|
||||
pending, _ = await coordinator.consume_pending("root")
|
||||
assert pending == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_noninteractive_recovery_exhaustion_crashes(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
|
||||
Reference in New Issue
Block a user