Conversation
…e intercept Three bugs in `strip_mid_history_orphans` and `persist_message` caused a WARN flood on session startup whenever the utility gate intercepted a tool call: 1. `persist_message` silently stored `parts_json = "[]"` on serde failure, producing a row with no ToolResult parts that orphaned_tool_use_ids could never match. Now returns early with an error log instead. 2. Forward pass of `strip_mid_history_orphans` passed `messages.get(i + 1)` directly to `orphaned_tool_use_ids`, so a System hint between an assistant tool_use and the user tool_result was mistaken for the pair's next message, making the ToolUse appear orphaned. Now scans past System messages to find the first non-System candidate. 3. Reverse pass had the same gap (found during test coverage). Fixed symmetrically. Adds three regression tests covering the round-trip, System-between-pair, and corrupt-parts-row scenarios. Closes #3168
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
persist_messagesilently storedparts_json = "[]"on serde failure, creating rows with no ToolResult parts thatorphaned_tool_use_idscould never match — now returns early with an error logstrip_mid_history_orphanspassedmessages.get(i + 1)directly, so a System hint between an assistanttool_useand the usertool_resultcaused false orphan detection — now scans past System messages to find the first non-System candidateTest plan
cargo nextest run -p zeph-core --lib— all tests pass (8390 in workspace)cargo clippy -p zeph-core -- -D warnings— cleancargo +nightly fmt --check— cleanCloses #3168