---
title: a2
description: An open-source SDK for building AI agents.
type: overview
summary: a2 is an SDK for building AI agents. It handles sandboxes, storage, optional durable execution, streaming, and tool orchestration. Built on the Vercel AI SDK.
---

# a2



a2 is an open-source SDK for building AI agents. It handles sandboxed execution, persistent storage, streaming, and tool orchestration. Durability via Vercel Workflow is opt-in. Built on the [Vercel AI SDK](https://ai-sdk.dev).

```ts title="src/agent.ts"
import { agent } from "experimental-agent";

export const myAgent = agent("my-agent", {
  model: "anthropic/claude-opus-4.6",
  system: "You are a helpful coding assistant.",
  needsApproval: {
    Bash: true,
  },
});
```

## Send and Stream

```ts title="src/chat.ts"
import { createUIMessageStreamResponse } from "ai";
import { myAgent } from "@/agent";

export async function sendMessage({
  chatId,
  message,
}: {
  chatId: string;
  message: string;
}) {
  const session = myAgent.session(chatId);
  await session.send(message);
  const stream = await session.stream();
  return createUIMessageStreamResponse({ stream });
}
```

a2 works with any JavaScript runtime. See [Framework Guides](/docs/guides/frameworks) for runtime-specific setup, including Next.js.

## Built-in Tools

Every agent includes [8 tools](/docs/reference/built-in-tools) that execute inside the [sandbox](/docs/concepts/sandbox):

* **[Read](/docs/reference/built-in-tools#read)** — Read file contents with line-range pagination
* **[Write](/docs/reference/built-in-tools#write)** — Write content to a file, creating parent directories
* **[Edit](/docs/reference/built-in-tools#edit)** — Replace an exact string in a file
* **[Grep](/docs/reference/built-in-tools#grep)** — Search files with ripgrep (regex, globs, file type filters)
* **[List](/docs/reference/built-in-tools#list)** — Recursively list directory contents with depth control
* **[Bash](/docs/reference/built-in-tools#bash)** — Execute shell commands with streaming output
* **[Skill](/docs/reference/built-in-tools#skill)** — Load reusable instruction sets on demand
* **[JavaScript](/docs/reference/built-in-tools#javascript)** — Execute JavaScript code dynamically, with access to other tools as sub-tools

Define additional tools using [`tool()`](/docs/guides/ai-sdk) from the [Vercel AI SDK](https://ai-sdk.dev). Use [`activeTools`](/docs/concepts/tools#restricting-tools) to control which tools are enabled per-agent or per-session, and [`needsApproval`](/docs/concepts/approvals) to require human approval before any tool executes — both built-in and custom.

## What a2 Handles

* **[Sandbox](/docs/concepts/sandbox)** — Agents run tools in an isolated execution environment. Supports [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox), local filesystem, Docker, or a custom backend.
* **[Storage](/docs/concepts/storage)** — Sessions, messages, and sandbox state are persisted via a `storage()` function you provide. Built-in `localStorage()` for dev, or bring your own database.
* **[Streaming](/docs/concepts/streaming)** — Real-time message streaming with reconnection support. Compatible with the AI SDK's `useChat` and `createUIMessageStreamResponse`.
* **[Workflow (Opt-In)](/docs/concepts#workflow-for-durability-opt-in)** — Add `"use workflow"` for durable execution via [Vercel Workflows](https://vercel.com/docs/workflow). Survives serverless timeouts, can suspend for human approval, and resumes where it left off.
* **[Approvals](/docs/concepts/approvals)** — Require human approval before specific tools execute. The agent suspends until the user responds.
* **[Hooks](/docs/concepts/hooks)** — Intercept tool execution with `tool.before` and `tool.after` hooks to modify inputs, transform outputs, or block calls.
* **[Skills](/docs/concepts/skills)** — Reusable instruction sets loaded from the filesystem that the agent reads on demand.

## Defaults

| Feature                                                   | Default                                                  | Override                                                                                                                 |
| --------------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| [Storage](/docs/concepts/storage)                         | `localStorage()` (filesystem)                            | [Custom `storage()` function](/docs/guides/custom-storage)                                                               |
| [Sandbox](/docs/concepts/sandbox)                         | [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox) | `sandbox: { type: "local" }` or `{ type: "docker" }`                                                                     |
| Model                                                     | — (required)                                             | Any model via [Vercel AI Gateway](https://ai-sdk.dev)                                                                    |
| Tools                                                     | [8 built-in tools](/docs/reference/built-in-tools)       | Add [custom tools](/docs/guides/custom-tools), restrict with [`activeTools`](/docs/reference/built-in-tools#activetools) |
| [Approvals](/docs/concepts/approvals)                     | None required                                            | [`needsApproval: { Bash: true }`](/docs/concepts/approvals)                                                              |
| [Workflow](/docs/concepts#workflow-for-durability-opt-in) | Off (in-process)                                         | Add a `"use workflow"` function                                                                                          |

## Resources

* **[Installation](/docs/installation)** — Install the SDK and its dependencies.
* **[Quickstart](/docs/quickstart)** — Set up an agent step by step.
* **[Build Your First Agent](/docs/guides/build-your-first-agent)** — End-to-end guide with sandbox, tools, approvals, and deployment.
* **[Concepts](/docs/concepts)** — How sessions, tools, sandbox, storage, and streaming work.
* **[Changelog](/docs/changelog)** — What changed in the latest release.
* **[Use with AI SDK](/docs/guides/ai-sdk)** — `useChat`, streaming, typed messages, and model selection.
* **[API Reference](/docs/reference/agent)** — Full `agent()` and session API documentation.
* **[GitHub](https://github.com/vercel-labs/agent-sdk)** — Source code.
