fix(agent-core): cap compaction output at 128k by default - #1156
Merged
Conversation
🦋 Changeset detectedLatest commit: aa0bd5d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Merged
Moixia
pushed a commit
to Moixia/idea
that referenced
this pull request
Jun 29, 2026
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.
Related Issue
Follow-up to #1129 and #1131.
Problem
After #1129, compaction reads
maxOutputSizefrom the model config. But whenmaxOutputSizeis not configured, compaction still falls back to the full context window size (max_context_tokens, often 1M+), which can exceed themax_tokensceiling enforced by OpenAI-compatible providers (e.g.[1, 393216]), triggering400 Invalid max_tokenserrors.#1131 added a 128k ceiling to the OpenAI Legacy provider, but the Kimi provider has no such ceiling, and compaction was intentionally left uncapped so it can always produce a summary. This leaves Kimi and any future chat-completions provider without a safe default.
What changed
maxOutputSizeis not set and the model's context window is known, compaction now caps its output atmin(max_context_tokens, 128k)instead of the full context window. This keeps compaction uncapped enough to produce a summary while staying below common provider ceilings.max_context_tokens === 0), the existing conservative fallback (32k orreservedContextSize) is preserved, so the unknown-context behavior is unchanged.maxOutputSizeis explicitly configured, it still takes precedence — this only changes the default.maxOutputSizeis not configured.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.