fix(reasoning): add 'max' to VALID_REASONING_EFFORTS (Opus 4.7+ 5-level ladder) - #34199
Closed
adzendo wants to merge 2 commits into
Closed
fix(reasoning): add 'max' to VALID_REASONING_EFFORTS (Opus 4.7+ 5-level ladder)#34199adzendo wants to merge 2 commits into
adzendo wants to merge 2 commits into
Conversation
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.
Collaborator
19 tasks
Contributor
|
Thanks for identifying the duplicated validation path. This has since been implemented and expanded on current main by PR #62650 (
Closing as implemented on main by automated hermes-sweeper review. |
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
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 acceptsoutput_config.effort="max"(verified live). Butmaxwas 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()inhermes_constants.pyrejected"max"because it was missing fromVALID_REASONING_EFFORTS. Settingagent.reasoning_effort: max(or CLI/reasoning max) returnedNone→ 'Unknown reasoning_effort, using default (medium)' → silent downgrade of the highest tier."max"toVALID_REASONING_EFFORTS+ docstring.test_unknown_levels_return_nonewhich hard-codedmaxas invalid (now covered bytest_each_valid_level).Commit 2 — gateway slash-command layer
The platform
/reasoninghandler ingateway/run.pyhad a second, duplicated hardcoded set{minimal,low,medium,high,xhigh}that still rejectedmaxwith 'Unknown argument', and the usage/unknown_arg locale strings didn't list it.gateway/run.py: replace the duplicated literal set with the canonicalVALID_REASONING_EFFORTSconstant — the two validation paths can no longer drift.locales/*.yaml(16 languages): addmaxto the/reasoningusage line and theunknown_argvalid-levels list.Provider safety
maxis first-class; 4.6 already downgradesxhigh -> max.maxaccepted.Test
parse_reasoning_effort("max")→{"enabled": True, "effort": "max"}; gateway/reasoning maxnow accepted end-to-end.