In this article
Threads hold conversations, turns hold a request’s work, and items identify individual inputs or outputs; transport request IDs serve a separate correlation role.
Codex app-server exposes a conversation as structured objects. An integration becomes easier to reason about when it preserves those object boundaries instead of flattening every notification into a single text log. The following payloads are illustrative protocol fragments, not a running application.
Initialize the connection
The documented connection lifecycle begins with initialize and an initialized notification. Client metadata identifies the integration. This handshake belongs to the connection rather than to a particular repository question. Keep that distinction in a client state machine so reconnecting does not accidentally reuse an uninitialized transport.
{"id":"init","method":"initialize","params":{"clientInfo":{"name":"example_client","version":"example"}}}
{"method":"initialized","params":{}}
Create a conversation object
A thread is the conversation container. The example receives its identifier from the server and stores that value for later operations. The client should not manufacture a thread identifier from a local task label: the application task and the server conversation are related objects with different owners.
{"id":"create","method":"thread/start","params":{}}
{"id":"create","result":{"thread":{"id":"thr_example"}}}
Start the work within that conversation
A turn connects a new user input to the thread. Its work can produce many items, including messages and tool activity. Sending turn/start is an initiating operation, not the final result. The integration must continue consuming the relevant notifications until the turn reaches its documented terminal state.
{"id":"work","method":"turn/start","params":{"threadId":"thr_example","input":[{"type":"text","text":"Summarize the repository"}]}}
Map identifiers to the correct owner
A transport response echoes the request ID, while a notification identifies the affected runtime object in its payload. These are complementary correlation mechanisms. A user interface can keep a pending-request map alongside its thread and turn records. Confusing the maps makes late replies surprisingly difficult to interpret.
| Object | Belongs to | Useful application key |
|---|---|---|
| Thread | Persistent conversation | Associate the conversation with the selected project record. |
| Turn | User request and resulting work | Track the current request without overwriting earlier work. |
| Item | A message, tool call or other work unit | Update the matching operation when a later event arrives. |
| Transport request | Client/server protocol exchange | Match a response to the request that created it. |
Build the interface from object state
An item can update a command row while a turn remains active. A completed turn can then attach its final status to the corresponding user request. Keeping both levels makes a task view understandable without interpreting every text delta as a new operation. The protocol documentation is the source for concrete event fields and supported methods.
Documentation and further study
Related engineering guides: Reproducible inference stacks: preserving a GPU pilot’s result; Choose a local AI stack: desktop chat, shared UI or coding agent.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.