# Full agent state

Show a live plan, task board, or document alongside the conversation.

## Read state from the server

For [AG-UI](/libraries/ai-runtime-ag-ui), read state from the native client. For Assistant UI’s Assistant Transport protocol, add its maintained decoder and state tracker.

```bash
npm install assistant-stream@0.3.55
```

```tsx
import { AssistantTransportDecoder, AssistantTransportDeltaTracker } from "assistant-stream";
export async function* readAgentState(response: Response) {
  if (!response.ok || !response.body) throw new Error(`State stream failed: ${response.status}`);
  const reader = response.body.pipeThrough(new AssistantTransportDecoder({ strict: true })).getReader();
  const tracker = new AssistantTransportDeltaTracker();
  try {
    while (true) {
      const { value, done } = await reader.read();
      if (done) break;
      if (value.type === "update-state") {
        tracker.append(value.operations);
        yield tracker.state;
      }
    }
  } finally {
    await reader.cancel();
    reader.releaseLock();
  }
}

```

Use the matching Assistant Transport encoder on the server. Pass your request’s AbortSignal to cancel reading. Validate the decoded JSON and choose which fields your view can show before publishing it.

## 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](/libraries/ai-runtime#external-store) 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 stream without a final [DONE] marker. The decoder can still log and skip invalid events. Validate required fields and show a failure when they are missing. A valid state update can contain no message. Keep one tracker for the whole stream and resume from the server’s replay or snapshot contract after reconnecting. See [Assistant Transport](https://www.assistant-ui.com/docs/runtimes/custom/assistant-transport) and [threads](/libraries/ai-threads).
