fix: reduce WS spawn pre-registration timeout from 15s to 3s#597
Merged
khaliqgant merged 5 commits intomainfrom Mar 20, 2026
Merged
fix: reduce WS spawn pre-registration timeout from 15s to 3s#597khaliqgant merged 5 commits intomainfrom
khaliqgant merged 5 commits intomainfrom
Conversation
PR #591 added a synchronous register_agent_token() HTTP call with a 15s timeout in the WS event loop before spawning agents. This blocked the event loop and delayed Codex agent spawns by up to 15s (on top of the existing 25s boot marker timeout), causing apparent spawn failures. Reduce the timeout to 3s so the spawn proceeds quickly. On timeout or failure, the agent self-registers via its MCP server (pre-#591 behavior). Also adds ~/.local/bin, ~/.opencode/bin, ~/.claude/local to the fallback PATH in pty.rs so CLIs installed in user-local directories are found. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude bakes the API key into --mcp-config JSON and self-registers reliably, so the blocking HTTP registration call is unnecessary. Non-Claude CLIs still get a 3s registration attempt since they need the token injected into their CLI args at spawn time. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Issue 1: Keep dedup seeding before spawn (so WS echoes during spawn are deduplicated) but remove the dedup entry if spawn fails, preventing failed spawns from blocking retries for the 5-minute dedup window. Adds DedupCache::remove() and remove_local_spawn_control_dedup(). Issue 2: Already fixed in prior commit (parse_cli_command before normalize_cli_name for is_claude check). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a second spawn request for an already-running agent fails with "already exists", we must not remove the dedup entry from the first successful spawn. Doing so would allow WebSocket echoes through. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
REG_TIMEOUTfrom 15s to 3s in both WS spawn handlers insrc/main.rs, fixing a regression introduced in PR fix: MCP tools unavailable for agents spawned via agent_add #591 where agent spawns (especially Codex) were delayed by a blocking HTTP call~/.local/bin,~/.opencode/bin,~/.claude/localto fallback PATH insrc/pty.rsfor CLI binary resolutionRoot cause
PR #591 added a synchronous
register_agent_token()HTTP call with a 15s timeout in the WS event loop before spawning agents. Combined with the existing 25s boot marker timeout, Codex agents could take ~40s to become ready — exceeding caller timeouts and causing apparent spawn failures. Claude agents were unaffected because they bake the token into their MCP JSON config.Test plan
agent_addand verify it comes online within ~5s (not 25-40s)~/.local/binare found by PTY spawner🤖 Generated with Claude Code