Skip to content

Agno: send Claude a temperature without a top_p - #1776

Merged
davidmckayv merged 1 commit into
mainfrom
fix/agno-claude-sampling
Nov 17, 2026
Merged

davidmckayv merged 1 commit into
mainfrom
fix/agno-claude-sampling

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

What and why

The Agno Bot failed every run on five Claude models the picker lists: Claude Haiku 4.5, Opus 4.5, Opus 4.6, Sonnet 4.5 and Sonnet 4.6. Anthropic answered 400: temperature and top_p cannot both be specified for this model, which the model compatibility check (#1775) found.

Agno's LiteLLM model sends temperature=0.7 and top_p=1.0 on every request. These Claude models take one of the two, never both. LiteLLM passes both through, because its model map only says whether a model takes sampling parameters at all (supports_sampling_params), not that it takes just one, so drop_params doesn't help here.

On Anthropic, the Agno Bot now leaves top_p out and keeps the temperature. A top_p of 1.0 keeps every token, which is what Anthropic's API does when none is sent, so the Bot samples exactly as it did before. Claude models that take no sampling parameters at all (Opus 4.7 and later) still lose the temperature through drop_params, as before. OpenAI and OpenAI-compatible endpoints are sent what they were sent before. The AG-UI side is unchanged.

The rule follows the provider's API, not a list of model names, so a new Claude model needs no change here.

Upgrading doesn't fix it: Agno 3.2.1, the latest release and what the image already installs, still defaults to temperature=0.7 and top_p=1.0 and sends both. Agno's own LiteLLM example sets top_p=None for Claude for this reason.

Sources

Tests

The test's Anthropic stand-in now refuses a request that names both, word for word as Anthropic does for these models. A new test runs an AG-UI run on each of the five models and checks the request carries the temperature and no top_p.

python -m pytest agent-agno/tests -q:

  • Before the fix: 6 failed, 24 passed (the five new cases, and the existing Anthropic-key run on claude-sonnet-4-5).
  • After the fix: 30 passed.

The probe, against the real API

scripts/model-compat.ts from #1775, run as --harness agent-agno --provider anthropic on a throwaway Linux box with the dev Anthropic key, one AG-UI run per model the picker lists, each carrying one tool. Before is the published image (latest) and the image built from main at c6c94e1. After is the image built from this branch at 28ea243.

Model Before, latest Before, main After, this branch
claude-fable-5-2 pass pass pass
claude-fable-5-1 pass pass pass
claude-fable-5 pass pass pass
claude-opus-5-5 pass pass pass
claude-opus-5 pass pass pass
claude-opus-4-8 pass pass pass
claude-opus-4-7 pass pass pass
claude-opus-4-6 fail fail pass
claude-opus-4-5-20251101 fail fail pass
claude-sonnet-5-5 pass pass pass
claude-sonnet-5 pass pass pass
claude-sonnet-4-6 fail fail pass
claude-sonnet-4-5-20250929 fail fail pass
claude-haiku-5-5 pass pass pass
claude-haiku-4-5-20251001 fail fail pass
Total 10 pass, 5 fail 10 pass, 5 fail 15 pass

Every failure was Anthropic's 400 invalid_request_error: "temperature and top_p cannot both be specified for this model." Every pass replied OK.

Agno sends temperature 0.7 and top_p 1.0 on every request, and Claude Haiku 4.5, Opus 4.5, Opus 4.6, Sonnet 4.5 and Sonnet 4.6 refuse a request that names both. On Anthropic the Agno Bot now leaves top_p out: 1.0 keeps every token, which is what the API does without one, so the temperature it has always run at is unchanged. Other providers are sent what they were before. The test's Anthropic stand-in now refuses both, as the real API does for these models.
@davidmckayv
davidmckayv merged commit a8c9259 into main Nov 17, 2026
16 checks passed
@davidmckayv
davidmckayv deleted the fix/agno-claude-sampling branch November 17, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant