.agents/features/agents.md
Agents is a flow step type (backed by @activepieces/piece-agent) that executes an LLM-driven autonomous loop. The agent is given a prompt, a set of tools, an AI provider/model, and optional structured-output fields. It runs a ReAct-style loop (up to maxSteps) where the model can call any configured tool before producing a final answer. Tools can be piece actions, other flows, MCP servers, or knowledge-base files. The feature is entirely configured inside the Flow Builder as a special step and does not have its own backend entity — the agent configuration lives inside the flow version's step settings.
packages/shared/src/lib/automation/agents/index.ts — enums (AgentToolType, AgentTaskStatus, ContentBlockType, ToolCallType, AgentOutputFieldType), types (AgentProviderModel, AgentResult, AgentStepBlock, AgentOutputField), and AgentPieceProps property name enumpackages/shared/src/lib/automation/agents/tools.ts — all tool Zod schemas: AgentPieceTool, AgentFlowTool, AgentMcpTool, AgentKnowledgeBaseTool, AgentTool discriminated union; McpAuthConfig, PredefinedInputsStructurepackages/web/src/features/agents/index.ts — barrel exportpackages/web/src/features/agents/hooks/agent-hooks.ts — agentQueries.useFlowsForAgent(), agentMutations.useValidateMcpTool()packages/web/src/features/agents/agent-tools/ — tool management UI (add dropdown, per-tool dialogs, stores)packages/web/src/features/agents/agent-tools/stores/ — Zustand stores for piece-tools dialog (pieces-tools.ts) and knowledge-base tools (knowledge-base-tools.ts)packages/web/src/features/agents/agent-tools/piece-tool-dialog/ — multi-page dialog: piece list → action list → predefined inputs form → connection pickerpackages/web/src/features/agents/agent-tools/flow-tool-dialog/ — dialog to attach another flow as a toolpackages/web/src/features/agents/agent-tools/mcp-tool-dialog/ — MCP server URL + auth config dialog; calls mcpToolApi.validateAgentMcpTool to verify connectivitypackages/web/src/features/agents/agent-tools/knowledge-base-dialog/ — dialog to attach a knowledge-base filepackages/web/src/features/agents/agent-timeline/ — AgentTimeline component that renders step-by-step execution blocks (markdown + tool calls) from AgentResult.stepspackages/web/src/features/agents/ai-model/ — AIModelSelector component; PROVIDER_EMBEDDING_MODELS constantpackages/web/src/features/agents/ai-providers.ts — SUPPORTED_AI_PROVIDERS list with metadata per providerpackages/web/src/features/agents/structured-output/ — AgentStructuredOutput component for defining output field schemapackages/web/src/app/builder/step-settings/agent-settings/index.tsx — builder panel for configuring an agent steppackages/web/src/app/builder/test-step/agent-test-step/index.tsx — test panel for running a single agent step and viewing resultsGated by platform.plan.agentsEnabled. When disabled, the agent step type is hidden from the piece selector. All editions can run agents if the flag is enabled; by default it is off on Community, on on Cloud plans that include it.
PIECE, FLOW, MCP, KNOWLEDGE_BASEpieceName, pieceVersion, actionName; can carry predefinedInput locking certain fieldsexternalFlowId; the flow is executed as a child runAGENT_DECIDE, CHOOSE_YOURSELF, LEAVE_EMPTY) baked into the tool so the agent knows which inputs it controlsprompt, steps[], status, and optional structuredOutputMarkdownContentBlock or ToolCallContentBlock describing one turn in the agent loopIN_PROGRESS (streaming) or COMPLETEDCOMPLETED, FAILED, IN_PROGRESSThe agent step is a PIECE action on @activepieces/piece-agent. Its settings.input contains:
agentTools — AgentTool[]structuredOutput — AgentOutputField[]prompt — string (may include {{variables}})maxSteps — numberaiProviderModel — AgentProviderModel ({ provider, model })webSearch / webSearchOptions — optional web search tool configurationExternal MCP servers configured as agent tools are validated server-side via POST /v1/projects/:projectId/agent-tools/mcp/validate (see packages/server/api/src/app/agents/). The handler performs the JSON-RPC initialize → notifications/initialized → tools/list handshake against the target and returns its tool names. The outbound call is routed through apAxios, whose http/https agents are built by ssrf-agents.ts to reject private / loopback / link-local / meta IPs by default. Operators can allow specific ranges via AP_SSRF_ALLOW_LIST (CIDR supported). All error paths collapse to a single generic message to avoid leaking reachability signal.
The validator lives under agents/ (not mcp/) because it belongs to the agent piece domain — validating an external MCP server the agent will connect to at flow-execution time. The mcp/ module handles the opposite direction: exposing Activepieces itself as an MCP server to external clients.
AgentTimeline receives AgentStepBlock[] from the step output and renders: