Repository navigation
fix(agent-runtime): shrink the retained-tail fallback until it fits - #2501
Merged
Merged
Conversation
The retained-tail recovery sized its window from the local token estimate, while the install check re-estimated with the calibrated one. When a provider counts more tokens than the estimate, every summary failure past the hard limit produced an oversized fallback and the turn ended with CONTEXT_COMPACTION_FAILED, on every later message too. The recovery now halves the window until the calibrated estimate fits, keeping the newest message. The resulting turn error names the checkpoint failure and is classified as local, so it no longer carries stale stream timings or HTTP status from an earlier request. fixes #2494
Deploying pi-desktop with
|
| Latest commit: |
d7dbeac
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9336ed46.pi-desktop.pages.dev |
| Branch Preview URL: | https://fix-compaction-stream-abort.pi-desktop.pages.dev |
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.
Fixes #2494.
Root cause
The retained-tail fallback sized its window from the local token estimate, but
persistCheckpointre-estimates with the calibrated estimate. When the provider counts more tokens than the local estimate (calibration ratio ≳1.8, e.g. CJK-heavy context), every summary failure past the hard limit produced anoversizedfallback, so the turn failed withCONTEXT_COMPACTION_FAILED— and every later message took the same path.Change
recoverCompactionFailurehalves the fallback window until the calibrated estimate fits (down to 1/128; the newest message is always kept).CONTEXT_COMPACTION_FAILEDturn error now names the checkpoint failure cause.CONTEXT_COMPACTION_FAILEDis classifiedorigin: "local", so it no longer carries staleproviderStatus/streamMsfrom the previous request (the misleadingproviderStatus: 200, streamMs: 0in the report).02-agent-runtime.mdupdated.Validation
vitest runin agent-runtime: 2083 passed;system-ca.test.tsflaked once under load and passes in isolation.tsc --noEmit,biome lint, docs checks pass.