Skip to content

Commit ae3e0f8

Browse files
fix(playground-ui): remove default temperature and topP from studio agent settings (#12256)
## Summary - Remove hardcoded `temperature: 0.5` and `topP: 1` defaults from playground agent settings - Let agent config and provider defaults handle these values instead ## Problem Studio was applying its own defaults for temperature and topP, which broke Claude Opus/Sonnet models that don't allow both to be specified simultaneously. The previous fix attempted to detect Claude 4.5+ models and reactively clear topP, but this was racy - the API request would fire before the `useEffect` ran. ## Solution The cleaner fix is to not set playground defaults at all. If neither the agent nor the user explicitly sets temperature/topP, the playground just doesn't send them, letting the provider use its own defaults. ## Test plan - [x] Tested with `examples/agent-v6` using Claude Opus 4.5 - no longer errors - [x] Unit tests updated and passing <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Agent settings no longer include hardcoded temperature and topP defaults; these now defer to agent configuration and provider defaults. * **Tests** * Unit tests updated to expect temperature and topP to be undefined by default. * **Chores** * Changeset added documenting the behavioral change and patch release. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: CalebBarnes <CalebBarnes@users.noreply.github.com> Co-authored-by: Marvin Frachet <marvin@mastra.ai>
1 parent d904fa1 commit ae3e0f8

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

.changeset/smooth-bananas-give.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@mastra/playground-ui': patch
3+
---
4+
5+
Remove hardcoded temperature: 0.5 and topP: 1 defaults from playground agent settings
6+
Let agent config and provider defaults handle these values instead

packages/playground-ui/src/domains/agents/hooks/__tests__/use-agent-settings-state.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,24 @@ import { isAnthropicModelWithSamplingRestriction } from '../../utils/model-restr
2424
/**
2525
* Test file for use-agent-settings-state.ts
2626
*
27-
* Issue #11760: Anthropic Claude 4.5+ models fail when both temperature and topP are sent.
28-
* Anthropic's API returns: "`temperature` and `top_p` cannot both be specified for this model."
29-
*
30-
* Default settings include both temperature and topP for models that support both (OpenAI, Google, Claude 3.5).
31-
* For Claude 4.5+ models, the AgentSettings component auto-clears topP when the model is detected.
27+
* Default settings should NOT include temperature or topP - these should be
28+
* left undefined so models use their provider defaults unless explicitly set.
3229
*/
3330
describe('use-agent-settings-state defaults', () => {
3431
beforeEach(() => {
3532
localStorageMock.clear();
3633
vi.clearAllMocks();
3734
});
3835

39-
it('should have both temperature and topP set by default (for models that support both)', async () => {
36+
it('should not have temperature or topP set by default (use model provider defaults)', async () => {
4037
const { defaultSettings } = await import('../use-agent-settings-state');
4138

4239
const modelSettings = defaultSettings.modelSettings;
4340

44-
// Defaults should include both values for models that support them
45-
// (OpenAI, Google, Claude 3.5, etc.)
46-
// Claude 4.5+ models will have topP auto-cleared at the component level
47-
expect(modelSettings.temperature).toBe(0.5);
48-
expect(modelSettings.topP).toBe(1);
41+
// temperature and topP should be undefined to use model provider defaults
42+
// This also avoids Claude 4.5+ errors where both cannot be specified
43+
expect(modelSettings.temperature).toBeUndefined();
44+
expect(modelSettings.topP).toBeUndefined();
4945
});
5046
});
5147

packages/playground-ui/src/domains/agents/hooks/use-agent-settings-state.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export const defaultSettings: AgentSettings = {
1010
modelSettings: {
1111
maxRetries: 2,
1212
maxSteps: 5,
13-
temperature: 0.5,
14-
topP: 1,
1513
chatWithGenerateLegacy: false,
1614
chatWithGenerate: false,
1715
},

0 commit comments

Comments
 (0)