feat(config): add per-model max_tokens overlay#29705
Open
digitalbase wants to merge 1 commit into
Open
Conversation
13 tasks
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.
If you use providers like openrouter, bedrock the single max_token setting isn't enough. It needs to be dynamic based on the model.
Summary
Adds a
model.models.<id>.max_tokensoverlay so a single profile can switch between models with different output-token ceilings without mutating the flatmodel.max_tokensfallback.Resolution order is:
max_tokensmodel.models.<active_model>.max_tokensmodel.max_tokensWhy this is not a duplicate
Related PRs solve adjacent scopes, but not this specific config shape:
model.models.<id>overlay pattern forcontext_lengthandprovider_routing, and explicitly notesmax_tokensas a natural future extension. This PR is that focused extension for output-token caps.custom_providers[].models.<model>.max_tokens, which helps custom-provider entries but not built-in providers like Bedrock/Anthropic/OpenAI or normal model switching within one profile.model.max_tokenspropagation, but not per-active-model overrides.Changes
agent/agent_init.py: resolvemodel.models.<active>.max_tokensbefore flatmodel.max_tokens, preserving constructor precedence and positive-int validation.gateway/run.py: includemodel.modelsin gateway agent cache-busting keys so edits to overlays rebuild cached agents.cli-config.yaml.example: document the per-model output-token overlay.