Skip to content

Send AI temperature only to models that accept it - #477

Open
mainalisandeep062 wants to merge 1 commit into
trypostit:mainfrom
yoddha-social:fix/omit-unsupported-temperature
Open

mainalisandeep062 wants to merge 1 commit into
trypostit:mainfrom
yoddha-social:fix/omit-unsupported-temperature

Conversation

@mainalisandeep062

Copy link
Copy Markdown
Contributor

Closes #476.

Why

Anthropic's Claude 5 models reject the temperature parameter ("temperature is deprecated for this model"). All four agents set one with #[Temperature], so with a Claude 5 model every AI feature fails and the composer only shows "Could not generate a suggestion". Details and the API response are in #476.

What

  • App\Ai\Concerns\OmitsUnsupportedTemperature replaces the #[Temperature] attribute. Each agent keeps its value (IdeaGenerator 0.8, PostWritingAssistant 0.7, PostContentShortener and MediaAltTextGenerator 0.2) in preferredTemperature() and sends it unless the active text model rejects temperatures.
  • The attribute has to go rather than sit next to a method: laravel/ai's TextGenerationOptions::resolve() falls back to the attribute when temperature() returns null.
  • Models without temperature are a list of patterns in config('trypost.ai.models_without_temperature'). The default only matches the Claude 5 family (claude-sonnet-5-5, claude-opus-5-5-20261001, ...), so Claude 4.x (claude-sonnet-4-5, dated or not) and other providers keep sending their temperature.

Tests

tests/Unit/Ai/Agents/TemperatureTest.php, over every agent in app/Ai/Agents like AgentProviderResolutionTest:

  • no agent uses the #[Temperature] attribute;
  • the model patterns: Claude 5 rejects, Claude 4.5 (plain and dated) and OpenAI accept;
  • TextGenerationOptions::forAgent() carries the agent's temperature for claude-sonnet-4-5 and none for claude-sonnet-5-5.

Anthropic's Claude 5 models reject the temperature parameter with
"`temperature` is deprecated for this model". All four agents set one with
#[Temperature], so with AI_TEXT_PROVIDER=anthropic and a Claude 5 model
every AI feature fails and the composer only shows "Could not generate a
suggestion".

OmitsUnsupportedTemperature replaces the attribute: each agent keeps its
value and sends it unless the active text model is listed in
trypost.ai.models_without_temperature (the Claude 5 family by default).
The attribute has to go because laravel/ai falls back to it when
temperature() returns null.
Copilot AI balanced review requested due to automatic review settings November 4, 2026 10:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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.

AI features fail with Claude 5 models: temperature is deprecated for this model

2 participants