Repository navigation
Description
Problem Description
The Claude client sends temperature and top_p in extra_body (src/devops_cli/ai/client/claude.py:143-156). Anthropic SDK 2.0.0 sends anthropic-version: 2026-10-21 (src/anthropic/_constants.py), and under that API version temperature, top_p and top_k return HTTP 400. So the move to SDK 2 breaks every Claude call at run time. No test catches it, because the tests mock the client and the parameters go in extra_body, outside the types.
pyproject.toml pins anthropic; the baseline (#5065) moves it to 1.17.0, the newest 1.x. The newest is 2.8.0, and Renovate (#4893) will offer it.
Other SDK 2 changes (migration guide https://platform.claude.com/docs/en/api/migration-2026-10-21):
- API keys go out as
Authorization: Bearerin place ofX-Api-Key.claude.py:298-315buildsanthropic.Anthropicwithapi_keyandbase_url; check the LiteLLM gateway route that the client can use. MessageParambecomes a union ofUserMessageParam,AssistantMessageParamandSystemMessageParam;Message.to_paramreturnsAssistantMessageParam;betasis removed frommodels.retrieveandmodels.list.fastmcp-slim[anthropic]capsanthropic<2(the project does not use that extra). pydantic-ai-slim needsanthropic>=1.15.0(2.68) with no cap; check pydantic-aiAnthropicModelon SDK 2.
Research of 2026-11-12 (research-python, migration anthropic).
Reproduction Steps
- Set
anthropic==2.8.0inpyproject.tomland runuv lock. - Run the full test suite: no test fails (the client is mocked).
- Make one real Claude call with the client (direct or through the gateway): the API answers HTTP 400 for
temperatureortop_p.
Expected vs Actual Behavior
Expected: a test at the HTTP seam fails while the client sends a parameter that the pinned API version refuses, and the client sends only accepted parameters.
Actual: the client sends temperature and top_p in extra_body, and only a live call shows the HTTP 400.
Environment Diagnostics
devops-cli main at the merge of #5065; anthropic 1.17.0 locked, 2.8.0 newest; Python 3.14.
Logs, Traces, or Terminal Output
Research run of 2026-11-12: with anthropic 2.8.0, the suite passed; the risk is at run time.
Source: #4893
Alternatives check of 2026-11-15: none.
Tool: none found.
Proposed design
Problem statement
The Claude client puts temperature and top_p in extra_body. Anthropic SDK 2 sends API version 2026-10-21, which returns HTTP 400 for temperature, top_p and top_k. The tests mock the client, so they do not see the request body and do not catch the failure. This change makes the Claude client omit the refused sampling parameters on SDK 2. It adds an HTTP-seam test that fails if a refused parameter is sent.
Acceptance criteria
Requirement: SDK 2 omits refused sampling parameters
The Claude client SHALL omit temperature, top_p and top_k from the Anthropic request body when the installed SDK major version is 2 or later.
Scenario: SDK 2 request body
- WHEN A test forces the Anthropic SDK 2 path, configures sampling, and captures the request body at the HTTP seam.
- THEN The captured JSON body has no
temperature,top_portop_kfield.
Requirement: HTTP seam rejects refused sampling parameters
The Claude client MUST pass the HTTP-seam test that returns HTTP 400 when the request body holds temperature, top_p or top_k.
Scenario: Refused parameter guard
- WHEN A test forces the Anthropic SDK 2 path and uses a fake HTTP transport that returns HTTP 400 for
temperature,top_portop_k. - THEN The Claude call succeeds and the captured request body has none of those fields.
Requirement: SDK 1 sampling behavior stays
The Claude client SHALL keep sending temperature and top_p when the installed SDK major version is 1.
Scenario: SDK 1 request body
- WHEN A test uses Anthropic SDK 1.17 and configures
temperatureandtop_p. - THEN The captured request body has the configured
temperatureandtop_pvalues.
Existing Tool Considered
No open, maintained tool or library covers the need. The alternatives check considered anthropic, pydantic-ai, LiteLLM and anthropic-sdk-python. The SDK causes the HTTP 400. The gateway and pydantic-ai sit above the API. None strips the client's extra_body or adds the HTTP-seam test. The fix stays in src/devops_cli/ai/client/claude.py and its tests.
Key questions
- Where does the Claude client send the sampling parameters?: The client puts
temperatureandtop_pinextra_bodyinsrc/devops_cli/ai/client/claude.py:143-156. [sources: src/devops_cli/ai/client/claude.py:143-156] - How should the Claude client stop sending refused sampling parameters?: Gate on the installed Anthropic SDK major version. Use
importlib.metadata.version("anthropic")and setsend_samplingto false when the major is 2 or later. Keep the SDK 1.x path. (best practice) [sources: src/devops_cli/ai/client/claude.py:143-156, pyproject.toml]- Chosen: Gate on the Anthropic SDK major version. SDK 2 sends the API version that refuses the fields, and SDK 1.17 keeps the current behavior.
- Rejected: Remove sampling parameters for all SDK versions. This drops a working setting for the pinned SDK 1.17 and changes more than the issue asks.
- Rejected: Keep
extra_bodyand rely on the API error. This breaks every Claude call on SDK 2 at run time.
- What test proves the fix at the HTTP seam?: Add an offline test with a fake HTTP transport that returns HTTP 400 when
temperature,top_portop_kis present. Force the SDK 2 path and assert the call succeeds with none of those fields. (best practice) [sources: src/devops_cli/ai/client/claude.py:143-156, pyproject.toml]- Chosen: Fake HTTP transport at the SDK seam. It sees the actual request body that
extra_bodybuilds and can return HTTP 400. - Rejected: Mock the client. It hides the request body and cannot catch the HTTP 400.
- Rejected: Live API call. It needs a secret and network, so it is not an offline test.
- Chosen: Fake HTTP transport at the SDK seam. It sees the actual request body that
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Both deal with sampling parameters in the AI client, but #2559 fixes the unified client not forwarding parameters, while this candidate stops the Claude client from sending parameters that SDK 2 rejects.build(deps): take every safe version update before Renovate (#5102)
devops-cli-service commentedon Nov 15, 2026
Alternatives check: none
Reason: The searches turned up the Anthropic Python SDK 2.8.0 itself — the component whose new API version returns HTTP 400 for temperature/top_p/top_k — plus the LiteLLM gateway and pydantic-ai, which sit in front of or above the same Anthropic API rather than fixing what the project's own Claude client puts in
extra_body. No open tool removes those parameters from the client's request or adds the HTTP-seam test the issue asks for, so the fix stays inclaude.pyand its tests.Tool: none found
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at b8c7632 (see proposed design in issue body).
devops-cli-service commentedon Nov 17, 2026
Released in v0.173.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.173.2
devops-cli-service commentedon Nov 17, 2026
Live since 2026-11-17 16:55 UTC