Skip to content

fix(external_websocket_sync): retry follow-up sends past claude-agent-acp drain race - #60

Merged
chocobar merged 2 commits into
mainfrom
fix/thread-service-claude-acp-drain-retry
Jun 9, 2026
Merged

fix(external_websocket_sync): retry follow-up sends past claude-agent-acp drain race#60
chocobar merged 2 commits into
mainfrom
fix/thread-service-claude-acp-drain-retry

Conversation

@chocobar

@chocobar chocobar commented Jun 9, 2026

Copy link
Copy Markdown

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

…-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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant