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:
Ahmed Allam
2026-08-02 02:15:51 +03:00
committed by Ahmed Allam
parent 49057f267f
commit 8f1bb64d16
2 changed files with 82 additions and 0 deletions
+48
View File
@@ -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,