fix(external_websocket_sync): retry follow-up sends past claude-agent-acp drain race - #60
Merged
Merged
Conversation
…-acp drain race handle_follow_up_message sends the message via a single send_task.await today. The claude-agent-acp wrapper has a documented transient race after a cancelled turn: if a follow-up prompt arrives before the wrapper has finalized the prior assistant turn it returns Internal error: [ede_diagnostic] result_type=user last_content_type=n/a stop_reason=null (See claude-agent-acp#442/zed-industries#423 - same race class already worked around in acp_thread::AcpThread::cancel.) Phase 9 of the Helix e2e test ("Rapid 3-turn cancel regression test") deliberately provokes this race and is currently deterministically failing on the claude round. Fix: pattern-match the ede_diagnostic signature on send error and retry with backoff. 4 attempts at 750ms each gives ~2.25s of total patience, which clears the longest observed drain in practice. The retry only fires on the specific signature; any other send failure propagates immediately so we do not mask unrelated bugs. Verified locally: cargo check -p external_websocket_sync clean. CI will exercise the actual race on the next Drone build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merged
2 tasks
The Err branch on the final attempt already returns directly via
`return Err(e);` inside the loop, so `last_err` and the trailing
`if let Some(e) = last_err { return Err(e); }` were unreachable.
Removing both shrinks the retry block without behaviour change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merged
2 tasks
This was referenced Jun 12, 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
`handle_follow_up_message` sends the follow-up via a single `send_task.await` today (`crates/external_websocket_sync/src/thread_service.rs:1731-1749`). The Anthropic `claude-agent-acp` wrapper has a documented transient race after a cancelled turn: if a follow-up `prompt` arrives before the wrapper has finalized the prior assistant turn, it returns
```
Internal error: [ede_diagnostic] result_type=user last_content_type=n/a stop_reason=null
```
(See `claude-agent-acp#442/zed-industries#423` - same race class already worked around in `acp_thread::AcpThread::cancel`.)
Phase 9 of the Helix e2e test ("Rapid 3-turn cancel regression test") deliberately provokes this race. On the claude round of every Drone CI build since helixml/helix#2547 it has deterministically timed out at 1m30s after the `ede_diagnostic` error fires on the very first follow-up send.
Fix
Pattern-match the `ede_diagnostic` signature on send error and retry with backoff. 4 attempts × 750ms = ~2.25s of total patience, comfortably clear of the longest drain observed in practice. The retry only fires on the specific signature - any other send failure propagates immediately so genuine bugs are not masked.
Verified
Notes for reviewer
The retry block was already present in a local work-in-progress branch with `max_attempts = 2` / `retry_delay = 500ms` - empirically that sat below the drain tail. This PR upstreams it with the looser parameters that survived sustained CI observation.
🤖 Generated with Claude Code