Import
Examples
Basic agent
Agent with tools
Streaming API route
Multi-agent composition
API
agent(config)
Create an agent
| Property | Type | Description |
|---|---|---|
id? | string | Unique identifier (auto-generated if omitted) |
model | ModelString | Provider and model (e.g. "openai/gpt-4o") |
system | string | (() => string) | (() => Promise<string>) | System prompt. Accepts a string, function, or async function. |
tools? | true | Record<string, Tool | boolean> | Tools available to the agent |
maxSteps? | number | Max tool-call iterations per request |
streaming? | boolean | Enable streaming responses |
memory? | MemoryConfig | Conversation memory settings |
middleware? | AgentMiddleware[] | Execution middleware pipeline |
edge? | EdgeConfig | Edge runtime configuration |
multimodal? | { vision?: boolean; audio?: boolean } | Enable vision and/or audio |
Agent
agent.generate(input)
Run the agent and return a complete response. Accepts a string or message array as input.
| Property | Type | Description | |
|---|---|---|---|
input | `string \ | Message[]` | Prompt string or message history |
context? | Record<string, unknown> | Additional context passed to the agent |
Promise<AgentResponse>
agent.stream(input)
Run the agent and stream the response. Returns a result with .toDataStreamResponse() for API routes.
| Property | Type | Description |
|---|---|---|
input? | string | Prompt string |
messages? | Message[] | Conversation message history |
context? | Record<string, unknown> | Additional context passed to the agent |
onToolCall? | (toolCall: ToolCall) => void | Callback fired when a tool is invoked |
onChunk? | (chunk: string) => void | Callback fired for each text chunk |
Promise<AgentStreamResult>
agent.respond(request)
Handle an incoming HTTP request and return a streaming Response. Reads messages from the request body.
Returns: Promise<Response>
agent.getMemory()
Get the agent’s memory instance.
Returns: Memory<Message>
agent.getMemoryStats()
Get memory usage statistics (message count, estimated tokens, type).
Returns: Promise<{ totalMessages: number; estimatedTokens: number; type: string }>
agent.clearMemory()
Clear all stored messages from memory.
Returns: Promise<void>
Exports
Functions
| Name | Description |
|---|---|
agent | Create an agent |
agentAsTool | Wrap agent as callable tool |
createMemory | Create memory (buffer, conversation, summary) |
createRedisMemory | Create Redis-backed memory |
createWorkflow | Create sequential agent workflow |
getAgent | Get agent by ID |
getAgentsAsTools | Get agents as tools (multi-agent) |
getAllAgentIds | List registered agent IDs |
getTextFromParts | Extract text from multi-part message |
getToolArguments | Extract parsed tool call args |
hasArgs | Check for parsed args on tool call |
hasInput | Check for raw input on tool call |
registerAgent | Register agent for discovery |
Classes
| Name | Description |
|---|---|
AgentRuntime | Agent execution runtime |
BufferMemory | In-memory message buffer |
ConversationMemory | Full conversation history |
RedisMemory | Redis-backed persistent memory |
SummaryMemory | Compresses old messages into summaries |
Types
| Name | Description |
|---|---|
Agent | agent() return type |
AgentConfig | Agent configuration |
AgentContext | Agent handler context |
AgentMiddleware | Agent execution middleware |
AgentResponse | Agent execution response |
AgentStatus | Agent status (idle, running, etc.) |
AgentStreamResult | Streaming result (.toDataStreamResponse()) |
EdgeConfig | Agent-to-agent edge config |
Memory | Memory interface |
MemoryConfig | Memory creation config |
MemoryPersistence | Memory storage backend |
MemoryStats | Memory usage stats |
Message | Chat message (user, assistant, system, tool) |
MessagePart | Multi-part message segment |
ModelProvider | Model provider interface |
ModelString | Model configuration string format: “provider/model-name” |
RedisClient | Redis client interface (compatible with ioredis and node-redis) |
RedisMemoryConfig | Redis memory configuration |
StreamToolCall | Streaming tool call |
ToolCall | Completed tool call |
ToolCallPart | Tool call message segment |
ToolCallPartWithArgs | Tool call with parsed args |
ToolCallPartWithInput | Tool call with raw input |
ToolResultPart | Tool execution result segment |
WorkflowConfig | createWorkflow config |
WorkflowResult | Completed workflow result |
WorkflowStep | Workflow step definition |
Related
veryfront/chat: Client-side chat UI for agentsveryfront/tool: Define tools for agentsveryfront/provider: Configure AI model providersveryfront/workflow: Orchestrate multi-agent workflows