LiveAug 13Production Slack Agent
Copilot Kit Logo

Shared state between agent and user.

One state object, kept in sync across your agent and your frontend in realtime. Choose who can read and who can write, per piece of state.

Three access modes.

Pick the mode per piece of state. Mix all three in one app.

Read-write

useAgent

One shared object the agent and the frontend both read and edit. The user drags a slider, the agent sees it. The agent updates a plan, the UI re-renders.

Partyreadwrite
Agentcan readcan write
Frontendcan readcan write

Agent reads, frontend owns

useAgentContext

Frontend state the agent can see but never edit. The current page, the selected rows, the user's locale: context that grounds every agent turn.

Partyreadwrite
Agentcan readcannot write
Frontendcan readcan write

Frontend reads, agent owns

agentState

Agent state the frontend renders but never edits. Progress through a long task, intermediate results, the agent's working plan: visible, not editable.

Partyreadwrite
Agentcan readcan write
Frontendcan readcannot write

Writes stream as deltas.

When either side writes, CopilotKit computes the delta between the old state and the new state as JSON Patch operations. Past trivial state sizes, that is the difference between shipping a few bytes per change and re-sending the whole object on every keystroke.

The deltas themselves stream as typed STATE_DELTA events over AG-UI, the open agent-user interaction protocol. A full snapshot brings a new session up to date, deltas keep it there.

A shared state object is shown on the frontend and on the agent. When either side writes a value, the delta between the old and new state is computed as a JSON Patch operation and streamed to the other side as a STATE_DELTA event, which applies it. Both sides settle on the same state.

Ship shared state.

useAgent and useAgentContext ship with CopilotKit. State sync runs on AG-UI.