Repository navigation
[NO-JIRA] self_compact: summarize only agent-visible, non-turn-context messages - #50
Merged
Merged
Conversation
…t messages When self-compaction was ported onto v1.61.1 (which removed upstream's do_compact helper in aaif-goose#13575), compact_messages_with_kind passed the full conversation slice directly to oi_kit_context_management::summarize instead of filtering out turn-context messages and projecting to agent_visible_messages(). On long-lived sessions with prior compactions, self_compact_and_resume sent the entire archived history (millions of tokens) to the summarizer, causing it to exceed the 1M context window even after stripping all tool responses. Restore the same !is_turn_context() + agent_visible_messages() projection used in v1.60.2's do_compact and v1.61.1's oi_kit_agent::compaction.
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
Fix a regression introduced when porting the R11 self-compaction patch onto upstream v1.61.1 (which removed
do_compactin aaif-goose#13575):compact_messages_with_kindpassed the fullconversation.messages()slice directly tooi_kit_context_management::summarize(), includingagent_visible = falsemessages archived by earlier compactions and turn-context messages.On long-lived sessions with prior compactions,
self_compact_and_resumesent the entire archived history (millions of tokens, e.g. 3.62M tokens on a 326K visible session) to the summarizer, causing it to exceed the 1M context window even after stripping all tool responses (Failed to compact: context limit exceeded even after removing all tool responses).This restores the exact
!msg.is_turn_context()+.agent_visible_messages()projection used in v1.60.2'sdo_compactand v1.61.1'soi_kit_agent::compaction::CompactionOperation::summarize_standalone.Note: this fixes archived/hidden history leaking into
self_compact_and_resume; if a session's agent-visible context alone exceeds the summarizer's window even with tool responses stripped,summarize()will still returnContextLengthExceededas upstream does.Changes
crates/goose/src/context_mgmt/mod.rs: filter out turn-context messages and project via.agent_visible_messages()before callingoi_kit_context_management::summarize().crates/goose/src/context_mgmt/mod.rs: add unit testself_compact_summarizes_only_agent_visible_non_turn_context_messages(verified failing before the fix, passing after)..github/workflows/patched-test.yml: register the new test in the exact-match CI filter.Verification
cargo test -p goose --lib -- context_mgmt::tests::(9/9 passed)cargo test -p goose --test self_compact(19/19 passed)cargo fmt --checkandcargo clippy -p goose --lib --test self_compact -- -D warningsclean