Skip to content

fix(reasoning): add 'max' to VALID_REASONING_EFFORTS (Opus 4.7+ 5-level ladder) - #34199

Closed
adzendo wants to merge 2 commits into
NousResearch:mainfrom
adzendo:fix/reasoning-effort-max-level
Closed

fix(reasoning): add 'max' to VALID_REASONING_EFFORTS (Opus 4.7+ 5-level ladder)#34199
adzendo wants to merge 2 commits into
NousResearch:mainfrom
adzendo:fix/reasoning-effort-max-level

Conversation

@adzendo

@adzendo adzendo commented May 29, 2026

Copy link
Copy Markdown

Summary

Anthropic Opus 4.7+ (including Opus 4.8) expose a five-level adaptive-thinking ladder: low < medium < high < xhigh < max. The Anthropic adapter already maps "max" -> "max" and the API accepts output_config.effort="max" (verified live). But max was rejected at two Hermes-layer gates, causing a silent downgrade to medium.

This PR fixes both, in 2 commits.

Commit 1 — config/CLI layer

parse_reasoning_effort() in hermes_constants.py rejected "max" because it was missing from VALID_REASONING_EFFORTS. Setting agent.reasoning_effort: max (or CLI /reasoning max) returned None'Unknown reasoning_effort, using default (medium)'silent downgrade of the highest tier.

  • Add "max" to VALID_REASONING_EFFORTS + docstring.
  • Update test_unknown_levels_return_none which hard-coded max as invalid (now covered by test_each_valid_level).

Commit 2 — gateway slash-command layer

The platform /reasoning handler in gateway/run.py had a second, duplicated hardcoded set {minimal,low,medium,high,xhigh} that still rejected max with 'Unknown argument', and the usage/unknown_arg locale strings didn't list it.

  • gateway/run.py: replace the duplicated literal set with the canonical VALID_REASONING_EFFORTS constant — the two validation paths can no longer drift.
  • locales/*.yaml (16 languages): add max to the /reasoning usage line and the unknown_arg valid-levels list.

Provider safety

  • Anthropic (Opus 4.7+/4.8): max is first-class; 4.6 already downgrades xhigh -> max.
  • OpenAI/Codex (GPT-5.5): effort string passed through; max accepted.
  • Gemini: maps via thinking-budget with safe fallback.

Test

pytest tests/test_hermes_constants.py -q   # 40 passed

parse_reasoning_effort("max"){"enabled": True, "effort": "max"}; gateway /reasoning max now accepted end-to-end.

Anthropic Opus 4.7+ (incl. 4.8) expose a 5-level adaptive-thinking ladder:
low < medium < high < xhigh < max. The adapter (agent/anthropic_adapter.py
ADAPTIVE_EFFORT_MAP) already maps 'max' -> 'max' and the Anthropic API
accepts output_config.effort='max', but parse_reasoning_effort() rejected
'max' because it was missing from VALID_REASONING_EFFORTS.

Effect of the bug: setting agent.reasoning_effort='max' (or /reasoning max)
silently fell back to medium with an 'Unknown reasoning_effort' warning --
a severe, silent downgrade on the highest-effort tier.

Fix: add 'max' to the allow-list tuple + docstring. Non-Anthropic providers
(OpenAI/Codex GPT-5.5, Gemini) also accept/​degrade 'max' safely via their
effort passthrough. Updates the unknown-levels test which hard-coded 'max'
as invalid; 'max' is now covered by test_each_valid_level.
…rings

The first commit fixed parse_reasoning_effort(), but the Telegram/platform
/reasoning slash-command handler in gateway/run.py had its OWN hardcoded
validation set {minimal,low,medium,high,xhigh} that still rejected 'max'
with 'Unknown argument', and the usage/unknown_arg locale strings didn't
list it.

- gateway/run.py: replace the duplicated hardcoded set with the canonical
  VALID_REASONING_EFFORTS constant so the two paths can never drift again.
- locales/*.yaml (16 langs): add 'max' to the /reasoning usage line and the
  unknown_arg valid-levels list.

Now '/reasoning max' works end-to-end on chat platforms, matching the CLI
and config behavior.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery provider/anthropic Anthropic native Messages API labels May 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #12211. See also #25401, #14717, #29248, #29269 — all address the same missing max in VALID_REASONING_EFFORTS.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the duplicated validation path. This has since been implemented and expanded on current main by PR #62650 (7550c594ce18d7d100014c2120112576efb03c26).

  • hermes_constants.py:794-822 now accepts both max and ultra through the canonical parser.
  • gateway/slash_commands.py:2734-2737 accepts max for /reasoning (and also ultra).
  • tests/gateway/test_reasoning_command.py:152-172 directly verifies /reasoning max persists the selected session override.
  • The member's duplicate report and linked work were consistent with this later superseding implementation.

Closing as implemented on main by automated hermes-sweeper review.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants