State class provides a way to manage state and history across a network of agents. It includes key-value storage and maintains a stack of all agent interactions.
The State is accessible to all Agents, Tools and Routers as a state or network.state property.
Creating State
Reading and Modifying State’s data (state.data)
The State class provides typed data accesible via the data property.
Learn more about the State use cases in the State concept guide.
A standard, mutable object which can be updated and modified within tools.
State History
The State history is passed as ahistory to the lifecycle hooks and via the network argument to the Tools handlers to the Router function.
The State history can be retrieved - as a copy - using the state.results property composed of InferenceResult objects:
InferenceResult
TheInferenceResult class represents a single agent call as part of the network state. It stores all inputs and outputs for a call.
The agent responsible for this inference call.
The input passed into the agent’s run method.
The input instructions without additional history, including the system prompt, user input, and initial agent assistant message.
The history sent to the inference call, appended to the prompt to form a complete conversation log.
The parsed output from the inference call.
Output from any tools called by the agent.
The raw API response from the call in JSON format.