refactor: move replay dedup from ACP protocol handler to MessageWriter#563
Draft
refactor: move replay dedup from ACP protocol handler to MessageWriter#563
Conversation
Change `prompt: &str` to `prompt: Option<&str>` in the `AgentDriver::run()` trait method, both driver implementations (`AcpDriver` and `SimpleDriverWrapper`), and the internal `run_acp_protocol()` helper. When `None`, the driver sets up or resumes the session but skips sending a prompt. All existing callers now pass `Some(prompt)` to preserve current behaviour. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ocol handler Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When resuming an ACP session, the server replays all previous messages. MessageWriter now loads existing message roles from the DB on resume and skips writing duplicates by tracking a replay cursor, preventing duplicate messages from being inserted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Filter out User messages when building replay_roles (User messages are inserted by session_runner before the driver runs, but never forwarded by AcpNotificationHandler, so they would block the cursor) - Add skipping_assistant flag to prevent double-advancing the replay cursor when flush_text is called multiple times for the same block - Combine replay_messages and replay_cursor into single Mutex<ReplayState> - Use .as_ref() instead of .to_string() for tool_call_id in driver to avoid unnecessary allocation - Add test for resume dedup behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
11d8249 to
2a47771
Compare
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
MessageWriter, which checks incoming messages against previously persisted DB rolespromptparameter optional inAgentDriver::run(), allowing session setup/resume without sending a promptget_session_messagesfrom theStoretrait (no longer needed at the protocol layer)HandlerPhase,ReplayBuffer, idle-timeout polling)Test plan
MessageWriterMessageWriterunit tests pass🤖 Generated with Claude Code