refactor: centralize model input token limit resolution#2071
Open
NarwhalChen wants to merge 1 commit into
Open
refactor: centralize model input token limit resolution#2071NarwhalChen wants to merge 1 commit into
NarwhalChen wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 1cf8f8c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
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 #2036. @RealKai42 identified the duplicated input-limit fallback as a deliberate out-of-scope cleanup.
Problem
Compaction, context validation, session status, and SDK/server projections independently repeated the rule that a model's prompt ceiling prefers
max_input_tokens, falls back tomax_context_tokens, and uses zero when capability data is unavailable. Keeping that semantic decision at each consumer risks the engine and its status surfaces drifting apart.What changed
getModelInputTokenLimitat the model-capability boundary in legacy kosong and in the self-contained v2 contract.Completion-budget code intentionally continues to use the total context window because it answers a different question: how much output can fit after the prompt.
Verification
pnpm --filter @moonshot-ai/agent-core test— 3,978 passedpnpm --filter @moonshot-ai/agent-core-v2 test— 3,951 passedpnpm --filter @moonshot-ai/agent-core-v2 lint:domainoxlint --type-awareon all touched TypeScript files — 0 errorsgit diff --checkChecklist
gen-changesetsskill and added a changeset.