The better way tocompose agentsin TypeScript

>_buncreatebetter-agent

The Best DX

server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
context is missing required property 'userId'
client.ts
1
2
3
4
5
6
7
8
9
10
11
12
context is missing required property 'userId'

Features

01Composable Agents

Build larger agent systems from smaller agents, tools, and shared runtime parts.

02Multi-Provider

Swap models with one line. Same API across supported providers.

+more
03Plugins

Add app-level guards, hooks, middleware, endpoints, and shared behavior with plugins.

rateLimitloggingsandboxipAllowlistguardshooksendpointsmiddlewarerateLimitloggingsandboxipAllowlistguardshooksendpointsmiddleware
04Framework Agnostic

Use Better Agent with your stack instead of building around a fixed app framework.

05AG-UI Events

Stream standard AG-UI events for messages, tools, approvals, interrupts, and final results.

06Durable Runs

Resume interrupted runs, replay streams, and continue threads across requests.

07Human in the Loop

Pause before sensitive tools run, then approve, reject, or resume from the client.

08First-Class Auth

Resolve request identity once, then use it across access rules, memory, plugins, and tools.

09Tools Everywhere

Call server tools, pause for client tools, connect MCP, or pass through hosted provider tools.

Works with

Primitives

Build on the primitives you need

agents.ts
export const supportAgent = defineAgent({
  name: "support",
  model: openai("gpt-5.5"),
  contextSchema: z.object({
    userId: z.string(),
    plan: z.enum(["free", "pro", "enterprise"]),
  }),
  instruction: ({ userId, plan }) =>
    `Resolve the user's issue with ${plan}-level detail. User: ${userId}.`,
  tools: [searchDocs, createTicket],
});
Try it out
npm create better-agent
Terminal