Skip to content

Fix Stopped flush: turn-scoped request_id, only flush current turn#34

Merged
lukemarsden merged 1 commit intomainfrom
fix/stopped-flush-turn-scoped-request-id
Apr 3, 2026
Merged

Fix Stopped flush: turn-scoped request_id, only flush current turn#34
lukemarsden merged 1 commit intomainfrom
fix/stopped-flush-turn-scoped-request-id

Conversation

@lukemarsden
Copy link
Copy Markdown

Summary

  • Capture request_id when a turn starts (first assistant entry), use it for the Stopped flush and message_completed instead of the global THREAD_REQUEST_MAP
  • Only flush entries from the current turn (after the last UserMessage), not the entire thread history

Why

Follow-up to #33. When a follow-up message or interrupt arrives before the old turn's Stopped handler fires, the global request_id has already been updated. The flush then tags old entries with the new request_id, causing them to leak into the wrong interaction's response_entries.

Test plan

  • E2E test passes with both zed-agent and claude (all phases including interrupt)
  • Store isolation validation passes (no response_entries leaked across interactions)

🤖 Generated with Claude Code

Two fixes to prevent response_entries leaking across interactions:

1. Capture request_id when the turn starts (first assistant entry), use
   it for the Stopped flush and message_completed instead of the global
   THREAD_REQUEST_MAP. This prevents a race where a follow-up or
   interrupt message updates the global request_id before the old turn's
   Stopped handler runs, causing old entries to be tagged with the new
   request_id.

2. Only flush entries from the current turn (after the last UserMessage),
   not the entire thread history. Previous turns' entries are already
   persisted and don't need re-sending.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lukemarsden added a commit to helixml/helix that referenced this pull request Apr 3, 2026
Points to helixml/zed#34 which fixes response_entries leaking across
interactions during follow-ups and interrupts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lukemarsden lukemarsden merged commit f3e5d2e into main Apr 3, 2026
19 checks passed
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