Cap adaptive-thinking effort per model's supported levels#55
Merged
Conversation
Global `agent.effort` (e.g. "max") is shared across the main agent and
auxiliary models (`cron_model`, memU recall/memorize). Sonnet/Haiku tiers
only advertise {low, medium, high}; forwarding "max" triggers a 400 from
CLIProxyAPI tier validation (`internal/thinking/validate.go:125`):
thinking: validation failed | provider=claude model=claude-sonnet-4-6
error=level "max" not supported, valid levels: low, medium, high
Same shape on Opus 4.6 with "xhigh" (supports max but not xhigh), and on
any auxiliary model the user configures below their main Opus 4.7.
Add `_effective_effort(value, model)` — a small table of known Claude
models with their advertised effort levels, and a step-down lookup that
caps the requested effort to the highest level the target model supports.
Unknown models pass through unchanged (backward compatible).
Preserves "max" for Opus 4.7 main agent while letting Sonnet cron/memU
calls succeed with the tier-appropriate level.
Symmetric with existing `_parse_thinking_config(value, model)` which is
already model-aware.
Implementation notes:
- `_MODEL_EFFORT_LEVELS` keys use substring form (`opus-4-7`, `opus-4-6`,
`sonnet-4-6`) iterated against the full model name so dated Anthropic
aliases like `claude-opus-4-7-20260416` resolve. Mirrors the
MODEL_PRICING pattern in nerve/db/usage.py and
`_model_supports_legacy_enabled_thinking` in the same file.
- `_effective_effort(value, model=None)` — default matches the sibling
`_parse_thinking_config(value, model=None)`.
- `logger.debug` when capping happens so users can trace why a configured
`effort: max` was forwarded as `high` to Sonnet.
- New `tests/test_engine.py` covers the cap table (incl. dated aliases,
unknown models, None/empty model, invalid effort string).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
pufit
approved these changes
Apr 30, 2026
neomnezia
added a commit
to neomnezia/nerve
that referenced
this pull request
Apr 30, 2026
Resolves conflict in nerve/channels/telegram.py by taking upstream version (fork's pre-squash drafts of PRs ClickHouse#55 and ClickHouse#56 superseded by upstream squash-merges). Brings in: - PR ClickHouse#60 — optional Langfuse observability - PR ClickHouse#56 — send_file Telegram delivery + cross-channel hardening - PR ClickHouse#55 — adaptive-thinking effort cap per model Drops fork-unique tests/test_telegram_send.py: imported symbols (FLOODWAIT_GAP_S, PREVIEW_FOOTER) that upstream squash-refactored away; upstream's tests/test_send_file.py provides equivalent coverage.
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
Global
agent.effort(e.g.max) is shared between the main agent and auxiliary models (cron_model, memU recall/memorize). Sonnet/Haiku tiers only advertise{low, medium, high}; forwardingmaxtriggers a 400 from CLIProxyAPI tier validation:Same shape on Opus 4.6 with
xhigh, and on any auxiliary model the user configures below their main Opus 4.7.Fix
Add
_effective_effort(value, model)— a small table of known Claude models with their advertised effort levels, plus a step-down lookup that caps the requested effort to the highest level the target model supports. Unknown models pass through unchanged (backward compatible).Preserves
maxfor the Opus 4.7 main agent while letting Sonnet cron/memU calls succeed with the tier-appropriate level.Symmetric with the existing
_parse_thinking_config(value, model)which is already model-aware.Notes
_MODEL_EFFORT_LEVELSkeys use substring form (opus-4-7,opus-4-6,sonnet-4-6) iterated against the full model name so dated Anthropic aliases likeclaude-opus-4-7-20260416resolve. Mirrors theMODEL_PRICINGpattern innerve/db/usage.pyand_model_supports_legacy_enabled_thinkingin the same file.logger.debugwhen capping so users can trace why a configuredeffort: maxwas forwarded ashighto Sonnet.tests/test_engine.pycovers the cap table — dated aliases, unknown models, None/empty model, invalid effort string.Test plan
pytest tests/test_engine.py— new cap-table tests passeffort: maxconfigured globally; main Opus 4.7 receivesmax, Sonnet cron/memU receivehigh(no more 400 from CLIProxyAPI)🤖 Generated with Claude Code