Skip to content

fix(ai): the claude provider sends what current Claude models accept, built by the anthropic SDK #1428

Closed

Description

@dan-petty

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), and DEFAULT_ANTHROPIC_MODEL is claude-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-7 or 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 through output_config.effort). budget_tokens is 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 temperature and top_p (:62-68) from ai.temperature and ai.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 unstreamed claude request to a current model fails.
  • Streamed and unstreamed requests differ. The streamed request sends temperature but not top_p (:159-162).
  • The rest is hand-written too: the pinned anthropic-version: 2023-06-01 header (:41, :138), the content-block parse (:80-117), the SSE event decoding (ai/client/streaming.py:307-347) and the error mapping.
  • The anthropic SDK (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-checked httpx2.Client as http_client.

Proposed remedy

  • ClaudeProviderMixin holds one anthropic.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 calls messages.create and messages.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_effort as output_config.effort. temperature and top_p are sent only where the model accepts them, in streamed and unstreamed calls alike.
  • An empty ai.model for provider claude raises ConfigurationError naming ai.model. DEFAULT_ANTHROPIC_MODEL and the claude-3-* checks are deleted.
  • _CLAUDE_EVENT_FRAMES and _claude_stream_frame are deleted; stop reasons still map through CONST_ANTHROPIC_STOP_REASONS.
  • Declare anthropic in pyproject.toml.

Key questions

Acceptance criteria

  • Given a recorded Models API reply that declares adaptive thinking and no sampling, the recorded messages request has thinking.type == "adaptive", no budget_tokens, and neither temperature nor top_p. The test fails on the current code.
  • Given a model that declares sampling support, streamed and unstreamed requests carry the same temperature and top_p.
  • Provider claude with an empty ai.model raises ConfigurationError naming ai.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' src prints nothing.
  • Tests run offline, with fakes only at the HTTP edge (an httpx2 MockTransport, through tests/llm_stream_fakes.route_client or 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 ci passes.
  • (person-run) devops ai chat with provider claude and 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 claude provider is a pydantic-ai AnthropicModel over AnthropicProvider, built with http_client= from the egress factory. It is called through pydantic_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_tokens and no sampling for a model that rejects them, and no claude-3- checks left.

If #1001 lands first, this item is its Claude step. Otherwise it lands this provider as #1001's first step.

Activity

  1. added
    type/bug
    scope/ai
    source/agent
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    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.

    • Priority: P1-High. The Claude provider is completely broken for all current models under default configuration, blocking any user relying on that provider.
    • Value: High. Restores a core provider that is currently unusable with any current Claude model.
    • Effort: Medium. 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.
  3. added a commit that references this issue on Oct 26, 2026
    59471a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope/aisource/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions