fix: re-route AgentConnectionStore through AgentConnectionCache (redux) - #46
Merged
Merged
Conversation
Re-applies the AgentConnectionStore portion of ba7e97a that was reverted in 350de99. Without it, the cross-cache race the revert commit explicitly left open ("UI-driven connect simultaneous with external_websocket_sync open_thread for the same agent isn't deduped") surfaces in production: the agent panel restoration on a resumed spec-task session calls `request_connection` for `claude-acp` at the same instant `thread_service::open_existing_thread_sync` does, each spawning a fresh `claude-agent-acp` wrapper, a fresh `claude --resume`, and a fresh `chrome-devtools-mcp`. Two ACP_SPAWN log lines for the same agent_id in the same second; only one of the chrome-devtools-mcp instances wins the npx race and registers, so the model talking to the other one sees "No such tool available: mcp__chrome-devtools__*". Verified against the reproducing spec task (ubuntu-external-01kq54vkjmb...): two `sh -c "claude-agent-acp"` parents, only one with chrome-devtools-mcp under it. Zed.log.old shows two ACP_SPAWN entries at 16:02:47 but only one ACP_DEDUP "No cached connection" line, confirming the second spawn skipped the cache. The original revert reason was that routing AgentConnectionStore through the cache made `E2E_AGENTS="zed-agent,claude" ./run_docker_e2e.sh` round 2 (claude) phase 1 time out with 0 events. With the current main (post the stale-flag and other thread_service fixes from #44 / #45), that E2E now passes both rounds with this change re-applied — verified locally. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lukemarsden
added a commit
to helixml/helix
that referenced
this pull request
Apr 26, 2026
Replaces the unmerged branch commit with the merge commit on Zed main after helixml/zed#46 landed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced May 6, 2026
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
Re-applies the
AgentConnectionStoreportion of ba7e97aea6 that was reverted in 350de991de. The revert commit explicitly flagged this as a known-unfixed race that "can be addressed separately if it ever surfaces" — it surfaced.Problem
Two
claude-agent-acpwrappers spawn for the same resumed spec-task session, each with their ownclaude --resumeand their ownchrome-devtools-mcp. One of thechrome-devtools-mcpinstances loses the npx race and never registers, so the model talking to that wrapper seesError: No such tool available: mcp__chrome-devtools__*.Reproduced on
ubuntu-external-01kq54vkjmb...:pstree: twosh -c "claude-agent-acp"parents, only one withchrome-devtools-mcpunder itZed.log.oldat 16:02:47: two[ACP_SPAWN] About to spawn ACP wrapper agent_id=AgentId("claude-acp")lines, but only one[ACP_DEDUP] No cached connectionline — confirming the second spawn skipped the cacheThe race: agent panel restoration on a resumed session calls
AgentConnectionStore::request_connectionforclaude-acpat the same instantexternal_websocket_sync::thread_service::open_existing_thread_syncdoes. Both paths independently callserver.connect(). The earlier fix only routedthread_servicethrough the cache, leaving the cross-path race open.Fix
Route
AgentConnectionStore::start_connectionthroughAgentConnectionCache::request_connectionso UI-driven connects share a singleAgentConnectionwithexternal_websocket_sync::thread_servicefor the same(project, agent_id).Why the original revert reason no longer applies
The revert (350de991de) said
E2E_AGENTS="zed-agent,claude" ./run_docker_e2e.shround 2 (claude) phase 1 timed out with 0 events. With current main (post the stale-flag and otherthread_servicefixes from #44 and #45 on this fork), that E2E now passes both rounds with this change re-applied.Test plan
E2E_AGENTS="zed-agent,claude" ./run_docker_e2e.shpasses (verified locally)pstreeshows only oneclaude-agent-acpparent per sessionZed.logshows[ACP_DEDUP] Reusing connectionfor the second callermcp__chrome-devtools__*tools work consistently🤖 Generated with Claude Code