Repository navigation
fix(loop): prevent compaction from splitting tool_call/tool_result pairs - #45
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45 +/- ##
==========================================
+ Coverage 91.81% 91.95% +0.13%
==========================================
Files 50 50
Lines 6685 6798 +113
==========================================
+ Hits 6138 6251 +113
Misses 547 547
🚀 New features to boost your workflow:
|
The compactor split messages purely by count, so an assistant message with tool_calls could end up in the summary while its matching Role::Tool responses stayed in recent (or vice versa). This produces histories with dangling tool_call_ids that providers reject. Walk the proposed split backward until no unanswered tool_call straddles the boundary. If no safe split exists above `start`, the caller's existing guard skips compaction entirely. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
angel-manuel
force-pushed
the
fix/compaction-tool-pair-atomicity
branch
from
April 17, 2026 11:13
ad66df2 to
fa16535
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
len - keep_recent), so an assistant message withtool_callscould land in the summary while its matchingRole::Toolresponses stayed in recent — producing histories with danglingtool_call_ids that providers reject.find_safe_splitwalks the proposed split backward until no unanswered tool call straddles the boundary. If no safe split exists abovestart, the existing guard skips compaction entirely.Test plan
cargo test -p overloop --lib compaction— 9 tests pass (4 existing + 5 new)cargo clippyclean🤖 Generated with Claude Code