Overview
The@deepagents/agent package provides the foundation for building multi-agent AI systems with TypeScript. It offers agent composition, tool integration, handoffs, structured output, streaming, and type-safe context management.
Installation
zod^3.25.76 || ^4.0.0ai(included automatically)
Quick Example
Core API
agent(config)
Creates a new agent.
execute(agent, messages, context, config?)
Executes an agent with streaming support.
generate(agent, messages, context, config?)
Non-streaming execution. Returns complete result.
swarm(agent, messages, context, abortSignal?)
High-level multi-agent execution with handoff support.
instructions(config)
Creates structured prompts for agents.
toState<T>(options)
Access context inside tools.
user(message)
Creates a user message.
Advanced Features
Structured Output
Define typed output schemas:Context Functions
Dynamic prompts based on context:Lifecycle Hooks
prepareHandoff
Runs before transferring to this agent:prepareEnd
Runs after this agent completes:Utilities
toOutput<T>(result)
Extract structured output from result:
stream()
Alias for execute():
TypeScript Types
Agent Type Parameters
Output: Structured output type (if usingoutputschema)CIn: Input context typeCOut: Output context type (defaults toCIn)
Model Providers
Compatible with all Vercel AI SDK providers:- OpenAI
- Anthropic
- Google
- Groq
Package Info
- Version: 0.23.0
- License: MIT
- Repository: github.com/JanuaryLabs/deepagents
- Package: @deepagents/agent
Related Packages
@deepagents/context
Context management and fragments
@deepagents/toolbox
Pre-built tools for agents
@deepagents/orchestrator
High-level orchestration patterns