feat: per-provider max_tokens via custom_providers models.<model>.max_tokens#28786
Open
pty819 wants to merge 1 commit into
Open
feat: per-provider max_tokens via custom_providers models.<model>.max_tokens#28786pty819 wants to merge 1 commit into
pty819 wants to merge 1 commit into
Conversation
…model>.max_tokens Adds a new lookup function get_custom_provider_max_tokens() parallel to the existing get_custom_provider_context_length(). When model.max_tokens is unset globally, the agent init path now falls back to checking custom_providers for a per-provider max_tokens override, matched by base_url + model name. This allows users to set a provider-scoped output-token cap without affecting fallback providers in the chain. Closes NousResearch#28782
This was referenced May 19, 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.
Summary
Adds per-provider
max_tokenssupport tocustom_providers, mirroring the existingcontext_lengthpattern. This allows users to set a provider-scoped output-token cap without affecting fallback providers.Problem
model.max_tokensinconfig.yamlis global — it applies to all providers including fallbacks. There is no way to scopemax_tokensto a specific provider, unlikecontext_lengthwhich already supports per-provider overrides.Changes
hermes_cli/config.pyget_custom_provider_max_tokens()— mirrorsget_custom_provider_context_length()exactly. Matches bybase_url+modelname, returnsmodels.<model>.max_tokensif present and valid."max_tokens"to_KNOWN_KEYSin_normalize_custom_provider_entryso the top-level key is not flagged as unknown (defensive, for users who had it at top level).agent/agent_init.pymodel.max_tokensfallback (and before context_length resolution), adds a second fallback that checkscustom_providersfor a per-providermax_tokenswhenagent.max_tokensis stillNone.Usage
Related
Closes #28782