fix(gateway): propagate max_tokens from config.yaml to AIAgent#20804
Closed
ViewWay wants to merge 2 commits into
Closed
fix(gateway): propagate max_tokens from config.yaml to AIAgent#20804ViewWay wants to merge 2 commits into
ViewWay wants to merge 2 commits into
Conversation
max_tokens set under model: in config.yaml was silently ignored. The value was never read from config, never passed through _resolve_runtime_agent_kwargs(), _resolve_turn_agent_config(), or the session override path. Added it to all three code paths so custom/Ollama endpoints receive the correct output cap. Closes NousResearch#20741
Collaborator
…r override Previous commit only covered the gateway runtime path. This adds: - CLI __init__: read max_tokens from model config with HERMES_MAX_TOKENS env override - CLI AIAgent() calls (interactive + background): pass max_tokens - Gateway _resolve_runtime_agent_kwargs: add HERMES_MAX_TOKENS env override All three code paths (CLI, gateway runtime, session override) now consistently propagate max_tokens to AIAgent.
Contributor
|
Merged via #39864 — your two commits were cherry-picked onto current main with your authorship preserved in |
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
max_tokensset undermodel:inconfig.yamlwas never read or propagated toAIAgent.__init__(). On providers without a hardcoded default (Ollama Cloud, custom endpoints), the parameter was omitted entirely, causing truncated responses withfinish_reason="length".Changes
Four surgical additions — one new key in each of three runtime dicts, plus the config read:
_resolve_runtime_agent_kwargs()model.max_tokensfrom config, add to return dict_resolve_session_agent_runtime()override pathmax_tokensto override_runtime_resolve_turn_agent_config()max_tokensfrom runtime_kwargsNo behavioral change when
max_tokensis unset (remainsNone→ model default).Testing
py_compile.Closes #20741