Skip to content

Full agent state

Decode a state protocol once and project only the fields your interface needs.

Keep the state schema application-owned

Use this path for state beyond a transcript: a plan, task board, selected document or structured agent workspace. If your backend already speaks AG-UI, use its native client's state reducer. For Assistant UI's Assistant Transport protocol, install assistant-stream@0.3.55 and reuse its maintained decoder and state tracker.

assistant-transport-state.ts

The server emits the matching Assistant Transport protocol with its maintained encoder. The caller's fetch signal owns cancellation. This function yields native JSON state; validate it against your application schema before publishing. Do not cast arbitrary state into ChatMessage[] or expose hidden server fields merely because they decoded successfully.

Connect a view without adopting another engine

Your store can keep the full state and expose a projection as ChatRuntimeInput: messages, identity, controller and capabilities. Use createChatRuntimeStore to subscribe. Render messages with MessageParts and show validated plan/task fields in application panels. If no message field exists, use the relevant components directly rather than inventing a transcript.

The decoder/tracker own wire parsing and state operations. Your application owns schema, command transport, persistence, replay and side effects. Ghost owns the optional runtime guards and React composition. There is no required Ghost transport or universal agent-state schema.

Troubleshooting

Strict decoding rejects a missing final [DONE] marker;the maintained decoder logs and drops invalid event payloads,so it does not establish complete wire integrity. Validate state and fail visibly when required fields are absent. A valid state update need not contain a message. If text-only events matter as well, consume them deliberately in the same owner rather than silently dropping application-required events. Do not reset the tracker per chunk. A reconnect needs the server's replay/snapshot contract; starting a fresh tracker against deltas that require an earlier state can corrupt the projection. See Assistant Transport and threads.