The agent's projected session state, or null before the first push.
null
The counterpart to syncState on the agent: whatever that projection returns is what arrives here — no per-tool result mirroring needed.
syncState
import { useAgentState } from "@alexkroman1/aai-ui";type Item = { sku: string; qty: number };function Cart() { const state = useAgentState<{ cart: Item[] }>(); return <ul>{state?.cart.map((item) => <li key={item.sku}>{item.qty}</li>)}</ul>;} Copy
import { useAgentState } from "@alexkroman1/aai-ui";type Item = { sku: string; qty: number };function Cart() { const state = useAgentState<{ cart: Item[] }>(); return <ul>{state?.cart.map((item) => <li key={item.sku}>{item.qty}</li>)}</ul>;}
Typed by the caller for the same reason useToolResult is: the shape is the author's own projection, which the framework cannot see. It is nullable on purpose — nothing has been pushed before the first tool call, and a UI has to render that moment.
useToolResult
The agent's projected session state, or
nullbefore the first push.The counterpart to
syncStateon the agent: whatever that projection returns is what arrives here — no per-tool result mirroring needed.Typed by the caller for the same reason
useToolResultis: the shape is the author's own projection, which the framework cannot see. It is nullable on purpose — nothing has been pushed before the first tool call, and a UI has to render that moment.