Fix 400 "thinking.type.enabled is not supported" when using a direct Anthropic API key - #4480
Merged
Merged
Conversation
sejas
marked this pull request as ready for review
August 7, 2026 14:59
Collaborator
📊 Performance Test ResultsComparing 2857e7f vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
Member
Author
|
I'm merging this as I want to include it in the next release. |
1 task
sejas
added a commit
that referenced
this pull request
Aug 7, 2026
…I key (1.18.0) (#4484) Cherry-picks 97a5a94 from trunk: chatting with a direct Anthropic API key always failed with `400 "thinking.type.enabled" is not supported for this model`. See #4480 for full details. - Copies thinking metadata (`compat`, `thinkingLevelMap`) from pi-ai's bundled catalog so requests use `thinking: { type: "adaptive" }`. - Passes `allowNetwork: false` when setting the runtime API key, removing an unguarded per-turn network fetch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
Used to trace the failing request path, design the fix, and write the regression tests. All changes were reviewed and verified locally against the live Anthropic API.
Proposed Changes
Chatting with a direct Anthropic API key (
/provider→ Anthropic · API key) always fails:Studio's hand-built model definition was missing the catalog metadata that tells the pi runtime that
claude-sonnet-5/claude-opus-5require the adaptive thinking request shape, so it sent the legacy budget-based shape, which the API rejects.This PR:
compat,thinkingLevelMap) from pi-ai's bundled Anthropic catalog into Studio's model definition, so requests usethinking: { type: "adaptive" }. The values stay in sync with pi-ai upgrades, and a new test fails if a future Studio model is missing from the catalog.allowNetwork: falsewhen setting the runtime API key — the implicit default triggered an awaited, unguarded network fetch of remote model catalogs on every direct-key turn (which also hung the new tests on a CI agent with slow egress). Studio hand-builds its models, so the fetch was pure latency.No behavior change for the WordPress.com provider, apart from dropping a beta header that adaptive-thinking models don't need. Studio's conservative context-window/output limits are unchanged.
Noted for a follow-up issue: the WordPress.com proxy path never requests extended thinking at all — the custom provider forwards options that pi-ai's low-level
streamignores.Testing Instructions
npm run cli:build && node apps/cli/dist/cli/main.mjs ai/provider→ "Anthropic · API key", enter a validsk-ant-...key./provider→ WordPress.com, send a prompt — still working.Pre-merge Checklist