Skip to content

fix(agent): honor custom provider max_tokens#28154

Open
outsourc-e wants to merge 1 commit into
NousResearch:mainfrom
outsourc-e:fix/issue-28046-custom-provider-max-tokens
Open

fix(agent): honor custom provider max_tokens#28154
outsourc-e wants to merge 1 commit into
NousResearch:mainfrom
outsourc-e:fix/issue-28046-custom-provider-max-tokens

Conversation

@outsourc-e

Copy link
Copy Markdown
Contributor

Summary

  • read max_tokens from custom_providers[].models.<model> during agent init
  • preserve explicit max_tokens passed by CLI/config instead of overriding it
  • add regression coverage for valid, stringified, invalid, zero, and absent custom-provider max_tokens

Why

Issue #28046 reports that custom providers already honor per-model context_length, but still fall back to the 4096 default output cap because max_tokens was never loaded from the same per-model config.

Test Plan

  • scripts/run_tests.sh tests/run_agent/test_custom_provider_max_tokens.py

Closes #28046

@BoardJames-Bot BoardJames-Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed by Hermes Agent. Diff is narrow: custom provider per-model max_tokens is parsed only when no explicit max_tokens was supplied, invalid values warn/fall back, and focused regression tests pass locally (tests/run_agent/test_custom_provider_max_tokens.py: 6 passed). No blockers found.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder labels May 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #28142 which fixes the same issue (#28046) with virtually identical code in agent/agent_init.py. #28142 was opened ~36 minutes earlier. Both add the same max_tokens lookup block from custom_providers[].models.<model>. Part of the broader max_tokens cluster: #20004, #18445, #20705.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: max_tokens not read from custom_providers per-model config, always defaults to 4096

3 participants