-
Notifications
You must be signed in to change notification settings - Fork 61
fix(compaction): bound what a summary request is asked to read #2072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rogercloud
wants to merge
5
commits into
xorbitsai:main
Choose a base branch
from
rogercloud:feat/bound-compact-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a774f20
fix(compaction): bound what a summary request is asked to read
a675d56
fix(compaction): preserve unrecoverable oversized messages
c1dfec5
fix(compaction): preserve context on token overflow
2ad6ff5
fix(compaction): fail closed on provider overflow
54587a5
style: sort compaction test imports
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Context compaction hardening follow-up | ||
|
|
||
| The immediate oversized-message fix intentionally remains small. A later | ||
| follow-up should turn compaction into a complete, model-aware budgeting and | ||
| recovery pipeline. | ||
|
|
||
| ## Budgeting | ||
|
|
||
| - Represent the compact model's context window, input budget, output budget, | ||
| and safety margin explicitly. | ||
| - Use the resolved compact model rather than the main model when their windows | ||
| differ. | ||
| - Count the complete provider request, including wrappers, tool calls, message | ||
| content, context references, and output allowance. | ||
| - Use the resolved model's tokenizer where available; keep the conservative | ||
| generic tokenizer only as a fallback. | ||
| - Verify both the summary request and the post-compaction agent request. | ||
|
|
||
| ## Recoverability | ||
|
|
||
| - Record explicit recovery metadata for tool observations, including whether | ||
| the operation is read-only and the durable arguments or handles needed to | ||
| repeat the read. | ||
| - Do not infer recoverability from the message role or tool name alone. | ||
| - Preserve file paths, URLs, resource identifiers, artifact handles, and other | ||
| durable locators separately from large raw payloads. | ||
| - Never re-run writes, sends, executions, or other state-changing operations | ||
| to recover a dropped observation. | ||
|
|
||
| ## Oversized unrecoverable messages | ||
|
|
||
| - Protect user, system, and assistant messages by default. | ||
| - Summarize natural language in bounded chunks along paragraph or semantic | ||
| boundaries. | ||
| - Split JSON, code, and tables only at structural boundaries. | ||
| - Merge chunk summaries hierarchically while retaining source message IDs for | ||
| auditability. | ||
| - Report an explicit blocked state when safe compaction is impossible. | ||
|
|
||
| ## Result and fallback semantics | ||
|
|
||
| - Track which messages a summary covers and which original messages remain | ||
| protected. | ||
| - Build the next context from the summary, protected originals, durable | ||
| recovery references, and the latest user request. | ||
| - Ensure protected messages do not trigger the same ineffective compaction on | ||
| every turn. | ||
| - Allow destructive truncation only for content already represented by a | ||
| summary or proven recoverable. | ||
| - Distinguish input overflow, output rejection, unusable summaries, tokenizer | ||
| uncertainty, and unrecoverable content in trace metadata. | ||
|
|
||
| ## Test matrix | ||
|
|
||
| - Every message role and mixtures of recoverable and unrecoverable content. | ||
| - One oversized message and cumulative overflow from individually small ones. | ||
| - Large tool calls, context references, multilingual text, emoji, code, JSON, | ||
| and tables. | ||
| - Different main-model and compact-model windows. | ||
| - Multiple protected messages, repeated compaction, checkpoint, and resume. | ||
| - Provider input/output rejection and partial chunk-summary failure. | ||
| - Invariants that successful compaction preserves user constraints, never | ||
| silently deletes unrecoverable data, fits the target window, and actually | ||
| shrinks the context. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.