Repository navigation
Closed
Labels
scope/aiAI review pipeline, personas, prompts, LLM client, or RAGsource/agentFiled by an agenttype/bugType bug: the code does not do what it must
Description
Problem
Checked at release/v0.2.29 (05e9388). The claude provider's requests are written by hand (ai/client/claude.py), and they no longer match what current Claude models accept.
- Retired default model. An empty model falls back to
claude-3-5-sonnet(claude.py:45,:142), andDEFAULT_ANTHROPIC_MODELisclaude-3-5-sonnet-20241022(config/defaults.py:389). Claude Sonnet 3.5 was retired on 2025-10-28, and Claude Sonnet 3.7 on 2026-02-19. - Thinking chosen by name. Thinking is on only when the model name contains
claude-3-7or ends in:thinking(:47,:144). It is then sent as{"type": "enabled", "budget_tokens": N}(:58-61,:155-158). Current models use adaptive thinking ({"type": "adaptive"}, with depth set throughoutput_config.effort).budget_tokensis rejected with HTTP 400 on Claude Opus 4.7 and later and on Claude Sonnet 5 and later. - Sampling sent to models that refuse it. Whenever thinking is off, the unstreamed request sends
temperatureandtop_p(:62-68) fromai.temperatureandai.top_p, which default to 0.1 and 0.95 (config/defaults.py:70-71). Claude Opus 4.7 and later, Claude Opus 5 and 5.5 and Claude Sonnet 5 reject sampling parameters with HTTP 400, and Claude Sonnet 5.5 rejects non-default values. With default settings, every unstreamedclauderequest to a current model fails. - Streamed and unstreamed requests differ. The streamed request sends
temperaturebut nottop_p(:159-162). - The rest is hand-written too: the pinned
anthropic-version: 2023-06-01header (:41,:138), the content-block parse (:80-117), the SSE event decoding (ai/client/streaming.py:307-347) and the error mapping. - The
anthropicSDK (Anthropic; 1.12.1, released 2026-10-08; 1.5.0 is already in uv.lock through pydantic-ai) is built on httpx2 and accepts the factory's egress-checkedhttpx2.Clientashttp_client.
Proposed remedy
ClaudeProviderMixinholds oneanthropic.Anthropic(api_key=..., base_url=<ai.api_base_url, or the SDK default>, http_client=<the provider's factory client>, max_retries=0, timeout=...)and callsmessages.createandmessages.stream.- Thinking, effort and sampling come from the model's declared capability, never from its name. Adaptive thinking is sent where the model declares it, with
ai.reasoning_effortasoutput_config.effort.temperatureandtop_pare sent only where the model accepts them, in streamed and unstreamed calls alike. - An empty
ai.modelfor providerclauderaisesConfigurationErrornamingai.model.DEFAULT_ANTHROPIC_MODELand theclaude-3-*checks are deleted. _CLAUDE_EVENT_FRAMESand_claude_stream_frameare deleted; stop reasons still map throughCONST_ANTHROPIC_STOP_REASONS.- Declare
anthropicinpyproject.toml.
Key questions
- Where does the capability come from? (proposed) The Models API (
client.models.retrieve(model), whose reply carriescapabilities), read once per process and cached, because it is the provider's own statement. fix(ai): reasoning request parameters follow the model's declared capability, not its name #888's declared capability overrides it where set. - Who retries? (proposed) As for the OpenAI-compatible providers: the SDK's
max_retries=0and the factory's tenacity transport.
Acceptance criteria
- Given a recorded Models API reply that declares adaptive thinking and no sampling, the recorded
messagesrequest hasthinking.type == "adaptive", nobudget_tokens, and neithertemperaturenortop_p. The test fails on the current code. - Given a model that declares sampling support, streamed and unstreamed requests carry the same
temperatureandtop_p. - Provider
claudewith an emptyai.modelraisesConfigurationErrornamingai.model. - Recorded Anthropic SSE streams give the same text, thinking and finish reasons as today (feat(ai): finish reasons and stream completeness for model replies #599); the existing tests pass.
- The SDK client's HTTP client is the factory-built one (an identity check).
-
rg -n 'claude-3-|budget_tokens|anthropic-version' srcprints nothing. - Tests run offline, with fakes only at the HTTP edge (an httpx2
MockTransport, throughtests/llm_stream_fakes.route_clientor refactor(cli): Unify HTTP and DNS seams with shared fakes #1314's fixture) or the process edge. No test patches a devops_cli name. - Each new or changed test runs in under 1 s.
-
uv run devops cipasses. - (person-run)
devops ai chatwith providerclaudeand a current model returns a reply.
Related: #1001, #888, #1419, #591
Found by the 2026-10-08 client-library audit.
Opened as a borrow (#1153, budget/borrowed): the agent filing quota is spent for this cycle, and this is a defect or security finding of the owner-requested 2026-10-08 client-library audit.
Update 2026-10-08: remedy follows the owner's #1001 decision
#1001 now uses pydantic-ai models, not the anthropic SDK directly, so this item's remedy changes:
- The
claudeprovider is a pydantic-aiAnthropicModeloverAnthropicProvider, built withhttp_client=from the egress factory. It is called throughpydantic_ai.direct. - Thinking, effort and sampling come from pydantic-ai's Anthropic model settings and the model's profile or declared capability, never from its name.
- The acceptance criteria stand: no
budget_tokensand no sampling for a model that rejects them, and noclaude-3-checks left.
If #1001 lands first, this item is its Claude step. Otherwise it lands this provider as #1001's first step.
Metadata
Metadata
Assignees
Labels
scope/aiAI review pipeline, personas, prompts, LLM client, or RAGsource/agentFiled by an agenttype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The Claude provider is completely broken for all current models under default configuration, blocking any user relying on that provider.Restores a core provider that is currently unusable with any current Claude model.Replacing hand-written HTTP with the already-locked Anthropic SDK, updating thinking/sampling logic, adding the dependency declaration, and adjusting tests is well-scoped but touches multiple code paths.fix(ai): the claude provider sends what current Claude models accept,…