Skip to content

Cron/hook thinking-effort: downgrade only under OAuth proxy#14

Merged
constkolesnyak merged 1 commit into
mainfrom
fix/cron-effort-oauth-only
Jun 25, 2026
Merged

Cron/hook thinking-effort: downgrade only under OAuth proxy#14
constkolesnyak merged 1 commit into
mainfrom
fix/cron-effort-oauth-only

Conversation

@constkolesnyak

Copy link
Copy Markdown
Owner

Summary

Addresses the review feedback on ClickHouse/nerve#129:

This will change the behavior for API users. We should keep it `max` by default and switch to `high` when OAuth subscription is used. — Artem

The original implementation introduced agent.cron_thinking and agent.cron_effort config fields defaulting to high, applied unconditionally to every cron/hook session. That silently downgraded API users who explicitly configure effort=max / thinking=max and accept max on every model.

Fix

OAuth in nerve is gated by the local cli-proxy-api wrapping the user's subscription credentials — config.proxy.enabled is the single source of truth. The helper now reads that flag and only downgrades when the session is cron/hook AND proxy is enabled. API users (no proxy) and interactive sessions keep their configured value unchanged.

Changes:

  • nerve/config.py — remove cron_thinking / cron_effort fields from AgentConfig and the matching from_dict lines. Defaults stay at thinking=max / effort=max for everyone.
  • nerve/agent/engine.py_select_thinking_effort(config, source) now takes the full NerveConfig (was AgentConfig) and applies a max-only cap: when source in ("cron", "hook") and config.proxy.enabled, maxhigh (lower values pass through). Single call site updated.
  • nerve/bootstrap.py — drop the two SetupWizard defaults.
  • config.example.yaml — drop the two keys; replace the multi-line comment with a note that the cap is automatic under OAuth.
  • docs/config.md — drop the two doc rows; fold the OAuth+cron caveat into the existing thinking / effort rows.

Composes cleanly with the existing model-aware _effective_effort (which already caps Sonnet at high) — this layer handles the thinking side (which is otherwise rejected by the CLI as a string-level max) and is explicit about the OAuth trigger.

Tests

tests/test_engine_options.py rewritten around the OAuth gate (21 tests, all passing):

  • OAuth ON + cron / hook + max,max("high","high") (the bug being fixed).
  • OAuth ON + cron / hook + lower values → unchanged (cap, not force).
  • OAuth ON + cron / hook + mixed → each knob capped independently.
  • OAuth ON + interactive sources (web / telegram / discord / api / "") + max,max → unchanged (main model accepts max under OAuth).
  • OAuth OFF + every source + max,max → unchanged (Artem's exact requirement).
  • OAuth OFF + cron + lower values → unchanged.
  • AgentConfig.from_dict({"cron_thinking": "high", "cron_effort": "high"}) silently ignores the legacy keys (backwards-compat).
  • Default AgentConfig no longer has cron_thinking / cron_effort attributes (asserted with hasattr).

Verification

  • pytest tests/test_engine_options.py -v — 21/21 pass.
  • pytest -q — 1306 passed, 2 skipped, 0 failed.

Notes for the upstream PR

Phase 1: this PR opens against the fork (constkolesnyak/nerve:main) for review. Phase 2 (separate) will push the same change to upstream/cron-effort-oauth and update ClickHouse/nerve#129.

🤖 Generated with Claude Code

Previous version added `agent.cron_thinking` and `agent.cron_effort`
config fields, both defaulting to `high`, applied to every cron/hook
session regardless of provider. That changed behavior for API users
who configure `effort=max` / `thinking=max` and accept it on every
model — they got silently downgraded.

Artem's review on ClickHouse#129: keep `max` by default and
switch to `high` only when OAuth subscription is in use.

OAuth in nerve is gated by the local cli-proxy-api wrapping the
user's subscription credentials — i.e. `config.proxy.enabled`. The
helper now reads that flag and only downgrades when source is
cron/hook AND proxy is enabled. API users (no proxy) keep their
configured value untouched, even for cron sessions.

Changes:
* `nerve/config.py`: remove `cron_thinking` / `cron_effort` fields
  and from_dict entries. Defaults stay at `max` / `max`.
* `nerve/agent/engine.py`: rewrite `_select_thinking_effort` to take
  the full Config (not just agent_config) and cap `max` -> `high`
  for cron/hook only when `config.proxy.enabled`. Update the single
  call site.
* `nerve/bootstrap.py`: remove the two SetupWizard defaults.
* `config.example.yaml`: drop the two keys, replace comment with a
  note that the cap is automatic under OAuth.
* `docs/config.md`: drop the two doc rows, fold the OAuth+cron note
  into the existing `thinking` / `effort` rows.
* `tests/test_engine_options.py`: rewrite around the new OAuth gate.
  21 tests covering OAuth on/off × cron/hook/interactive × max/lower
  values, plus the from_dict backwards-compat (legacy cron_thinking/
  cron_effort keys are silently ignored).

Tests: 21/21 in tests/test_engine_options.py. Full suite: 1306 passed,
2 skipped, 0 failed.

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