Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function WorkflowSelector({
onMouseDown={(e) => handleRemove(e, w.id)}
>
{w.name}
<X className='h-3 w-3' />
<X className='!text-[var(--text-primary)] h-4 w-4 flex-shrink-0 opacity-50' />
</Badge>
))}
{selectedWorkflows.length > 2 && (
Expand Down
69 changes: 39 additions & 30 deletions apps/sim/blocks/blocks/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Return ONLY the JSON array.`,
type: 'dropdown',
placeholder: 'Select reasoning effort...',
options: [
{ label: 'auto', id: 'auto' },
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
Expand All @@ -173,9 +174,12 @@ Return ONLY the JSON array.`,
const { useSubBlockStore } = await import('@/stores/workflows/subblock/store')
const { useWorkflowRegistry } = await import('@/stores/workflows/registry/store')

const autoOption = { label: 'auto', id: 'auto' }

const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
if (!activeWorkflowId) {
return [
autoOption,
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
Expand All @@ -188,6 +192,7 @@ Return ONLY the JSON array.`,

if (!modelValue) {
return [
autoOption,
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
Expand All @@ -197,15 +202,16 @@ Return ONLY the JSON array.`,
const validOptions = getReasoningEffortValuesForModel(modelValue)
if (!validOptions) {
return [
autoOption,
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
]
}

return validOptions.map((opt) => ({ label: opt, id: opt }))
return [autoOption, ...validOptions.map((opt) => ({ label: opt, id: opt }))]
},
value: () => 'medium',
mode: 'advanced',
condition: {
field: 'model',
value: MODELS_WITH_REASONING_EFFORT,
Expand All @@ -217,6 +223,7 @@ Return ONLY the JSON array.`,
type: 'dropdown',
placeholder: 'Select verbosity...',
options: [
{ label: 'auto', id: 'auto' },
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
Expand All @@ -226,9 +233,12 @@ Return ONLY the JSON array.`,
const { useSubBlockStore } = await import('@/stores/workflows/subblock/store')
const { useWorkflowRegistry } = await import('@/stores/workflows/registry/store')

const autoOption = { label: 'auto', id: 'auto' }

const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
if (!activeWorkflowId) {
return [
autoOption,
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
Expand All @@ -241,6 +251,7 @@ Return ONLY the JSON array.`,

if (!modelValue) {
return [
autoOption,
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
Expand All @@ -250,15 +261,16 @@ Return ONLY the JSON array.`,
const validOptions = getVerbosityValuesForModel(modelValue)
if (!validOptions) {
return [
autoOption,
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
{ label: 'high', id: 'high' },
]
}

return validOptions.map((opt) => ({ label: opt, id: opt }))
return [autoOption, ...validOptions.map((opt) => ({ label: opt, id: opt }))]
},
value: () => 'medium',
mode: 'advanced',
condition: {
field: 'model',
value: MODELS_WITH_VERBOSITY,
Expand All @@ -270,6 +282,7 @@ Return ONLY the JSON array.`,
type: 'dropdown',
placeholder: 'Select thinking level...',
options: [
{ label: 'none', id: 'none' },
{ label: 'minimal', id: 'minimal' },
{ label: 'low', id: 'low' },
{ label: 'medium', id: 'medium' },
Expand All @@ -281,36 +294,29 @@ Return ONLY the JSON array.`,
const { useSubBlockStore } = await import('@/stores/workflows/subblock/store')
const { useWorkflowRegistry } = await import('@/stores/workflows/registry/store')

const noneOption = { label: 'none', id: 'none' }

const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
if (!activeWorkflowId) {
return [
{ label: 'low', id: 'low' },
{ label: 'high', id: 'high' },
]
return [noneOption, { label: 'low', id: 'low' }, { label: 'high', id: 'high' }]
}

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

if (!modelValue) {
return [
{ label: 'low', id: 'low' },
{ label: 'high', id: 'high' },
]
return [noneOption, { label: 'low', id: 'low' }, { label: 'high', id: 'high' }]
}

const validOptions = getThinkingLevelsForModel(modelValue)
if (!validOptions) {
return [
{ label: 'low', id: 'low' },
{ label: 'high', id: 'high' },
]
return [noneOption, { label: 'low', id: 'low' }, { label: 'high', id: 'high' }]
}

return validOptions.map((opt) => ({ label: opt, id: opt }))
return [noneOption, ...validOptions.map((opt) => ({ label: opt, id: opt }))]
},
value: () => 'high',
mode: 'advanced',
condition: {
field: 'model',
value: MODELS_WITH_THINKING,
Expand Down Expand Up @@ -401,18 +407,6 @@ Return ONLY the JSON array.`,
value: providers.bedrock.models,
},
},
{
id: 'tools',
title: 'Tools',
type: 'tool-input',
defaultValue: [],
},
{
id: 'skills',
title: 'Skills',
type: 'skill-input',
defaultValue: [],
},
{
id: 'apiKey',
title: 'API Key',
Expand All @@ -439,6 +433,18 @@ Return ONLY the JSON array.`,
not: true, // Show for all models EXCEPT Ollama, vLLM, Vertex, and Bedrock models
}),
},
{
id: 'tools',
title: 'Tools',
type: 'tool-input',
defaultValue: [],
},
{
id: 'skills',
title: 'Skills',
type: 'skill-input',
defaultValue: [],
},
{
id: 'memoryType',
title: 'Memory',
Expand Down Expand Up @@ -493,6 +499,7 @@ Return ONLY the JSON array.`,
min: 0,
max: 1,
defaultValue: 0.3,
mode: 'advanced',
condition: () => ({
field: 'model',
value: (() => {
Expand All @@ -510,6 +517,7 @@ Return ONLY the JSON array.`,
min: 0,
max: 2,
defaultValue: 0.3,
mode: 'advanced',
condition: () => ({
field: 'model',
value: (() => {
Expand All @@ -525,6 +533,7 @@ Return ONLY the JSON array.`,
title: 'Max Output Tokens',
type: 'short-input',
placeholder: 'Enter max tokens (e.g., 4096)...',
mode: 'advanced',
},
{
id: 'responseFormat',
Expand Down
14 changes: 3 additions & 11 deletions apps/sim/executor/handlers/agent/agent-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,24 +906,17 @@ export class AgentBlockHandler implements BlockHandler {
}
}

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

if (firstSystemIndex === -1) {
// No system message exists - add at position 0
messages.unshift({ role: 'system', content })
} else if (firstSystemIndex === 0) {
// System message already at position 0 - replace it
// Explicit systemPrompt parameter takes precedence over memory/messages
messages[0] = { role: 'system', content }
} else {
// System message exists but not at position 0 - move it to position 0
// and update with new content
messages.splice(firstSystemIndex, 1)
messages.unshift({ role: 'system', content })
}

// Remove any additional system messages (keep only the first one)
for (let i = messages.length - 1; i >= 1; i--) {
if (messages[i].role === 'system') {
messages.splice(i, 1)
Expand Down Expand Up @@ -989,13 +982,14 @@ export class AgentBlockHandler implements BlockHandler {
workflowId: ctx.workflowId,
workspaceId: ctx.workspaceId,
stream: streaming,
messages,
messages: messages?.map(({ executionId, ...msg }) => msg),
environmentVariables: ctx.environmentVariables || {},
workflowVariables: ctx.workflowVariables || {},
blockData,
blockNameMapping,
reasoningEffort: inputs.reasoningEffort,
verbosity: inputs.verbosity,
thinkingLevel: inputs.thinkingLevel,
}
}

Expand Down Expand Up @@ -1064,6 +1058,7 @@ export class AgentBlockHandler implements BlockHandler {
isDeployedContext: ctx.isDeployedContext,
reasoningEffort: providerRequest.reasoningEffort,
verbosity: providerRequest.verbosity,
thinkingLevel: providerRequest.thinkingLevel,
})

return this.processProviderResponse(response, block, responseFormat)
Expand All @@ -1081,8 +1076,6 @@ export class AgentBlockHandler implements BlockHandler {

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

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

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

if (!accessToken) {
Expand Down
1 change: 1 addition & 0 deletions apps/sim/executor/handlers/agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface AgentInputs {
bedrockRegion?: string
reasoningEffort?: string
verbosity?: string
thinkingLevel?: string
}

export interface ToolInput {
Expand Down
Loading