Repository navigation
fix(orchestration): return wait_for_agent before the MCP client ends the call - #190
Merged
Merged
Conversation
…the call wait_for_agent accepts up to 600 seconds, but the MCP clients of most orchestrator CLIs (Codex's default tool_timeout_sec, OpenCode) end a tool call after about 60 seconds. An orchestrator that asked for a long wait got a failed tool call instead of a result, and no progress. For every orchestrator but Claude Code, whose client waits far longer, one call now waits at most 50 seconds and then returns the existing "timeout" with status and the masked output. The schema, the default and Claude Code's limit are unchanged. The tool description (both catalogs), the orchestrator skill and the docs say that a timeout means the subagent is still running.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #160 as a small, independent PR on 1.8.5 (it touches only what 1.8.5 does not already cover). It does not depend on the other parts.
Problem
wait_for_agentacceptstimeoutSecondsup to 600, and the description invites the orchestrator to use long waits. The MCP clients of most orchestrator CLIs end a tool call after about 60 seconds (Codex's defaulttool_timeout_sec, OpenCode's client). The comment aboveMAX_AGENT_WAIT_SECONDSalready notes this, but only the default (55 s) respects it.Before:
wait_for_agent({ sessionId, timeoutSeconds: 300 })while the subagent works.After: the same call returns after 50 s with the existing
reason: "timeout", the subagent'sstatusand its masked output as progress. The description says that a timeout means the subagent is still running and to callwait_for_agentagain.Change
CLIENT_SAFE_AGENT_WAIT_SECONDS = 50next to the existing constants inorchestration-catalog.mjs.ScopedOrchestrationHandler.waitcaps one call at that value unless the orchestrator is Claude Code, whose MCP client lets a tool call run far longer; for Claude Code nothing changes (up to 600 s).agent/orchestrator/SKILL.mdanddocs/agent-orchestration.mdsay so.The schema (
maximum: 600), the default (55 s) and the wait logic itself are unchanged. Five lines of code plus wording.Why this and not less
The deadline belongs to the client, not to the subagent, so it has to be enforced where CanvasTTY knows which client is calling: the orchestration handler already knows the orchestrator's session and provider. Lowering the schema maximum alone would not help: a model can still ask for any value up to it, and Claude Code orchestrators do benefit from long waits. Raising the client's own timeout is not possible for every CLI (OpenCode has no per-server setting we write), and it would hide a long silence from the model instead of giving it progress.
What changes for existing workflows
timeoutwith status and output. Calls of 50 s or less are unchanged. A wait that ends earlier (idle, done, needs_approval and so on) is unchanged.Validation
tests/orchestration-providers-wait.test.mjs: for OpenCode and Codex orchestrators a request of 600 or 120 s (and the default) must reachwaitForas 50 000 ms, a 20 s request stays 20 000 ms, Claude Code keeps 600 000 ms and its 55 s default; the result istimeoutwithstatus: "working"and the subagent's output; the description states the cap.actual: 600000, expected: 50000for OpenCode asking for 600); with the fix it passes.npm run build(typecheck),npm run audit:secrets, the eager renderer bundle check and the full test suite pass. Full suite: 2652 tests, 2646 pass, 0 fail, 6 skipped. The renderer is untouched (eager bundle unchanged against the other branches;renderer-bundle-splittingpasses).