Use lower thinking/effort for cron and hook sessions under OAuth#129
Open
constkolesnyak wants to merge 1 commit into
Open
Use lower thinking/effort for cron and hook sessions under OAuth#129constkolesnyak wants to merge 1 commit into
constkolesnyak wants to merge 1 commit into
Conversation
Every cron run was failing with `API Error: 400 level "max" not supported, valid levels: low, medium, high` because the global `agent.effort=max` and `agent.thinking=max` were applied to cron sessions too. Cron sessions run on `cron_model` (Sonnet by default), which under Claude OAuth (subscription) caps non-flagship models at `high` and rejects `max`. With a persistent cron session this also poisons every subsequent run on the same SDK session id. Add dedicated `agent.cron_thinking` / `agent.cron_effort` settings (default `high`) and a `_select_thinking_effort` helper that picks the right pair based on session source. `cron` and `hook` get the overrides; everything else keeps the main settings, so interactive sessions still get the full thinking budget on the flagship model. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.
Problem
Every cron run on Claude OAuth (subscription) fails with:
Root cause: the global
agent.thinking=max/agent.effort=maxdefaults are applied to every session, including cron and hook sessions that run oncron_model(Sonnet by default). Claude OAuth caps non-flagship models athighand rejectsmax. With a persistent cron session this also poisons every subsequent run on the samesdk_session_id.The main interactive model (Opus) accepts
max, so just lowering the global default would degrade the interactive experience to fix cron.Fix
Add dedicated
agent.cron_thinkingandagent.cron_effortsettings (defaulthigh) and a small_select_thinking_effort(agent_config, source)helper that returns the right pair for the session source:source in {"cron", "hook"}→cron_thinking/cron_effortthinking/effort(unchanged)Defaults match what works under OAuth on Sonnet (
high). Users with a provider that acceptsmaxfor Sonnet can lift the defaults.Composes cleanly with the existing model-aware
_parse_thinking_config(value, model)/_effective_effort(value, model)helpers —_select_thinking_effortonly picks the source-appropriate input, the model-aware step still gates per-model legality.Tests
tests/test_engine_options.py(new, 13 tests, all passing):_select_thinking_effortreturns cron_* forcronandhook, defaults for everything elsehighfor cron_thinking / cron_effortFull suite:
1164 passed, 2 skipped(excluding pre-existingtests/test_cron.py::TestMaybeRotateContextrotate_at failures unrelated to this change — present onmaintoo).Files
nerve/config.py— addcron_thinking/cron_efforttoAgentConfigwith"high"defaultsnerve/agent/engine.py—_select_thinking_efforthelper, used at session-start pathnerve/bootstrap.py— surface in bootstrap defaultsconfig.example.yaml,docs/config.md— document the two new keystests/test_engine_options.py— newHistory
Previously opened as #53, closed in error against the wrong target. This is the recreated version against upstream, rebased onto current
mainwith the model-aware_parse_thinking_config/_effective_effortAPI.