Repository navigation
feat(compact): reactive compaction with adaptive window cap and context reservation - #274
Open
jiangchuanso wants to merge 1 commit into
Open
jiangchuanso wants to merge 1 commit into
jiangchuanso wants to merge 1 commit into
Conversation
…xt reservation Implement reactive compaction that preserves recent original messages and emits context/compaction events. Add adaptive reservation and a configurable window cap, and map over-window 400 responses to PromptTooLong.
This branch has not been deployed
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
Introduce reactive compaction: instead of compacting only on a fixed trigger, the agent reacts to context-window pressure, preserves the most recent original messages, and emits context/compaction events so hosts (e.g. JSON stream consumers) can observe what happened.
crates/aion-config/src/compact.rs,config.rs): compaction reserve and a configurable window cap are parsed from config, so reserved headroom adapts to the effective context window.crates/aion-agent/src/compact/auto.rs,estimate.rs,context_usage.rs,engine.rs): compaction is driven by context-usage signals; recent original turns are kept verbatim instead of being folded into the summary. New context/compaction notifications are published through the output sinks (output/sink.rs,output/protocol_sink.rs).PromptTooLongrather than a generic error (crates/aion-providers/src/error.rs,transport.rs,retry.rs).crates/aion-protocol/src/events.rs,commands.rs,crates/aion-types/src/compact.rs): new context/compaction events are added to the JSON stream protocol and documented indocs/json-stream-protocol.md.Test plan
auto_test.rs), provider error classification (error_test.rs) and protocol command construction (commands_test.rs).crates/aion-agent/tests/autocompact_test.rsexercises the end-to-end compact behavior.cargo test/cargo clippygates in CI validate the change.