feat(config): add per-model max_tokens overlay - #29705
Conversation
|
Thanks for the focused implementation and the coverage of precedence, invalid values, and gateway cache invalidation.
Please keep provider-native output ceilings rather than adding a configurable output-token cap. A separate focused fix for a concrete transport/provider bug that does not introduce a user-facing max_tokens setting can be proposed independently. Closed as not-planned per standing maintainer policy ( |
Great automation. And i agree. One small note is that it would be nice to link to the standing policy as part of this review. More context = better |
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.