Skip to content

Commit 99ae543

Browse files
authored
feat(models): updated model configs, updated anthropic provider to propagate errors back to user if any (#3159)
* feat(models): updated model configs, updated anthropic provider to propagate errors back to user if any * moved max tokens to advanced * updated model configs and testesd * removed default in max config for output tokens * moved more stuff to advanced mode in the agent block * stronger typing * move api key under model, update mistral and groq * update openrouter, fixed serializer to allow ollama/vllm models without api key * removed ollama handling
1 parent 925f06a commit 99ae543

File tree

17 files changed

+766
-520
lines changed

17 files changed

+766
-520
lines changed

apps/sim/app/workspace/[workspaceId]/logs/components/logs-toolbar/components/notifications/components/workflow-selector/workflow-selector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function WorkflowSelector({
8989
onMouseDown={(e) => handleRemove(e, w.id)}
9090
>
9191
{w.name}
92-
<X className='h-3 w-3' />
92+
<X className='!text-[var(--text-primary)] h-4 w-4 flex-shrink-0 opacity-50' />
9393
</Badge>
9494
))}
9595
{selectedWorkflows.length > 2 && (

apps/sim/blocks/blocks/agent.ts

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Return ONLY the JSON array.`,
154154
type: 'dropdown',
155155
placeholder: 'Select reasoning effort...',
156156
options: [
157+
{ label: 'auto', id: 'auto' },
157158
{ label: 'low', id: 'low' },
158159
{ label: 'medium', id: 'medium' },
159160
{ label: 'high', id: 'high' },
@@ -163,9 +164,12 @@ Return ONLY the JSON array.`,
163164
const { useSubBlockStore } = await import('@/stores/workflows/subblock/store')
164165
const { useWorkflowRegistry } = await import('@/stores/workflows/registry/store')
165166

167+
const autoOption = { label: 'auto', id: 'auto' }
168+
166169
const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
167170
if (!activeWorkflowId) {
168171
return [
172+
autoOption,
169173
{ label: 'low', id: 'low' },
170174
{ label: 'medium', id: 'medium' },
171175
{ label: 'high', id: 'high' },
@@ -178,6 +182,7 @@ Return ONLY the JSON array.`,
178182

179183
if (!modelValue) {
180184
return [
185+
autoOption,
181186
{ label: 'low', id: 'low' },
182187
{ label: 'medium', id: 'medium' },
183188
{ label: 'high', id: 'high' },
@@ -187,15 +192,16 @@ Return ONLY the JSON array.`,
187192
const validOptions = getReasoningEffortValuesForModel(modelValue)
188193
if (!validOptions) {
189194
return [
195+
autoOption,
190196
{ label: 'low', id: 'low' },
191197
{ label: 'medium', id: 'medium' },
192198
{ label: 'high', id: 'high' },
193199
]
194200
}
195201

196-
return validOptions.map((opt) => ({ label: opt, id: opt }))
202+
return [autoOption, ...validOptions.map((opt) => ({ label: opt, id: opt }))]
197203
},
198-
value: () => 'medium',
204+
mode: 'advanced',
199205
condition: {
200206
field: 'model',
201207
value: MODELS_WITH_REASONING_EFFORT,
@@ -207,6 +213,7 @@ Return ONLY the JSON array.`,
207213
type: 'dropdown',
208214
placeholder: 'Select verbosity...',
209215
options: [
216+
{ label: 'auto', id: 'auto' },
210217
{ label: 'low', id: 'low' },
211218
{ label: 'medium', id: 'medium' },
212219
{ label: 'high', id: 'high' },
@@ -216,9 +223,12 @@ Return ONLY the JSON array.`,
216223
const { useSubBlockStore } = await import('@/stores/workflows/subblock/store')
217224
const { useWorkflowRegistry } = await import('@/stores/workflows/registry/store')
218225

226+
const autoOption = { label: 'auto', id: 'auto' }
227+
219228
const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
220229
if (!activeWorkflowId) {
221230
return [
231+
autoOption,
222232
{ label: 'low', id: 'low' },
223233
{ label: 'medium', id: 'medium' },
224234
{ label: 'high', id: 'high' },
@@ -231,6 +241,7 @@ Return ONLY the JSON array.`,
231241

232242
if (!modelValue) {
233243
return [
244+
autoOption,
234245
{ label: 'low', id: 'low' },
235246
{ label: 'medium', id: 'medium' },
236247
{ label: 'high', id: 'high' },
@@ -240,15 +251,16 @@ Return ONLY the JSON array.`,
240251
const validOptions = getVerbosityValuesForModel(modelValue)
241252
if (!validOptions) {
242253
return [
254+
autoOption,
243255
{ label: 'low', id: 'low' },
244256
{ label: 'medium', id: 'medium' },
245257
{ label: 'high', id: 'high' },
246258
]
247259
}
248260

249-
return validOptions.map((opt) => ({ label: opt, id: opt }))
261+
return [autoOption, ...validOptions.map((opt) => ({ label: opt, id: opt }))]
250262
},
251-
value: () => 'medium',
263+
mode: 'advanced',
252264
condition: {
253265
field: 'model',
254266
value: MODELS_WITH_VERBOSITY,
@@ -260,6 +272,7 @@ Return ONLY the JSON array.`,
260272
type: 'dropdown',
261273
placeholder: 'Select thinking level...',
262274
options: [
275+
{ label: 'none', id: 'none' },
263276
{ label: 'minimal', id: 'minimal' },
264277
{ label: 'low', id: 'low' },
265278
{ label: 'medium', id: 'medium' },
@@ -271,36 +284,29 @@ Return ONLY the JSON array.`,
271284
const { useSubBlockStore } = await import('@/stores/workflows/subblock/store')
272285
const { useWorkflowRegistry } = await import('@/stores/workflows/registry/store')
273286

287+
const noneOption = { label: 'none', id: 'none' }
288+
274289
const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
275290
if (!activeWorkflowId) {
276-
return [
277-
{ label: 'low', id: 'low' },
278-
{ label: 'high', id: 'high' },
279-
]
291+
return [noneOption, { label: 'low', id: 'low' }, { label: 'high', id: 'high' }]
280292
}
281293

282294
const workflowValues = useSubBlockStore.getState().workflowValues[activeWorkflowId]
283295
const blockValues = workflowValues?.[blockId]
284296
const modelValue = blockValues?.model as string
285297

286298
if (!modelValue) {
287-
return [
288-
{ label: 'low', id: 'low' },
289-
{ label: 'high', id: 'high' },
290-
]
299+
return [noneOption, { label: 'low', id: 'low' }, { label: 'high', id: 'high' }]
291300
}
292301

293302
const validOptions = getThinkingLevelsForModel(modelValue)
294303
if (!validOptions) {
295-
return [
296-
{ label: 'low', id: 'low' },
297-
{ label: 'high', id: 'high' },
298-
]
304+
return [noneOption, { label: 'low', id: 'low' }, { label: 'high', id: 'high' }]
299305
}
300306

301-
return validOptions.map((opt) => ({ label: opt, id: opt }))
307+
return [noneOption, ...validOptions.map((opt) => ({ label: opt, id: opt }))]
302308
},
303-
value: () => 'high',
309+
mode: 'advanced',
304310
condition: {
305311
field: 'model',
306312
value: MODELS_WITH_THINKING,
@@ -391,6 +397,16 @@ Return ONLY the JSON array.`,
391397
value: providers.bedrock.models,
392398
},
393399
},
400+
{
401+
id: 'apiKey',
402+
title: 'API Key',
403+
type: 'short-input',
404+
placeholder: 'Enter your API key',
405+
password: true,
406+
connectionDroppable: false,
407+
required: true,
408+
condition: getApiKeyCondition(),
409+
},
394410
{
395411
id: 'tools',
396412
title: 'Tools',
@@ -403,16 +419,6 @@ Return ONLY the JSON array.`,
403419
type: 'skill-input',
404420
defaultValue: [],
405421
},
406-
{
407-
id: 'apiKey',
408-
title: 'API Key',
409-
type: 'short-input',
410-
placeholder: 'Enter your API key',
411-
password: true,
412-
connectionDroppable: false,
413-
required: true,
414-
condition: getApiKeyCondition(),
415-
},
416422
{
417423
id: 'memoryType',
418424
title: 'Memory',
@@ -467,6 +473,7 @@ Return ONLY the JSON array.`,
467473
min: 0,
468474
max: 1,
469475
defaultValue: 0.3,
476+
mode: 'advanced',
470477
condition: () => ({
471478
field: 'model',
472479
value: (() => {
@@ -484,6 +491,7 @@ Return ONLY the JSON array.`,
484491
min: 0,
485492
max: 2,
486493
defaultValue: 0.3,
494+
mode: 'advanced',
487495
condition: () => ({
488496
field: 'model',
489497
value: (() => {
@@ -499,6 +507,7 @@ Return ONLY the JSON array.`,
499507
title: 'Max Output Tokens',
500508
type: 'short-input',
501509
placeholder: 'Enter max tokens (e.g., 4096)...',
510+
mode: 'advanced',
502511
},
503512
{
504513
id: 'responseFormat',

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -915,24 +915,17 @@ export class AgentBlockHandler implements BlockHandler {
915915
}
916916
}
917917

918-
// Find first system message
919918
const firstSystemIndex = messages.findIndex((msg) => msg.role === 'system')
920919

921920
if (firstSystemIndex === -1) {
922-
// No system message exists - add at position 0
923921
messages.unshift({ role: 'system', content })
924922
} else if (firstSystemIndex === 0) {
925-
// System message already at position 0 - replace it
926-
// Explicit systemPrompt parameter takes precedence over memory/messages
927923
messages[0] = { role: 'system', content }
928924
} else {
929-
// System message exists but not at position 0 - move it to position 0
930-
// and update with new content
931925
messages.splice(firstSystemIndex, 1)
932926
messages.unshift({ role: 'system', content })
933927
}
934928

935-
// Remove any additional system messages (keep only the first one)
936929
for (let i = messages.length - 1; i >= 1; i--) {
937930
if (messages[i].role === 'system') {
938931
messages.splice(i, 1)
@@ -998,13 +991,14 @@ export class AgentBlockHandler implements BlockHandler {
998991
workflowId: ctx.workflowId,
999992
workspaceId: ctx.workspaceId,
1000993
stream: streaming,
1001-
messages,
994+
messages: messages?.map(({ executionId, ...msg }) => msg),
1002995
environmentVariables: ctx.environmentVariables || {},
1003996
workflowVariables: ctx.workflowVariables || {},
1004997
blockData,
1005998
blockNameMapping,
1006999
reasoningEffort: inputs.reasoningEffort,
10071000
verbosity: inputs.verbosity,
1001+
thinkingLevel: inputs.thinkingLevel,
10081002
}
10091003
}
10101004

@@ -1074,6 +1068,7 @@ export class AgentBlockHandler implements BlockHandler {
10741068
isDeployedContext: ctx.isDeployedContext,
10751069
reasoningEffort: providerRequest.reasoningEffort,
10761070
verbosity: providerRequest.verbosity,
1071+
thinkingLevel: providerRequest.thinkingLevel,
10771072
})
10781073

10791074
return this.processProviderResponse(response, block, responseFormat)
@@ -1091,8 +1086,6 @@ export class AgentBlockHandler implements BlockHandler {
10911086

10921087
logger.info(`[${requestId}] Resolving Vertex AI credential: ${credentialId}`)
10931088

1094-
// Get the credential - we need to find the owner
1095-
// Since we're in a workflow context, we can query the credential directly
10961089
const credential = await db.query.account.findFirst({
10971090
where: eq(account.id, credentialId),
10981091
})
@@ -1101,7 +1094,6 @@ export class AgentBlockHandler implements BlockHandler {
11011094
throw new Error(`Vertex AI credential not found: ${credentialId}`)
11021095
}
11031096

1104-
// Refresh the token if needed
11051097
const { accessToken } = await refreshTokenIfNeeded(requestId, credential, credentialId)
11061098

11071099
if (!accessToken) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface AgentInputs {
3434
bedrockRegion?: string
3535
reasoningEffort?: string
3636
verbosity?: string
37+
thinkingLevel?: string
3738
}
3839

3940
export interface ToolInput {

0 commit comments

Comments
 (0)