﻿# Build a Codex activity view from streamed events

Build a Codex progress interface by associating streamed notifications with their thread, turn and item instead of displaying an unstructured append-only transcript.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/learn-codex-stream-events/
Language: en

A Codex integration can show work while it happens. The app-server stream describes activity through notifications and incremental updates. A useful interface preserves the object each update belongs to, so a tool operation and an assistant message remain distinguishable throughout the turn.

## Begin with a state projection

Keep conversation, request and item records in the application. The screen becomes a projection of those records rather than the only place where progress exists. A command item can have its own activity row while the answer text grows elsewhere. This arrangement also gives reconnection or refresh logic a coherent object to restore.

## Interpret notification identity before content

A notification’s meaning comes from both its method and the identifiers in its payload. The following abbreviated examples illustrate the association. They omit fields a full client may need; generate or consult the schema for the installed app-server version before implementing a parser.

```jsonl
{"method":"item/started","params":{"threadId":"thr_example","turnId":"turn_example","item":{"id":"cmd_example","type":"commandExecution"}}}
{"method":"item/agentMessage/delta","params":{"threadId":"thr_example","turnId":"turn_example","itemId":"msg_example","delta":"Inspecting the parser"}}
{"method":"turn/completed","params":{"threadId":"thr_example","turn":{"id":"turn_example","status":"completed"}}}
```

## Append text to its message item

A text delta is part of a message, not a complete replacement for the thread. Append it to the correct message item and preserve its association with the turn. When another item arrives, create or update its own representation. This avoids mixing a progress explanation with command output merely because both appeared close together in time.

## Keep completion at the right level

Finishing an item does not necessarily finish the turn. The request may still need another tool call or a final answer. Likewise, a terminal turn status should not erase the evidence already shown for its items. The application can distinguish transport activity, individual work units and the overall request through a small mapping.

| Event information | Interface update | Retained association |
| --- | --- | --- |
| Thread identifier | Choose the conversation record | Keep the project and thread relationship. |
| Turn identifier | Choose the active request | Preserve earlier requests in the same conversation. |
| Item identifier | Update a message or operation | Append deltas to that item rather than a global field. |
| Terminal turn status | Finish the request’s activity state | Keep the delivered artifact and unresolved limitations visible. |

## Test the projection with interleaved examples

A proposed client test can replay notifications for several items and verify that each delta reaches its intended record. Include a failed or interrupted turn as well as a completed one. This evaluates the interface’s event handling, not the model’s coding quality. A correct projection should explain the observed execution without inventing a success state from the mere presence of streamed text.

## Documentation and further study

- [Codex App Server](https://learn.chatgpt.com/docs/app-server).

- [Codex as a platform: build on the open agent harness](https://developers.openai.com/blog/codex-as-a-platform).

- [Non-interactive mode](https://learn.chatgpt.com/docs/non-interactive-mode).

Related engineering guides: [Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [Choose a local AI stack: desktop chat, shared UI or coding agent](/journal/local-ai-app-stack-selection/).
