Skip to content

temperature sent unconditionally on the OpenAI-compatible path to Anthropic (native-path fix at v0.1.14 doesn't cover it) #1223

Description

@turtle696966969696

Summary

Next-generation Claude models (claude-opus-4-8, claude-sonnet-5, and per the code comment also claude-opus-5agent/src/providers/llm.py:808-809) reject requests carrying temperature with HTTP 400. As of v0.1.14 this is fixed for the native Anthropic Messages API path (provider == "anthropic", llm.py:1366) — the string-matching detector at llm.py:827-834 catches the error, strips temperature, retries, and remembers the outcome per model.

I ran into this on a different, unsupported-but-functional configuration: LANGCHAIN_PROVIDER=openai with OPENAI_BASE_URL pointed at https://api.anthropic.com/v1/, using Anthropic's own OpenAI-compatible endpoint rather than the native Messages API. I want to flag up front that this isn't the documented way to reach Anthropic — the README lists the native Messages API as the supported provider (README.md:742), and .env.example:26-30 documents ANTHROPIC_BASE_URL under a dedicated "Anthropic Messages API / compatible proxy" section as the intended route, including for compatible proxies. I got here because Anthropic's compat endpoint happens to work for everything else through the generic OpenAI branch, which makes the failure easy to mistake for a bug in a supported setup rather than the edge of an unsupported one.

On that branch, the generic ChatOpenAI kwargs dict sends temperature unconditionally:

kwargs: dict[str, Any] = {
    "model": name,
    ...
    "temperature": temperature,      # agent/src/providers/llm.py:1418 — unconditional, unchanged at v0.1.14

temperature always carries a value — agent/src/config/env_schema.py:141 declares it as a plain float with default=0.0, not Optional[float].

Live response, verbatim:

{"error": {"code": "invalid_request_error",
           "message": "`temperature` is deprecated for this model.",
           "type": "invalid_request_error",
           "param": null}}

Same param: null, same shape the native-path detector already handles by string-matching on message prose.

Given this isn't a supported configuration, I'm not sure whether the right fix is extending detection to the generic branch (the logic already exists two branches away and the error shape is identical) or just a docs note warning this specific combination isn't covered — happy to open a PR for whichever direction maintainers would rather have.

Side note for anyone on the native path: ANTHROPIC_API_KEY is read via a bare os.getenv call (llm.py:1037), not declared in env_schema.py — a missing/mistyped value won't be caught by provider doctor or preflight, only at first call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions