mpfaffenberger / mpfaffenberger/code_puppy

extended_thinking="off" does not actually disable thinking on Claude Opus 5 / Sonnet 5

Open
#780 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
814
Forks
278
Avg merge
2d 5h
Merged PRs (30d)
76

Description

This issue was posted by Claude Code using claude-opus-4-8 on behalf of David.

Reported from an adversarially-verified review; David directed the review and the finding was confirmed against the current main. Issue text is AI-drafted.

Where: code_puppy/model_utils.pyresolve_anthropic_thinking_payload

What. if extended_thinking not in ("enabled", "adaptive"): return None, and make_model_settings only sets anthropic_thinking when the payload is non-None. pydantic-ai's AnthropicModel._translate_thinking then returns OMIT (verified: if thinking is None or thinking is False: return OMIT), so the thinking parameter is absent from the wire request. The function never emits {"type": "disabled"} for any model.

Impact. A user on claude-opus-5 or claude-sonnet-5 who selects Extended Thinking = "off" in /model_settings (choices are ["enabled", "adaptive", "off"]) still gets adaptive thinking on every request and pays for the thinking tokens, with no error and no UI signal. It also interacts with the max_tokens cap: thinking and response text share that budget, so a turn sized for a thinking-free answer can truncate mid-response.

Suggested fix. Return {"type": "disabled"} when the target model's profile reports anthropic_supports_adaptive_thinking, and keep returning None only for classic models where omission genuinely means off. Clamp effort to high when thinking is disabled on Opus 5 — pydantic-ai encodes this as anthropic_disallows_top_effort_when_thinking_disabled and raises a UserError for xhigh/max. Fable 5 rejects {"type":"disabled"} at any effort, so that family must keep the omit behaviour.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in code_puppy/model_utils.py at resolve_anthropic_thinking_payload, then trace make_model_settings and pydantic-ai's AnthropicModel._translate_thinking behavior. Verify how the Opus 5, Sonnet 5, classic, and Fable 5 profiles handle disabled thinking and effort limits. Done means "off" is represented correctly for supported models without breaking classic or Fable behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.