Agent (app/agent.ts)
Your agent is defined using Vercel AI SDK (ai@^6). The file exports a default ToolLoopAgent and an optional accepts for payment pricing.
app/agent.ts
ToolLoopAgent
The ToolLoopAgent from Vercel AI SDK handles multi-step tool execution loops automatically. It:
- Takes a model, instructions, and a set of tools
- Executes tool calls in a loop until the stop condition is met
- Returns the final response
accepts Export
The optional accepts named export controls x402 payment gating on the A2A /agent endpoint:
- Agents with
acceptsare registered on payment-gated A2A endpoints - Agents without
acceptsare not registered
capabilities Export
The optional capabilities named export configures the A2A agent card’s capabilities and controls how the executor runs your agent:
app/agent.ts
streaming(default:true) — Whenfalse, the executor usesgenerate()instead ofstream(), returning the full response as a single artifactpushNotifications(default:false) — Advertises push notification support in the agent cardstateTransitionHistory— Advertises state transition history support in the agent card
{ streaming: true, pushNotifications: false }. See the agent.ts reference for details.
Sub-Agents (app/agents/*.ts)
Place additional agent files in app/agents/ to expose multiple A2A endpoints from a single deployment. Each file follows the same format as app/agent.ts and is automatically registered on its own path.
app/agents/research.ts
Files starting with
_ (e.g., _helpers.ts) are ignored by the build pipeline. Use this convention for shared
utilities.Tools (app/tools/*.ts)
Each .ts file in app/tools/ exports a Vercel AI SDK tool and an optional accepts for MCP payment gating. Tools are automatically discovered and registered on both A2A and MCP endpoints.
app/tools/weather.ts
Tool Discovery
The build pipeline automatically discovers all.ts files in app/tools/:
- Each file is registered as an MCP tool
- Tools with
acceptsare payment-gated on the/mcpendpoint - Tools without
acceptsare not registered on MCP
Files starting with
_ (e.g., _helpers.ts) are ignored by the build pipeline. Use this convention for shared
utilities.Per-Tool Pricing
Each tool can declare its own price, enabling granular pricing across your agent:Custom Server
For full control over endpoint registration and middleware, createapp/server.ts. This overrides auto-generation entirely:
app/server.ts