SIGN IN SIGN UP

fix(claude): drop auto context_management without eligible thinking

Anthropic rejects the injected clear_thinking_20251015 strategy unless
thinking is enabled or adaptive:

  `clear_thinking_20251015` strategy requires `thinking` to be enabled or
  adaptive

Both sides of the automatic injection only special-cased the literal
{"type":"disabled"}, so an absent thinking field slipped through
gjson's empty string and the request was sent with a strategy the API
refuses. Two reachable paths produced it:

- a cloaked caller that never sent thinking at all;
- a caller whose thinking was enabled at injection time and then removed
  by disableThinkingIfToolChoiceForced, which runs between injection and
  reconciliation.

Both now test the accepted values instead of excluding the disabled one,
via a shared claudeThinkingAcceptsClearThinking helper, so reconciliation
also withdraws an object CPA injected itself once thinking disappears.
Caller-owned and payload-rule-owned objects keep their existing
precedence and are never withdrawn.

Verified against api.anthropic.com: context_management with thinking
absent or disabled returns 400, with thinking enabled returns 200. The
existing expectation that forced tool choice retains the automatic object
pinned the rejected shape and is inverted accordingly.
S
sususu committed
8638f28db55624e7829157c2f629fb426caf7204
Parent: a8bbbea
Committed by sususu98 <33882693+sususu98@users.noreply.github.com> on 8/11/2026, 11:33:40 AM