Skip to content

feat(config): add per-model max_tokens overlay - #29705

Closed
digitalbase wants to merge 1 commit into
NousResearch:mainfrom
digitalbase:feat/per-model-max-tokens-overlay
Closed

feat(config): add per-model max_tokens overlay#29705
digitalbase wants to merge 1 commit into
NousResearch:mainfrom
digitalbase:feat/per-model-max-tokens-overlay

Conversation

@digitalbase

@digitalbase digitalbase commented May 21, 2026

Copy link
Copy Markdown
Contributor

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_tokens overlay so a single profile can switch between models with different output-token ceilings without mutating the flat model.max_tokens fallback.

model:
  default: anthropic/claude-opus-4.6
  max_tokens: 8192              # fallback for unmatched models
  models:
    anthropic/claude-opus-4.6:
      max_tokens: 32768
    gpt-5.5:
      max_tokens: 65536

Resolution order is:

  1. Explicit constructor/programmatic max_tokens
  2. model.models.<active_model>.max_tokens
  3. Flat model.max_tokens
  4. Provider/model default

Why this is not a duplicate

Related PRs solve adjacent scopes, but not this specific config shape:

Changes

  • agent/agent_init.py: resolve model.models.<active>.max_tokens before flat model.max_tokens, preserving constructor precedence and positive-int validation.
  • gateway/run.py: include model.models in gateway agent cache-busting keys so edits to overlays rebuild cached agents.
  • cli-config.yaml.example: document the per-model output-token overlay.
  • Tests cover override wins, unmatched fallback, invalid per-model fallback, constructor precedence, and gateway cache invalidation.

@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have labels May 21, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused implementation and the coverage of precedence, invalid values, and gateway cache invalidation.

  • This is an automated hermes-sweeper review.
  • The PR's substance is a new user-facing model.models.<id>.max_tokens configuration surface (agent/agent_init.py, cli-config.yaml.example; commit c9dee52a71de).
  • Hermes has a standing policy against user-facing max_tokens knobs, including per-model and config-based variants (max-tokens-knob). The configuration shape does not change that policy.
  • The timeline's related feat(custom_providers): per-model max_tokens with switch/fallback re-resolution #35518 reference does not alter this policy match.

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 (max-tokens-knob). This is a design-direction decision, not a code-quality judgment — see the Contribution Rubric in AGENTS.md for what the project is looking for. If you believe this policy was misapplied to your change, comment here and a maintainer will take a look.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) label Jul 13, 2026
@digitalbase

Copy link
Copy Markdown
Contributor Author

Thanks for the focused implementation and the coverage of precedence, invalid values, and gateway cache invalidation.

  • This is an automated hermes-sweeper review.
  • The PR's substance is a new user-facing model.models.<id>.max_tokens configuration surface (agent/agent_init.py, cli-config.yaml.example; commit c9dee52a71de).
  • Hermes has a standing policy against user-facing max_tokens knobs, including per-model and config-based variants (max-tokens-knob). The configuration shape does not change that policy.
  • The timeline's related feat(custom_providers): per-model max_tokens with switch/fallback re-resolution #35518 reference does not alter this policy match.

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 (max-tokens-knob). This is a design-direction decision, not a code-quality judgment — see the Contribution Rubric in AGENTS.md for what the project is looking for. If you believe this policy was misapplied to your change, comment here and a maintainer will take a look.

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

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

Labels

area/config Config system, migrations, profiles comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants