The Agent Block is a core workflow component that wraps Large Language Model (LLM) execution with advanced capabilities including multi-provider model selection, tool/function calling, memory management, skills integration, and structured output generation. It serves as the primary interface for AI agent behavior within workflows apps/sim/blocks/blocks/agent.ts64-69
This document covers the Agent Block's configuration, execution handler, tool integration, and memory system. For multi-provider LLM integration details, see 5. AI Provider Integration. For the broader block system architecture, see 4.1. Block Registry System.
The Agent Block is defined in apps/sim/blocks/blocks/agent.ts59-215 as AgentBlock: BlockConfig<AgentResponse>. It exposes a rich set of configuration options through its subBlocks array.
| SubBlock ID | Type | Purpose |
|---|---|---|
messages | messages-input | Array of system/user/assistant messages with dynamic prompt generation apps/sim/blocks/blocks/agent.ts78-108 |
model | combobox | Model selection from all providers (OpenAI, Anthropic, Google, etc.) apps/sim/blocks/blocks/agent.ts117-130 |
tools | tool-input | Array of tools available to the agent with usage control apps/sim/blocks/blocks/agent.ts132-155 |
skills | skill-input | Progressive disclosure skill references apps/sim/blocks/blocks/agent.ts157-175 |
memoryType | dropdown | Memory strategy: none, conversation, sliding window apps/sim/blocks/blocks/agent.ts435-488 |
responseFormat | code | JSON schema for structured outputs with wand-based generation apps/sim/blocks/blocks/agent.ts384-433 |
The block includes conditional subBlocks that appear based on the selected model:
azureEndpoint, azureApiVersion apps/sim/blocks/blocks/agent.ts192-218vertexProject, vertexLocation apps/sim/blocks/blocks/agent.ts220-244bedrockAccessKeyId, bedrockSecretKey, bedrockRegion apps/sim/blocks/blocks/agent.ts246-285reasoningEffort, verbosity, thinkingLevel apps/sim/blocks/blocks/agent.ts515-657Sources: apps/sim/blocks/blocks/agent.ts59-657
The following diagram bridges the high-level agent concepts to the specific code entities that handle them.
Agent Block System Architecture
Sources: apps/sim/blocks/blocks/agent.ts59-715 apps/sim/executor/handlers/agent/agent-handler.ts44-114 apps/sim/executor/handlers/agent/types.ts1-68
The AgentBlockHandler class implements the BlockHandler interface apps/sim/executor/handlers/agent/agent-handler.ts44-47 It is responsible for transforming high-level agent inputs into low-level provider requests.
Sources: apps/sim/executor/handlers/agent/agent-handler.ts44-114
The sequence below details the interaction between the handler and external systems like memory and providers.
Agent Block Execution Sequence
Sources: apps/sim/executor/handlers/agent/agent-handler.ts49-114 apps/sim/executor/handlers/agent/memory.ts1-20
The formatTools function apps/sim/executor/handlers/agent/agent-handler.ts178-225 converts various tool types (MCP, Custom, Workflow Blocks) into a unified ProviderToolConfig format.
mcpServers connection status in the database apps/sim/executor/handlers/agent/agent-handler.ts131-177executeTool('function_execute', ...) which runs code in an isolated environment apps/sim/executor/handlers/agent/agent-handler.ts275-353transformBlockTool to expose specific block operations as LLM functions apps/sim/providers/utils.ts35Agents support three levels of ToolUsageControl apps/sim/providers/types.ts104:
auto: The model chooses when to use the tool.force: The model is required to use the tool.none: The tool is filtered out before the request is sent apps/sim/executor/handlers/agent/agent-handler.ts187Sources: apps/sim/executor/handlers/agent/agent-handler.ts131-353 apps/sim/providers/utils.ts43 apps/sim/providers/types.ts104-119
The memoryService apps/sim/executor/handlers/agent/memory.ts manages conversation history based on memoryType (conversation, sliding window, etc.).
When an agent executes:
messages input apps/sim/executor/handlers/agent/agent-handler.ts83For streaming responses, the handler uses wrapStreamForMemoryPersistence apps/sim/executor/handlers/agent/agent-handler.ts100-104 This function tee()s the stream, allowing one branch to be returned to the client while the other is consumed by the handler to accumulate and save the final response to the memory database.
Sources: apps/sim/executor/handlers/agent/agent-handler.ts83-113 apps/sim/executor/handlers/agent/memory.ts
The Agent block uses a pattern-based resolution system to map models to providers apps/sim/providers/utils.ts203-248
| Model Pattern | Provider ID | File |
|---|---|---|
/^gpt/, /^o\d/ | openai | apps/sim/providers/models.ts106 |
/^claude/ | anthropic | apps/sim/providers/models.ts339 |
/^gemini/ | google | apps/sim/providers/models.ts503 |
/^openrouter\// | openrouter | apps/sim/providers/models.ts79 |
/^vllm\// | vllm | apps/sim/providers/models.ts94 |
The PROVIDER_DEFINITIONS constant apps/sim/providers/models.ts73 acts as the single source of truth for:
Sources: apps/sim/providers/models.ts73-503 apps/sim/providers/utils.ts203-248
The parseResponseFormat utility apps/sim/executor/handlers/shared/response-format.ts processes the JSON schema provided in the block config.
response_format or responseSchema).Sources: apps/sim/executor/handlers/agent/agent-handler.ts59 apps/sim/executor/handlers/shared/response-format.ts
Refresh this wiki