Skip to main content
The agent maintains stateful context across turns, including messages, tools, model configuration, and message queues for steering and follow-up.

Agent State

The agent exposes its state via agent.state:

State Mutations

System Prompt

Model Selection

Thinking Level

Tools

Thinking Budgets

Configure token budgets for thinking levels:

Message Management

Adding Messages

Accessing Messages

Message Queues

The agent supports two types of queued messages:

Steering Messages

Steering messages interrupt the agent while tools are running:
When steering messages are detected:
  1. Remaining tools are skipped with error results
  2. Steering messages are injected
  3. LLM responds to the interruption

Follow-up Messages

Follow-up messages queue work after the agent would otherwise stop:
Follow-up messages are checked when:
  • There are no more tool calls
  • No steering messages are queued
If any follow-up messages exist, they’re injected and another turn runs.

Delivery Modes

Deliver one message, wait for response, then deliver the next.

Clearing Queues

Custom Message Types

Extend AgentMessage for app-specific types:
Handle custom types in convertToLlm:

Context Transformation

Transform the context before sending to the LLM:

Reset and Control

Next Steps

Agent Overview

Core agent concepts

Transport

Custom backends and proxies

API Reference

Complete Agent API