Skip to content

fix(claude): honor thinking.display "summarized" by not adding redact-thinking beta - #17003

Closed
huynle-dev wants to merge 3 commits into
cheaper-inference:release/v3.8.52from
huynle:fix/summarized-thinking-no-redact-beta
Closed

huynle-dev wants to merge 3 commits into
cheaper-inference:release/v3.8.52from
huynle:fix/summarized-thinking-no-redact-beta

Conversation

@huynle-dev

@huynle-dev huynle-dev commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Claude requests that explicitly ask for readable thinking (thinking: { type: "adaptive", display: "summarized" }, as sent by @ai-sdk/anthropic / OpenCode) came back with empty thinking text plus a signature. Cause: OmniRoute adds the redact-thinking-2026-02-12 beta by itself:

    • selectBetaFlags() pushes it for opaque clients and for any client that negotiated interleaved-thinking-2025-05-14 (which @ai-sdk/anthropic always sends), and
    • the static ANTHROPIC_BETA_API_KEY set used by API-key connections includes it.

    Only CC-compatible relays without the redactThinking opt-in had it stripped (the post-pass in base.ts).

  • Fix (new pure leaf open-sse/executors/base/redactThinkingBeta.ts):

    • selectBetaFlags() leaves out redact-thinking-2026-02-12 when the body asks for thinking.display: "summarized".
    • A final dispatch pass (right before stripInternalBodyFields) removes OmniRoute-added redact-thinking-* tokens from anthropic-beta under the same rule, so the static API-key set is covered too.
    • New opt-out OMNIROUTE_REDACT_THINKING=false stops OmniRoute adding the redact beta at all (documented in .env.example + docs/reference/ENVIRONMENT.md).
    • Unchanged: a client that negotiated a redact-thinking beta itself keeps it, and a CC-compatible connection with requestDefaults.redactThinking: true keeps it. Without display: "summarized" (and without the env), current behavior stays the same.

Related Issues

  • None filed; found while debugging empty summarized thinking through the native claude (OAuth) provider.

Target Branch

  • Base is the active release/v3.8.x branch (release/v3.8.52), not main

Validation

  • Change type: provider
  • Focused tests: tests/unit/claude-*.test.ts tests/unit/anthropic-*.test.ts tests/unit/executor-*.test.ts tests/unit/cc-compatible*.test.ts tests/unit/provider-request-failure-pipeline.test.ts tests/unit/context-editing-executor-injection.test.ts tests/unit/base-*.test.ts → 2064 tests, 2056 pass, 1 fail (Adapta stream errors are sanitized in an isolated executor fixture, which fails the same way locally without this change).
  • New test fails before the fix (4/9 red) and passes after.
  • tsc -p tsconfig.typecheck-core.json clean; Prettier clean; check-file-size and check-env-doc-sync OK.
  • npm run lint (CI)

Tests Added Or Updated

  • tests/unit/claude-5x-thinking-passthrough.test.ts (new, test-only): end-to-end handleChatCore coverage that captures the upstream /v1/messages body. thinking: {type:"adaptive", display:"summarized"} must reach the upstream unchanged for claude-haiku-5-5 / claude-sonnet-5-5 / claude-opus-5-5 on both claude (OAuth) and anthropic (API key). Haiku 4.5 must keep enabled + budget_tokens. A manual budget on Haiku 5.5 must collapse to adaptive. This is regression cover for fix(claude): stop downgrading adaptive thinking on claude-haiku-5-5 #15841: without it, 3.8.51 rewrites Haiku 5.5 to enabled + budget_tokens: 10000, which the API-key path rejects with 400 and the OAuth path answers with empty thinking. Passes on the current release/v3.8.52 tip.

  • tests/unit/claude-summarized-thinking-redact-beta.test.ts (new): predicate/env unit tests, selectBetaFlags with and without summarized display, the header strip helper (incl. client and connection opt-in), and end-to-end DefaultExecutor dispatch for claude (OAuth) and anthropic (API key) capturing the outbound anthropic-beta.

  • tests/unit/provider-request-failure-pipeline.test.ts (CC-compatible relay with redactThinking: true + summarizeThinking: true still keeps the beta) passes unchanged.

