You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(wake): a loop started by another agent wakes the starter at every iteration, and an operator terminate can end a delegated run with no wake #4767
Two gaps in the caller wake, both left as stated limits by #4538 (PR #4766). Found by reading the code; neither was reproduced on an instance.
1. A loop wakes its starter at every iteration
When agent A starts a loop on agent B, every iteration row carries triggered_by="loop", source_agent_name=A and the loop_id (services/loop_service.py, both dispatch sites). caller_wake_service.maybe_wake_caller stands down for a fan_out_id (the batch join is that ending's own reaction) but has no rule for loop_id. So each iteration's end starts one billed turn on A, bounded only by the per-pair hourly budget (caller_wake_max_per_hour, default 120).
A loop an agent starts on itself is not affected (caller and callee are the same agent). The per-call opt-out from #4538 does not reach this path: a loop is not started through chat_with_agent.
Decision needed: what the starter should get. Options:
One wake when the loop ends (completed, stopped or failed), none per iteration.
No wake at all; the starter reads get_loop_status.
Per-iteration wakes stay, with an opt-out on the loop start.
2. A terminated run may never wake its caller
Both terminate paths write CANCELLED through the status compare-and-set and never spawn the terminal fan-out:
chat_execution_service._proxy_terminate_and_finalize (a turn the agent is running);
chat_execution_service._cancel_inflight_if_parked (a turn still parked in the backend's agent-call queue).
When the terminate wins that write, nothing calls spawn_task_terminal_event, so the delegating agent gets no wake, and a subscriber gets no agent.task.* event. When the executor's own late write wins instead, the fan-out runs. The outcome depends on that race.
The user docs say a delegated run that ends by cancellation wakes its caller (docs/user-docs/collaboration/agent-network.md, "Wake on Ending").
Since #4538 the slot these paths release does drain a wake parked for a free slot. That is a different thing: it delivers an ending that was already parked, not the terminated run's own ending.
Decision needed: should a terminate that wins the status write run the same terminal fan-out as every other winner (wake, agent.task.* event, loop advance, fan-out join)? This is the same class as #1804 and #3651 (both closed): a terminal writer that skips part of the shared terminal work.
Acceptance criteria
The product answer for each part is recorded on this issue.
Part 1: a test starts a loop from another agent's key, ends N iterations, and asserts the number of caller_wake rows the decision calls for.
Part 2: a test terminates a delegated run with the terminate winning the status write, and asserts what the decision calls for (a wake and the event, or a documented "no wake").
Activity