feat(compact): cap summary completion and measure post-checkpoint fit - #456
Open
bobzhang wants to merge 2 commits into
Open
feat(compact): cap summary completion and measure post-checkpoint fit#456bobzhang wants to merge 2 commits into
bobzhang wants to merge 2 commits into
Conversation
The checkpoint reserve documents that it holds the summary completion, but nothing enforced it: the summary request passed no max_tokens, so a rambling summarizer could spend past the reserve and strand the session via fail-open. Client::chat gains an optional max_tokens (encoded only when passed); the summary request caps itself at the new CompactionSummaryMaxTokens (8_192), and a whitebox test pins the reserve > cap relation. Generation now also rejects a response that answers with native tool calls (no usable summary; fails fail-open like an empty one) and warns when the completion spent the whole cap (length-truncated summary: kept, a truncated checkpoint beats none). The auto checkpoint additionally logs its fit postcondition: the compacted projection's model-visible chars on auto_compaction_finished, plus a warning when even the conservative char accounting says the next request cannot fit — the summary did not relieve the ceiling it was generated for. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Three subal findings. Kimi ignores thinking=No and its legacy max_tokens budget is shared with reasoning_content, so an 8K cap could be spent entirely on reasoning and hand back empty visible content — failing every ceiling checkpoint on Kimi; the cap now encodes as max_completion_tokens for Kimi models (snapshot test added). The post-checkpoint telemetry field is renamed to compacted_projection_chars: it measures the checkpoint's output at checkpoint time, a lower bound the surrounding shapes' suffixes (late steers, kept answers, goal notices) only grow. The warning becomes auto_compaction_fit_unproven — chars overestimate tokens, so crossing the window means conservative accounting can no longer prove the next request fits, not proven overflow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Fourth slice of the compaction production-hardening plan (R2: enforce the reserve's contract). Stacked on #455.
Client::chatgains optionalmax_tokens, encoded per provider:max_tokensfor DeepSeek,max_completion_tokensfor Kimi — Kimi ignoresthinking=Noand its legacy field shares the budget withreasoning_content, so a legacy cap could be spent entirely on reasoning and hand back an empty summary, failing every ceiling checkpoint (subal P1).CompactionSummaryMaxTokens(8,192); a whitebox test enforcescheckpoint_reserve_tokens > cap, the reserve's documented-but-previously-unenforced contract.compaction_summary_truncatedwhen the completion spends the whole cap (summary kept: truncated beats none at the ceiling).auto_compaction_finishedgainscompacted_projection_chars— the checkpoint's output size at checkpoint time, a lower bound later suffixes only grow — plus anauto_compaction_fit_unprovenwarning when conservative char accounting can no longer prove the next request fits (explicitly not proven overflow: chars overestimate tokens).Testing
moon check --deny-warnclean; deepseek+agent+compact 115/115.🤖 Generated with Claude Code