Coverage Notes

  • open-sse/executors/base/redactThinkingBeta.ts is fully exercised by the new test; the base.ts / claudeIdentity.ts call sites are covered by the dispatch tests.

Reviewer Notes

  • open-sse/executors/base.ts grows by +5 lines (1744 → 1749, cap 2094): one import plus one call at the final dispatch chokepoint.
  • Risk: requests that ask for summarized thinking no longer send redact-thinking-2026-02-12. That is the behavior the client asked for; set requestDefaults.redactThinking on a CC-compatible connection, or send the beta from the client, to keep redaction.

…"summarized"

OmniRoute adds the redact-thinking-2026-02-12 beta for opaque clients and
for clients that negotiate interleaved-thinking (selectBetaFlags), and the
static API-key beta set carries it too. With that beta Anthropic returns
thinking blocks with empty text (signature only), silently overriding an
explicit thinking.display: "summarized" from clients such as
@ai-sdk/anthropic / OpenCode.

- selectBetaFlags omits redact-thinking when the body asks for summarized
  thinking (or OMNIROUTE_REDACT_THINKING=false).
- A final dispatch pass strips OmniRoute-added redact-thinking-* tokens from
  anthropic-beta under the same rule (covers the static API-key set).
- Client-negotiated redact-thinking and CC-compatible connections with
  requestDefaults.redactThinking=true keep it.
…aiku 4.5

Pins the /v1/messages body handleChatCore sends for claude (OAuth) and
anthropic (API key): adaptive + display summarized passes through unchanged
on haiku/sonnet/opus 5.5, Haiku 4.5 keeps enabled + budget, and a manual
budget on Haiku 5.5 collapses to adaptive (regression cover for cheaper-inference#15841).
diegosouzapw added a commit that referenced this pull request Oct 18, 2026
…ed display (carries #17003) (#17040)

Carries #17003 by @huynle-dev (org-owned fork rejects maintainer pushes). Summarized thinking is no longer redacted for non-OAuth claude requests; the Claude OAuth fingerprint stays unchanged unless CLAUDE_OAUTH_SUMMARIZED_THINKING_UNREDACTED (default off) is enabled. Focused tests 95/95; typecheck, open-sse typecheck, boundary 774/774, env-doc-sync, changelog-integrity, docs-counts green. Remaining CI reds are the inherited base-red #15306. Thanks @huynle-dev for finding the root cause of #16407!

Co-authored-by: Huy Le <dacrazyazn@gmail.com>
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thank you @huynle-dev — this landed as #17040. Your branch is in an organization-owned fork, where GitHub does not let maintainers push even with "allow edits by maintainers" on (403), so your three commits were carried into #17040 unchanged and you are credited with a Co-authored-by trailer on the squash commit. On top of them, dropping the redact-thinking beta for Claude OAuth requests now sits behind a default-off flag (CLAUDE_OAUTH_SUMMARIZED_THINKING_UNREDACTED), because that beta is part of the Claude Code OAuth fingerprint; API-key requests get your fix by default. Closing this one as merged via #17040. (/merge-batch 2026-10-17)

diegosouzapw added a commit that referenced this pull request Oct 19, 2026
Reconcile the living [3.8.52] CHANGELOG section against the full cycle
(release/v3.8.51..0a1265e, 1,386 non-merge commits): fold the 74 pending
changelog.d fragments, add bullets for the 53 commits that had none, patch
PR links/credits on 50 bullets (closed-PR re-lands credited: #16988 ← #16982
@fabioKoruja00, #17040 ← #17003 @huynle-dev), regenerate the Contributors
table (306 external), date the header (TBD → 2026-10-19) and resync the 66
i18n CHANGELOG mirrors.
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.

2 participants