Skip to content

Use lower thinking/effort for cron and hook sessions under OAuth#129

Open
constkolesnyak wants to merge 1 commit into
ClickHouse:mainfrom
constkolesnyak:upstream/cron-effort-oauth
Open

Use lower thinking/effort for cron and hook sessions under OAuth#129
constkolesnyak wants to merge 1 commit into
ClickHouse:mainfrom
constkolesnyak:upstream/cron-effort-oauth

Conversation

@constkolesnyak

Copy link
Copy Markdown
Contributor

Problem

Every cron run on Claude OAuth (subscription) fails with:

API Error: 400 level "max" not supported, valid levels: low, medium, high

Root cause: the global agent.thinking=max / agent.effort=max defaults are applied to every session, including cron and hook sessions that run on cron_model (Sonnet by default). Claude OAuth 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.

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_thinking and agent.cron_effort settings (default high) 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_effort
  • everything else → thinking / effort (unchanged)

Defaults match what works under OAuth on Sonnet (high). Users with a provider that accepts max for Sonnet can lift the defaults.

Composes cleanly with the existing model-aware _parse_thinking_config(value, model) / _effective_effort(value, model) helpers — _select_thinking_effort only 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_effort returns cron_* for cron and hook, defaults for everything else
  • explicit override + None handling
  • defaults of high for cron_thinking / cron_effort

Full suite: 1164 passed, 2 skipped (excluding pre-existing tests/test_cron.py::TestMaybeRotateContext rotate_at failures unrelated to this change — present on main too).

Files

  • nerve/config.py — add cron_thinking / cron_effort to AgentConfig with "high" defaults
  • nerve/agent/engine.py_select_thinking_effort helper, used at session-start path
  • nerve/bootstrap.py — surface in bootstrap defaults
  • config.example.yaml, docs/config.md — document the two new keys
  • tests/test_engine_options.py — new

History

Previously opened as #53, closed in error against the wrong target. This is the recreated version against upstream, rebased onto current main with the model-aware _parse_thinking_config / _effective_effort API.

Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant