agentc
GitHubagentc-sh/agentc
agentc
GitHubagentc-sh/agentc
›Introduction
Get started›Concepts in 5 minutes›Build your first agent›Add your first tool›Serve and connect
Concepts›Architecture overview›The manifest›The compilation pipeline›Archetypes›The graph›Tools and capabilities›Runtime libraries›Skills›Agents and prompts›Serving and protocols›Observability
Guides›Author a manifest›Write a tool›Give your agent a filesystem›Control network egress›Connect external tools via MCP›Connect agents via A2A›Use the bash tool›Control tool access with capabilities›Write templated prompts›Manage prompts with Langfuse›Pass context from the client›Configure a model provider›Connect a CopilotKit frontend›Deploy a standalone binary›Deploy with Docker and PostgreSQL›Instrument with OpenTelemetry›Extend code generation with blocks
Reference
Manifest
Runtime
ReAct
HTTP
›Prompt templates›State
›Observability

State

The ReAct run state structure, how tools update it, and what clients can see.

Every run has a persistent state object. The state persists across the run and holds everything the agent needs between steps. Tools receive a snapshot of the current state and can return updates to it alongside their output.

Run state

For ReAct, the state holds:

FieldTypeDescription
run_idstringUnique identifier for this run.
session_idstringIdentifier for the session this run belongs to.
modelobjectClient-supplied model selection, inference, timeout, and retry configuration for this session.
model.overrideobjectOptional provider, model, and inference parameter overrides.
model.override.providerstringOptional provider to use instead of the agent default.
model.override.modelstringOptional model to use instead of the agent default.
model.override.inference_paramsobjectOptional inference parameter overrides.
model.timeoutintegerOptional model response stream establishment timeout in milliseconds.
model.retryobjectOptional retry policy for transient model response stream establishment failures.
model.retry.max_attemptsintegerMaximum number of attempts, including the first request.
model.retry.initial_backoffintegerDelay in milliseconds before the first retry.
model.retry.max_backoffintegerMaximum base backoff between attempts, in milliseconds.
capability_overridestringIf set, the capabilities to use for the agent this session instead of the default.
messagesarrayThe full conversation history for this run.
context_varsarrayContext variables provided at the start of the session.
toolsarrayTool definitions provided by the client for this session.
contextobjectStructured data that persists across steps. This is the primary field for tools to write to and for clients to read from.

The context field is a free-form JSON object. Tools write to it via state updates, and clients can read it from state events. Any data your tools need to communicate back to the frontend should go in context.

Messages are persisted separately from context. That matters because clients often want to read the conversation history without starting a new run. The persisted message store is also what makes the session and message HTTP endpoints useful outside of the active stream.

ReAct user messages can be multimodal. A user message is an ordered list of content blocks. The common block types are text, image, audio, video, and document. Image, audio, video, and document blocks carry a source and a media_type. The source is either a URL or base64 payload. The media_type is the MIME type the model provider should see.

State update

State updates are how the state evolves over the course of a session. Each state has its own corresponding structure for updates. For ReAct, the state update structure is:

FieldTypeDescription
messagesarrayNew messages to append to the conversation history.
contextarrayPartial updates to the context field in the form of RFC 6902 JSON Patch operations. Tools primarily use this to write data back to the frontend.

State updates from tools

When a tool returns, it can include a state_update array of RFC 6902 JSON Patch operations. These patches are not applied directly to the run state. Instead:

  1. The patches are used to construct a StateUpdate object. For ReAct, StateUpdate has two fields: messages and context. This means tools can only update those two fields.
  2. The StateUpdate is applied to the run state and persisted.
  3. The patches are emitted to the client as state delta events immediately after the tool returns.

This means any patch path in a tool's state_update must be rooted at /context/ or /messages/. In practice, tools almost always write to /context/.

Example state update from a tool:

[
  { "op": "add", "path": "/context/last_city", "value": "London" },
  { "op": "add", "path": "/context/temperature", "value": 18.5 }
]

Client-visible state

Clients only have access to the context field of the run state. When state delta events are emitted, the client receives patches scoped to context. When a client sends new state in a run request, it is applied to context.

This design means context is the shared data contract between your tools and your frontend. Structure it as needed for your use case. The event stream that carries these updates is documented in the HTTP reference.

← PreviousPrompt templatesNext →AG-UI

© 2026 pogue.dev. All rights reserved.

Creative CommonsCC BY 4.0
On this pageRun stateState updateState updates from toolsClient-visible state

Search docs

Search the agentc documentation