Repository navigation
Description
Summary
Three limits that #4538 (PR #4766) states and leaves open. The first was ruled acceptable for that PR on condition that it is tracked (the ruling is on #4538). Parts 2 and 3 were found by reading the code and were not reproduced on an instance.
Loop iterations waking the starter are tracked separately in #4767.
1. A plain REST sync call still wakes its caller after an inline answer
Since #4538 the backend stands a caller wake down only on positive evidence: the call sent wake: false, or it declared its wait (caller_wait_ms) and the run ended inside it. The MCP server sends caller_wait_ms on every sync call, so every MCP call is covered.
An agent that calls POST /api/agents/{name}/task directly, sync, and sends neither field gets its wake after the inline answer, as before #4538. It fails safe: one extra billed turn, never a lost wake.
The backend cannot simply treat "no declared wait" as "answered inline". A client that gives up before the handler does (for example a shell call with its own timeout) would then get neither the answer nor the wake.
Decision needed: leave it as documented (the caller sends one field), or give the backend a way to know the reply was delivered. Options for the second:
- The sync handler records that it wrote its response, and the wake waits for that record for a short time before it starts.
- The handler checks whether the client is still connected before it answers, and re-opens the wake when it is not.
2. A schedule an agent triggers has no opt-out
POST /api/agents/{name}/schedules/{id}/trigger stamps source_agent_name with the calling agent, and the run it starts carries triggered_by: "manual", which is not one of the reserved triggers. So when that run ends, the agent that triggered it is woken. trigger_agent_schedule takes no wake parameter, so an agent that triggers a schedule and reads the result in the same turn cannot decline.
Decision needed: add the same wake: false to the trigger route and the MCP tool, or decide that a triggered schedule should not wake its trigger-er at all.
3. Two receipts say nothing about the wake
A receipt's wake field tells the caller whether to end its turn or set a reminder. Two receipts carry no such field:
fan_out. The legs of a batch never wake the caller (the batch join is that ending's own reaction), but neither the result nor thefan_out_timeoutreceipt sayswake: "none",wake_reason: "fan_out". The reason already exists inresolveWake; thefan_outtool does not use it.queued_timeouton a sync call. When a sync call outlives the MCP server's wait, the server writes the receipt itself, with no backend answer to read the wake verdict from, so the receipt is silent. Since bug(wake): a sync agent-to-agent call still wakes the caller, billing a second turn for an answer it already has #4538 that run keeps its wake, but the caller is not told. The backend's own sync long-poll receipt (_dispatch_sync_backlog) does not stamp the verdict either.
Proposed: fan_out prints wake: "none", wake_reason: "fan_out". For queued_timeout, the MCP server reads the caller's wake policy for its own receipt (the same {effective, source} shape get_agent_info publishes), and the backend's long-poll receipt stamps it as the async receipts do.
Acceptance criteria
- The product answer for parts 1 and 2 is recorded on this issue.
- Part 1: either the docs remain the answer, or a test makes a REST sync call with neither field, lets it answer inline, and asserts no
caller_wakerow; and a second test has the client give up first and asserts the wake. - Part 2: a test triggers a schedule from an agent's key and asserts what the decision calls for.
- Part 3: a
fan_outresult and a syncqueued_timeoutreceipt each carry awakefield that matches what the backend then does. - The user docs match the behaviour for all three.
Activity