Skip to content

fix(magic-ai): omit temperature for Claude models that reject it - #728

Merged
navneetkumar-pim-webkul merged 2 commits into
3.xfrom
fix/magic-ai-claude-sampling
Sep 24, 2026
Merged

navneetkumar-pim-webkul merged 2 commits into
3.xfrom
fix/magic-ai-claude-sampling

Conversation

@navneetkumar-pim-webkul

Copy link
Copy Markdown
Collaborator

Issue Reference

N/A — found internally.

Description

Claude Opus/Sonnet 4.7 and later, including the Claude 5 family, return a 400 when a request carries temperature, so Magic AI content generation failed on every current Claude model.

  • LaravelAiAdapter::rejectsSamplingParameters() matches Claude model ids (bare, or prefixed like Bedrock/Vertex anthropic.claude-…). Claude 3.x, Haiku 4.x and Opus/Sonnet up to 4.6 (dated snapshots included) still receive the configured temperature; any other Claude model omits it, so the next release does not break generation again.
  • Only temperature is dropped. The 16000-token floor stays specific to the OpenAI reasoning models that need it; a Claude model keeps the configured max tokens.

How To Test This?

  1. Add an Anthropic platform with claude-opus-4-7 or claude-sonnet-5 and generate product content.
    • Before: the request fails with a 400 about temperature.
    • After: content is generated.
  2. vendor/bin/pest packages/Webkul/Admin/tests/Feature/MagicAi/ReasoningModelTemperatureTest.php: 7 of the new cases fail before the fix, all 17 pass after. The MagicAI and Admin MagicAi suites pass (491 tests).

Screenshots

N/A — no UI change.

Checklist

  • vendor/bin/pest passes locally
  • vendor/bin/pint --test reports no style issues
  • Tailwind classes are reordered — N/A
  • New user-facing strings use translation keys (all 33 locales) — N/A, no new strings
  • Target branch is 3.x, the current release line (master targets the next major)

Documentation

  • My pull request requires an update on the documentation repository.

Claude Opus/Sonnet 4.7 and later, including the Claude 5 family, return a
400 when a request carries temperature, so content generation failed on
every current Claude model. Claude 3.x, Haiku 4.x and Opus/Sonnet up to 4.6
still receive the configured temperature; any other Claude model omits it
so the next release does not break generation again.

Only the temperature is dropped: the 16000-token floor stays specific to
the OpenAI reasoning models that need it.
Copilot AI lite review requested due to automatic review settings September 24, 2026 16:18
@navneetkumar-pim-webkul navneetkumar-pim-webkul mentioned this pull request Sep 24, 2026
2 of 6 tasks

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 review overview

🟡 Changes recommended

Support Bedrock-style versioned Claude IDs and add prefixed-ID regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates Magic AI to omit temperature for newer Claude models while preserving token settings for compatible models.

Changes:

  • Adds Claude model compatibility detection.
  • Adds regression tests for temperature and token handling.
File Summary
packages/​Webkul/​MagicAI/​src/​Services/​LaravelAiAdapter.php Applies Claude-specific temperature handling.
packages/​Webkul/​Admin/​tests/​Feature/​MagicAi/​ReasoningModelTemperatureTest.php Tests Claude temperature and token behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/Webkul/MagicAI/src/Services/LaravelAiAdapter.php Outdated
A Bedrock id such as anthropic.claude-opus-4-6-v1:0 ends in a -vN:M suffix the allowlist did not accept, so a Claude 4.6 model on Bedrock lost its temperature. The suffix is now accepted after the optional snapshot date, and prefixed Bedrock and Vertex ids are covered on both sides of the cut-off.
@navneetkumar-pim-webkul
navneetkumar-pim-webkul merged commit b0b45e8 into 3.x Sep 24, 2026
23 checks passed
@navneetkumar-pim-webkul
navneetkumar-pim-webkul deleted the fix/magic-ai-claude-sampling branch September 24, 2026 16:42
navneetkumar-pim-webkul added a commit that referenced this pull request Sep 24, 2026
Six merged pull requests since v3.1.1 carried no changelog entry: the
gallery unsaved badge and worker timeout handler (#713), the import filter
re-render (#720), the worker timeout alarm (#722), the channel name on
PostgreSQL (#725), the price input height (#726), and the export view
events (#717, #718). The two fixes pending in #727 and #728 are included
so the cut merges after them.

The model recommendation entry described the cheap-tier ranking that #724
replaced with newest-per-family; it now describes the shipped behaviour.

3.1.2 is a patch release, so everything is filed under bug fixes and
improvements; no feature section. Core::VERSION, package.json and the
UPGRADE.md walkthrough move to 3.1.2 together, as they did for 3.1.1.
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.

2 participants