Skip to content

Commit ff43528

Browse files
authored
fix(gpt-5): fixed verbosity and reasoning params (#1069)
* fix(gpt-5): fixed verbosity and reasoning parsm * fixed dropdown * default values for verbosity and reasoning effort * cleanup * use default value in dropdown
1 parent 692ba69 commit ff43528

File tree

11 files changed

+118
-38
lines changed

11 files changed

+118
-38
lines changed

apps/sim/app/api/providers/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export async function POST(request: NextRequest) {
3939
stream,
4040
messages,
4141
environmentVariables,
42+
reasoningEffort,
43+
verbosity,
4244
} = body
4345

4446
logger.info(`[${requestId}] Provider request details`, {
@@ -58,6 +60,8 @@ export async function POST(request: NextRequest) {
5860
messageCount: messages?.length || 0,
5961
hasEnvironmentVariables:
6062
!!environmentVariables && Object.keys(environmentVariables).length > 0,
63+
reasoningEffort,
64+
verbosity,
6165
})
6266

6367
let finalApiKey: string
@@ -99,6 +103,8 @@ export async function POST(request: NextRequest) {
99103
stream,
100104
messages,
101105
environmentVariables,
106+
reasoningEffort,
107+
verbosity,
102108
})
103109

104110
const executionTime = Date.now() - startTime

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/dropdown.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface DropdownProps {
2222
previewValue?: string | null
2323
disabled?: boolean
2424
placeholder?: string
25+
config?: import('@/blocks/types').SubBlockConfig
2526
}
2627

2728
export function Dropdown({
@@ -34,6 +35,7 @@ export function Dropdown({
3435
previewValue,
3536
disabled,
3637
placeholder = 'Select an option...',
38+
config,
3739
}: DropdownProps) {
3840
const [storeValue, setStoreValue] = useSubBlockValue<string>(blockId, subBlockId)
3941
const [storeInitialized, setStoreInitialized] = useState(false)
@@ -281,7 +283,7 @@ export function Dropdown({
281283

282284
{/* Dropdown */}
283285
{open && (
284-
<div className='absolute top-full left-0 z-[100] mt-1 w-full min-w-[286px]'>
286+
<div className='absolute top-full left-0 z-[100] mt-1 w-full'>
285287
<div className='allow-scroll fade-in-0 zoom-in-95 animate-in rounded-md border bg-popover text-popover-foreground shadow-lg'>
286288
<div
287289
ref={dropdownRef}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/sub-block.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,12 @@ export function SubBlock({
126126
blockId={blockId}
127127
subBlockId={config.id}
128128
options={config.options as { label: string; id: string }[]}
129+
defaultValue={typeof config.value === 'function' ? config.value({}) : config.value}
130+
placeholder={config.placeholder}
129131
isPreview={isPreview}
130132
previewValue={previewValue}
131133
disabled={isDisabled}
134+
config={config}
132135
/>
133136
</div>
134137
)
@@ -139,6 +142,7 @@ export function SubBlock({
139142
blockId={blockId}
140143
subBlockId={config.id}
141144
options={config.options as { label: string; id: string }[]}
145+
defaultValue={typeof config.value === 'function' ? config.value({}) : config.value}
142146
placeholder={config.placeholder}
143147
isPreview={isPreview}
144148
previewValue={previewValue}

apps/sim/blocks/blocks/agent.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,16 @@ Create a system prompt appropriately detailed for the request, using clear langu
215215
{
216216
id: 'reasoningEffort',
217217
title: 'Reasoning Effort',
218-
type: 'combobox',
218+
type: 'dropdown',
219219
layout: 'half',
220220
placeholder: 'Select reasoning effort...',
221-
options: () => {
222-
return [
223-
{ label: 'low', id: 'low' },
224-
{ label: 'medium', id: 'medium' },
225-
{ label: 'high', id: 'high' },
226-
]
227-
},
221+
options: [
222+
{ label: 'minimal', id: 'minimal' },
223+
{ label: 'low', id: 'low' },
224+
{ label: 'medium', id: 'medium' },
225+
{ label: 'high', id: 'high' },
226+
],
227+
value: () => 'medium',
228228
condition: {
229229
field: 'model',
230230
value: MODELS_WITH_REASONING_EFFORT,
@@ -233,10 +233,15 @@ Create a system prompt appropriately detailed for the request, using clear langu
233233
{
234234
id: 'verbosity',
235235
title: 'Verbosity',
236-
type: 'slider',
236+
type: 'dropdown',
237237
layout: 'half',
238-
min: 0,
239-
max: 2,
238+
placeholder: 'Select verbosity...',
239+
options: [
240+
{ label: 'low', id: 'low' },
241+
{ label: 'medium', id: 'medium' },
242+
{ label: 'high', id: 'high' },
243+
],
244+
value: () => 'medium',
240245
condition: {
241246
field: 'model',
242247
value: MODELS_WITH_VERBOSITY,
@@ -518,7 +523,7 @@ Example 3 (Array Input):
518523
},
519524
temperature: { type: 'number', description: 'Response randomness level' },
520525
reasoningEffort: { type: 'string', description: 'Reasoning effort level for GPT-5 models' },
521-
verbosity: { type: 'number', description: 'Verbosity level for GPT-5 models' },
526+
verbosity: { type: 'string', description: 'Verbosity level for GPT-5 models' },
522527
tools: { type: 'json', description: 'Available tools configuration' },
523528
},
524529
outputs: {

apps/sim/executor/handlers/agent/agent-handler.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,5 +1326,59 @@ describe('AgentBlockHandler', () => {
13261326
expect(requestBody.model).toBe('azure/gpt-4o')
13271327
expect(requestBody.apiKey).toBe('test-azure-api-key')
13281328
})
1329+
1330+
it('should pass GPT-5 specific parameters (reasoningEffort and verbosity) through the request pipeline', async () => {
1331+
const inputs = {
1332+
model: 'gpt-5',
1333+
systemPrompt: 'You are a helpful assistant.',
1334+
userPrompt: 'Hello!',
1335+
apiKey: 'test-api-key',
1336+
reasoningEffort: 'minimal',
1337+
verbosity: 'high',
1338+
temperature: 0.7,
1339+
}
1340+
1341+
mockGetProviderFromModel.mockReturnValue('openai')
1342+
1343+
await handler.execute(mockBlock, inputs, mockContext)
1344+
1345+
expect(mockFetch).toHaveBeenCalledWith(expect.any(String), expect.any(Object))
1346+
1347+
const fetchCall = mockFetch.mock.calls[0]
1348+
const requestBody = JSON.parse(fetchCall[1].body)
1349+
1350+
// Check that GPT-5 parameters are included in the request
1351+
expect(requestBody.reasoningEffort).toBe('minimal')
1352+
expect(requestBody.verbosity).toBe('high')
1353+
expect(requestBody.provider).toBe('openai')
1354+
expect(requestBody.model).toBe('gpt-5')
1355+
expect(requestBody.apiKey).toBe('test-api-key')
1356+
})
1357+
1358+
it('should handle missing GPT-5 parameters gracefully', async () => {
1359+
const inputs = {
1360+
model: 'gpt-5',
1361+
systemPrompt: 'You are a helpful assistant.',
1362+
userPrompt: 'Hello!',
1363+
apiKey: 'test-api-key',
1364+
temperature: 0.7,
1365+
// No reasoningEffort or verbosity provided
1366+
}
1367+
1368+
mockGetProviderFromModel.mockReturnValue('openai')
1369+
1370+
await handler.execute(mockBlock, inputs, mockContext)
1371+
1372+
expect(mockFetch).toHaveBeenCalledWith(expect.any(String), expect.any(Object))
1373+
1374+
const fetchCall = mockFetch.mock.calls[0]
1375+
const requestBody = JSON.parse(fetchCall[1].body)
1376+
1377+
// Check that GPT-5 parameters are undefined when not provided
1378+
expect(requestBody.reasoningEffort).toBeUndefined()
1379+
expect(requestBody.verbosity).toBeUndefined()
1380+
expect(requestBody.provider).toBe('openai')
1381+
expect(requestBody.model).toBe('gpt-5')
1382+
})
13291383
})
13301384
})

apps/sim/executor/handlers/agent/agent-handler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ export class AgentBlockHandler implements BlockHandler {
368368
stream: streaming,
369369
messages,
370370
environmentVariables: context.environmentVariables || {},
371+
reasoningEffort: inputs.reasoningEffort,
372+
verbosity: inputs.verbosity,
371373
}
372374
}
373375

apps/sim/executor/handlers/agent/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface AgentInputs {
1010
apiKey?: string
1111
azureEndpoint?: string
1212
azureApiVersion?: string
13+
reasoningEffort?: string
14+
verbosity?: string
1315
}
1416

1517
export interface ToolInput {

apps/sim/providers/azure-openai/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ export const azureOpenAIProvider: ProviderConfig = {
145145
if (request.maxTokens !== undefined) payload.max_tokens = request.maxTokens
146146

147147
// Add GPT-5 specific parameters
148-
if (request.reasoningEffort !== undefined) payload.reasoning_effort = request.reasoningEffort
148+
if (request.reasoningEffort !== undefined) {
149+
payload.reasoning = {
150+
effort: request.reasoningEffort,
151+
}
152+
}
149153
if (request.verbosity !== undefined) payload.verbosity = request.verbosity
150154

151155
// Add response format for structured output if specified

apps/sim/providers/models.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ export interface ModelCapabilities {
3535
toolUsageControl?: boolean
3636
computerUse?: boolean
3737
reasoningEffort?: {
38-
min: string
39-
max: string
4038
values: string[]
4139
}
4240
verbosity?: {
43-
min: number
44-
max: number
41+
values: string[]
4542
}
4643
}
4744

@@ -97,11 +94,11 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
9794
capabilities: {
9895
toolUsageControl: true,
9996
reasoningEffort: {
100-
min: 'low',
101-
max: 'high',
97+
values: ['minimal', 'low', 'medium', 'high'],
98+
},
99+
verbosity: {
102100
values: ['low', 'medium', 'high'],
103101
},
104-
verbosity: { min: 0, max: 2 },
105102
},
106103
},
107104
{
@@ -115,11 +112,11 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
115112
capabilities: {
116113
toolUsageControl: true,
117114
reasoningEffort: {
118-
min: 'low',
119-
max: 'high',
115+
values: ['minimal', 'low', 'medium', 'high'],
116+
},
117+
verbosity: {
120118
values: ['low', 'medium', 'high'],
121119
},
122-
verbosity: { min: 0, max: 2 },
123120
},
124121
},
125122
{
@@ -133,11 +130,11 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
133130
capabilities: {
134131
toolUsageControl: true,
135132
reasoningEffort: {
136-
min: 'low',
137-
max: 'high',
133+
values: ['minimal', 'low', 'medium', 'high'],
134+
},
135+
verbosity: {
138136
values: ['low', 'medium', 'high'],
139137
},
140-
verbosity: { min: 0, max: 2 },
141138
},
142139
},
143140
{
@@ -261,11 +258,11 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
261258
capabilities: {
262259
toolUsageControl: true,
263260
reasoningEffort: {
264-
min: 'low',
265-
max: 'high',
261+
values: ['minimal', 'low', 'medium', 'high'],
262+
},
263+
verbosity: {
266264
values: ['low', 'medium', 'high'],
267265
},
268-
verbosity: { min: 0, max: 2 },
269266
},
270267
},
271268
{
@@ -279,11 +276,11 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
279276
capabilities: {
280277
toolUsageControl: true,
281278
reasoningEffort: {
282-
min: 'low',
283-
max: 'high',
279+
values: ['minimal', 'low', 'medium', 'high'],
280+
},
281+
verbosity: {
284282
values: ['low', 'medium', 'high'],
285283
},
286-
verbosity: { min: 0, max: 2 },
287284
},
288285
},
289286
{
@@ -297,11 +294,11 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
297294
capabilities: {
298295
toolUsageControl: true,
299296
reasoningEffort: {
300-
min: 'low',
301-
max: 'high',
297+
values: ['minimal', 'low', 'medium', 'high'],
298+
},
299+
verbosity: {
302300
values: ['low', 'medium', 'high'],
303301
},
304-
verbosity: { min: 0, max: 2 },
305302
},
306303
},
307304
{

apps/sim/providers/openai/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ export const openaiProvider: ProviderConfig = {
131131
if (request.maxTokens !== undefined) payload.max_tokens = request.maxTokens
132132

133133
// Add GPT-5 specific parameters
134-
if (request.reasoningEffort !== undefined) payload.reasoning_effort = request.reasoningEffort
134+
if (request.reasoningEffort !== undefined) {
135+
payload.reasoning = {
136+
effort: request.reasoningEffort,
137+
}
138+
}
135139
if (request.verbosity !== undefined) payload.verbosity = request.verbosity
136140

137141
// Add response format for structured output if specified

0 commit comments

Comments
 (0)