app-server.md +168 −16
116- **Start (or resume) a thread**: Call `thread/start` for a new conversation, `thread/resume` to continue an existing one, or `thread/fork` to branch history into a new thread id.116- **Start (or resume) a thread**: Call `thread/start` for a new conversation, `thread/resume` to continue an existing one, or `thread/fork` to branch history into a new thread id.
117- **Begin a turn**: Call `turn/start` with the target `threadId` and user input. Optional fields override model, personality, `cwd`, sandbox policy, and more.117- **Begin a turn**: Call `turn/start` with the target `threadId` and user input. Optional fields override model, personality, `cwd`, sandbox policy, and more.
118- **Steer an active turn**: Call `turn/steer` to append user input to the currently in-flight turn without creating a new turn.118- **Steer an active turn**: Call `turn/steer` to append user input to the currently in-flight turn without creating a new turn.
119119- **Stream events**: After `turn/start`, keep reading notifications on stdout: `item/started`, `item/completed`, `item/agentMessage/delta`, tool progress, and other updates.- **Stream events**: After `turn/start`, keep reading notifications on stdout: `thread/archived`, `thread/unarchived`, `item/started`, `item/completed`, `item/agentMessage/delta`, tool progress, and other updates.
120- **Finish the turn**: The server emits `turn/completed` with final status when the model finishes or after a `turn/interrupt` cancellation.120- **Finish the turn**: The server emits `turn/completed` with final status when the model finishes or after a `turn/interrupt` cancellation.
121 121
122## Initialization122## Initialization
201- `thread/start` - create a new thread; emits `thread/started` and automatically subscribes you to turn/item events for that thread.201- `thread/start` - create a new thread; emits `thread/started` and automatically subscribes you to turn/item events for that thread.
202- `thread/resume` - reopen an existing thread by id so later `turn/start` calls append to it.202- `thread/resume` - reopen an existing thread by id so later `turn/start` calls append to it.
203- `thread/fork` - fork a thread into a new thread id by copying stored history; emits `thread/started` for the new thread.203- `thread/fork` - fork a thread into a new thread id by copying stored history; emits `thread/started` for the new thread.
204204- `thread/read` - read a stored thread by id without resuming it; set `includeTurns` to return full turn history.- `thread/read` - read a stored thread by id without resuming it; set `includeTurns` to return full turn history. Returned `thread` objects include runtime `status`.
205205- `thread/list` - page through stored thread logs; supports cursor-based pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filters.- `thread/list` - page through stored thread logs; supports cursor-based pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filters. Returned `thread` objects include runtime `status`.
206- `thread/loaded/list` - list the thread ids currently loaded in memory.206- `thread/loaded/list` - list the thread ids currently loaded in memory.
207207- `thread/archive` - move a thread’s log file into the archived directory; returns `{}` on success.- `thread/archive` - move a thread's log file into the archived directory; returns `{}` on success and emits `thread/archived`.
208208- `thread/unarchive` - restore an archived thread rollout back into the active sessions directory; returns the restored `thread`.- `thread/unarchive` - restore an archived thread rollout back into the active sessions directory; returns the restored `thread` and emits `thread/unarchived`.
209- `thread/status/changed` - notification emitted when a loaded thread's runtime `status` changes.
209- `thread/compact/start` - trigger conversation history compaction for a thread; returns `{}` immediately while progress streams via `turn/*` and `item/*` notifications.210- `thread/compact/start` - trigger conversation history compaction for a thread; returns `{}` immediately while progress streams via `turn/*` and `item/*` notifications.
210- `thread/rollback` - drop the last N turns from the in-memory context and persist a rollback marker; returns the updated `thread`.211- `thread/rollback` - drop the last N turns from the in-memory context and persist a rollback marker; returns the updated `thread`.
211- `turn/start` - add user input to a thread and begin Codex generation; responds with the initial `turn` and streams events. For `collaborationMode`, `settings.developer_instructions: null` means "use built-in instructions for the selected mode."212- `turn/start` - add user input to a thread and begin Codex generation; responds with the initial `turn` and streams events. For `collaborationMode`, `settings.developer_instructions: null` means "use built-in instructions for the selected mode."
223- `tool/requestUserInput` - prompt the user with 1-3 short questions for a tool call (experimental); questions can set `isOther` for a free-form option.224- `tool/requestUserInput` - prompt the user with 1-3 short questions for a tool call (experimental); questions can set `isOther` for a free-form option.
224- `config/mcpServer/reload` - reload MCP server configuration from disk and queue a refresh for loaded threads.225- `config/mcpServer/reload` - reload MCP server configuration from disk and queue a refresh for loaded threads.
225- `mcpServerStatus/list` - list MCP servers, tools, resources, and auth status (cursor + limit pagination).226- `mcpServerStatus/list` - list MCP servers, tools, resources, and auth status (cursor + limit pagination).
226227- `feedback/upload` - submit a feedback report (classification + optional reason/logs + conversation id).- `windowsSandbox/setupStart` - start Windows sandbox setup for `elevated` or `unelevated` mode; returns quickly and later emits `windowsSandbox/setupCompleted`.
228- `feedback/upload` - submit a feedback report (classification + optional reason/logs + conversation id, plus optional `extraLogFiles` attachments).
227- `config/read` - fetch the effective configuration on disk after resolving configuration layering.229- `config/read` - fetch the effective configuration on disk after resolving configuration layering.
228- `config/value/write` - write a single configuration key/value to the user's `config.toml` on disk.230- `config/value/write` - write a single configuration key/value to the user's `config.toml` on disk.
229- `config/batchWrite` - apply configuration edits atomically to the user's `config.toml` on disk.231- `config/batchWrite` - apply configuration edits atomically to the user's `config.toml` on disk.
333 "threadId": "thr_123",335 "threadId": "thr_123",
334 "personality": "friendly"336 "personality": "friendly"
335} }337} }
336338{ "id": 11, "result": { "thread": { "id": "thr_123" } } }{ "id": 11, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes" } } }
337```339```
338 340
339Resuming a thread doesn't update `thread.updatedAt` (or the rollout file's modified time) by itself. The timestamp updates when you start a turn.341Resuming a thread doesn't update `thread.updatedAt` (or the rollout file's modified time) by itself. The timestamp updates when you start a turn.
352{ "method": "thread/started", "params": { "thread": { "id": "thr_456" } } }354{ "method": "thread/started", "params": { "thread": { "id": "thr_456" } } }
353```355```
354 356
357When a user-facing thread title has been set, app-server hydrates `thread.name` on `thread/list`, `thread/read`, `thread/resume`, `thread/unarchive`, and `thread/rollback` responses. `thread/start` and `thread/fork` may omit `name` (or return `null`) until a title is set later.
358
355### Read a stored thread (without resuming)359### Read a stored thread (without resuming)
356 360
357Use `thread/read` when you want stored thread data but don't want to resume the thread or subscribe to its events.361Use `thread/read` when you want stored thread data but don't want to resume the thread or subscribe to its events.
358 362
359- `includeTurns` - when `true`, the response includes the thread's turns; when `false` or omitted, you get the thread summary only.363- `includeTurns` - when `true`, the response includes the thread's turns; when `false` or omitted, you get the thread summary only.
364- Returned `thread` objects include runtime `status` (`notLoaded`, `idle`, `systemError`, or `active` with `activeFlags`).
360 365
361```json366```json
362{ "method": "thread/read", "id": 19, "params": { "threadId": "thr_123", "includeTurns": true } }367{ "method": "thread/read", "id": 19, "params": { "threadId": "thr_123", "includeTurns": true } }
363368{ "id": 19, "result": { "thread": { "id": "thr_123", "turns": [] } } }{ "id": 19, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes", "status": { "type": "notLoaded" }, "turns": [] } } }
364```369```
365 370
366Unlike `thread/resume`, `thread/read` doesn't load the thread into memory or emit `thread/started`.371Unlike `thread/resume`, `thread/read` doesn't load the thread into memory or emit `thread/started`.
400} }405} }
401{ "id": 20, "result": {406{ "id": 20, "result": {
402 "data": [407 "data": [
403408 { "id": "thr_a", "preview": "Create a TUI", "modelProvider": "openai", "createdAt": 1730831111, "updatedAt": 1730831111 }, { "id": "thr_a", "preview": "Create a TUI", "modelProvider": "openai", "createdAt": 1730831111, "updatedAt": 1730831111, "name": "TUI prototype", "status": { "type": "notLoaded" } },
404409 { "id": "thr_b", "preview": "Fix tests", "modelProvider": "openai", "createdAt": 1730750000, "updatedAt": 1730750000 } { "id": "thr_b", "preview": "Fix tests", "modelProvider": "openai", "createdAt": 1730750000, "updatedAt": 1730750000, "status": { "type": "notLoaded" } }
405 ],410 ],
406 "nextCursor": "opaque-token-or-null"411 "nextCursor": "opaque-token-or-null"
407} }412} }
409 414
410When `nextCursor` is `null`, you have reached the final page.415When `nextCursor` is `null`, you have reached the final page.
411 416
417### Track thread status changes
418
419`thread/status/changed` is emitted whenever a loaded thread's runtime status changes. The payload includes `threadId` and the new `status`.
420
421```json
422{
423 "method": "thread/status/changed",
424 "params": {
425 "threadId": "thr_123",
426 "status": { "type": "active", "activeFlags": ["waitingOnApproval"] }
427 }
428}
429```
430
412### List loaded threads431### List loaded threads
413 432
414`thread/loaded/list` returns thread IDs currently loaded in memory.433`thread/loaded/list` returns thread IDs currently loaded in memory.
425```json444```json
426{ "method": "thread/archive", "id": 22, "params": { "threadId": "thr_b" } }445{ "method": "thread/archive", "id": 22, "params": { "threadId": "thr_b" } }
427{ "id": 22, "result": {} }446{ "id": 22, "result": {} }
447{ "method": "thread/archived", "params": { "threadId": "thr_b" } }
428```448```
429 449
430Archived threads won't appear in future calls to `thread/list` unless you pass `archived: true`.450Archived threads won't appear in future calls to `thread/list` unless you pass `archived: true`.
435 455
436```json456```json
437{ "method": "thread/unarchive", "id": 24, "params": { "threadId": "thr_b" } }457{ "method": "thread/unarchive", "id": 24, "params": { "threadId": "thr_b" } }
438458{ "id": 24, "result": { "thread": { "id": "thr_b" } } }{ "id": 24, "result": { "thread": { "id": "thr_b", "name": "Bug bash notes" } } }
459{ "method": "thread/unarchived", "params": { "threadId": "thr_b" } }
439```460```
440 461
441### Trigger thread compaction462### Trigger thread compaction
478}499}
479```500```
480 501
502On macOS, `includePlatformDefaults: true` appends a curated platform-default Seatbelt policy for restricted-read sessions. This improves tool compatibility without broadly allowing all of `/System`.
503
481Examples:504Examples:
482 505
483```json506```json
654- `sandboxPolicy` accepts the same shape used by `turn/start` (for example, `dangerFullAccess`, `readOnly`, `workspaceWrite`, `externalSandbox`).677- `sandboxPolicy` accepts the same shape used by `turn/start` (for example, `dangerFullAccess`, `readOnly`, `workspaceWrite`, `externalSandbox`).
655- When omitted, `timeoutMs` falls back to the server default.678- When omitted, `timeoutMs` falls back to the server default.
656 679
680### Read admin requirements (`configRequirements/read`)
681
682Use `configRequirements/read` to inspect the effective admin requirements loaded from `requirements.toml` and/or MDM.
683
684```json
685{ "method": "configRequirements/read", "id": 52, "params": {} }
686{ "id": 52, "result": {
687 "requirements": {
688 "allowedApprovalPolicies": ["onRequest", "unlessTrusted"],
689 "allowedSandboxModes": ["readOnly", "workspaceWrite"],
690 "network": {
691 "enabled": true,
692 "allowedDomains": ["api.openai.com"],
693 "allowUnixSockets": ["/tmp/example.sock"],
694 "dangerouslyAllowAllUnixSockets": false
695 }
696 }
697} }
698```
699
700`result.requirements` is `null` when no requirements are configured. When present, the optional `network` object carries managed proxy constraints (domain rules, proxy settings, and unix-socket policy).
701
702### Windows sandbox setup (`windowsSandbox/setupStart`)
703
704Custom Windows clients can trigger sandbox setup asynchronously instead of blocking on startup checks.
705
706```json
707{ "method": "windowsSandbox/setupStart", "id": 53, "params": { "mode": "elevated" } }
708{ "id": 53, "result": { "started": true } }
709```
710
711App-server starts setup in the background and later emits a completion notification:
712
713```json
714{
715 "method": "windowsSandbox/setupCompleted",
716 "params": { "mode": "elevated", "success": true, "error": null }
717}
718```
719
720Modes:
721
722- `elevated` - run the elevated Windows sandbox setup path.
723- `unelevated` - run the legacy setup/preflight path.
724
657## Events725## Events
658 726
659727Event notifications are the server-initiated stream for thread lifecycles, turn lifecycles, and the items within them. After you start or resume a thread, keep reading the active transport stream for `thread/started`, `turn/*`, and `item/*` notifications.Event notifications are the server-initiated stream for thread lifecycles, turn lifecycles, and the items within them. After you start or resume a thread, keep reading the active transport stream for `thread/started`, `thread/archived`, `thread/unarchived`, `thread/status/changed`, `turn/*`, and `item/*` notifications.
660 728
661### Notification opt-out729### Notification opt-out
662 730
674- `fuzzyFileSearch/sessionUpdated` - `{ sessionId, query, files }` with the current matches for the active query.742- `fuzzyFileSearch/sessionUpdated` - `{ sessionId, query, files }` with the current matches for the active query.
675- `fuzzyFileSearch/sessionCompleted` - `{ sessionId }` once indexing and matching for that query completes.743- `fuzzyFileSearch/sessionCompleted` - `{ sessionId }` once indexing and matching for that query completes.
676 744
745### Windows sandbox setup events
746
747- `windowsSandbox/setupCompleted` - `{ mode, success, error }` emitted after a `windowsSandbox/setupStart` request finishes.
748
677### Turn events749### Turn events
678 750
679- `turn/started` - `{ turn }` with the turn id, empty `items`, and `status: "inProgress"`.751- `turn/started` - `{ turn }` with the turn id, empty `items`, and `status: "inProgress"`.
689`ThreadItem` is the tagged union carried in turn responses and `item/*` notifications. Common item types include:761`ThreadItem` is the tagged union carried in turn responses and `item/*` notifications. Common item types include:
690 762
691- `userMessage` - `{id, content}` where `content` is a list of user inputs (`text`, `image`, or `localImage`).763- `userMessage` - `{id, content}` where `content` is a list of user inputs (`text`, `image`, or `localImage`).
692764- `agentMessage` - `{id, text}` containing the accumulated agent reply.- `agentMessage` - `{id, text, phase?}` containing the accumulated agent reply. When present, `phase` uses Responses API wire values (`commentary`, `final_answer`).
693- `plan` - `{id, text}` containing proposed plan text in plan mode. Treat the final `plan` item from `item/completed` as authoritative.765- `plan` - `{id, text}` containing proposed plan text in plan mode. Treat the final `plan` item from `item/completed` as authoritative.
694- `reasoning` - `{id, summary, content}` where `summary` holds streamed reasoning summaries and `content` holds raw reasoning blocks.766- `reasoning` - `{id, summary, content}` where `summary` holds streamed reasoning summaries and `content` holds raw reasoning blocks.
695- `commandExecution` - `{id, command, cwd, status, commandActions, aggregatedOutput?, exitCode?, durationMs?}`.767- `commandExecution` - `{id, command, cwd, status, commandActions, aggregatedOutput?, exitCode?, durationMs?}`.
751Order of messages:823Order of messages:
752 824
7531. `item/started` shows the pending `commandExecution` item with `command`, `cwd`, and other fields.8251. `item/started` shows the pending `commandExecution` item with `command`, `cwd`, and other fields.
7548262. `item/commandExecution/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, optional `command`, optional `cwd`, optional `commandActions`, and optional `proposedExecpolicyAmendment`.2. `item/commandExecution/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, optional `command`, optional `cwd`, optional `commandActions`, optional `proposedExecpolicyAmendment`, and optional `networkApprovalContext`.
7553. Client responds with one of the command execution approval decisions above.8273. Client responds with one of the command execution approval decisions above.
7564. `item/completed` returns the final `commandExecution` item with `status: completed | failed | declined`.8284. `item/completed` returns the final `commandExecution` item with `status: completed | failed | declined`.
757 829
830When `networkApprovalContext` is present, the prompt is for managed network access (not a general shell-command approval). The current v2 schema exposes the target `host` and `protocol`; clients should render a network-specific prompt and not rely on `command` being a user-meaningful shell command preview.
831
832Codex deduplicates concurrent network approval prompts by destination (`host`, protocol, and port). The app-server may therefore send one prompt that unblocks multiple queued requests to the same destination, while different ports on the same host are treated separately.
833
758### File change approvals834### File change approvals
759 835
760Order of messages:836Order of messages:
766 842
767### MCP tool-call approvals (apps)843### MCP tool-call approvals (apps)
768 844
769845App (connector) tool calls can also require approval. When an app tool call has side effects, the server may elicit approval with `tool/requestUserInput` and options such as **Accept**, **Decline**, and **Cancel**. If the user declines or cancels, the related `mcpToolCall` item completes with an error instead of running the tool.App (connector) tool calls can also require approval. When an app tool call has side effects, the server may elicit approval with `tool/requestUserInput` and options such as **Accept**, **Decline**, and **Cancel**. Destructive tool annotations always trigger approval even when the tool also advertises less-privileged hints. If the user declines or cancels, the related `mcpToolCall` item completes with an error instead of running the tool.
770 846
771## Skills847## Skills
772 848
863 939
864## Apps (connectors)940## Apps (connectors)
865 941
866942Use `app/list` to fetch available apps. In the CLI/TUI, `/apps` is the user-facing picker; in custom clients, call `app/list` directly. Each entry includes both `isAccessible` (available to the user) and `isEnabled` (enabled in `config.toml`) so clients can distinguish install/access from local enabled state.Use `app/list` to fetch available apps. In the CLI/TUI, `/apps` is the user-facing picker; in custom clients, call `app/list` directly. Each entry includes both `isAccessible` (available to the user) and `isEnabled` (enabled in `config.toml`) so clients can distinguish install/access from local enabled state. App entries can also include optional `branding`, `appMetadata`, and `labels` fields.
867 943
868```json944```json
869{ "method": "app/list", "id": 50, "params": {945{ "method": "app/list", "id": 50, "params": {
879 "name": "Demo App",955 "name": "Demo App",
880 "description": "Example connector for documentation.",956 "description": "Example connector for documentation.",
881 "logoUrl": "https://example.com/demo-app.png",957 "logoUrl": "https://example.com/demo-app.png",
958 "logoUrlDark": null,
959 "distributionChannel": null,
960 "branding": null,
961 "appMetadata": null,
962 "labels": null,
882 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",963 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",
883 "isAccessible": true,964 "isAccessible": true,
884 "isEnabled": true965 "isEnabled": true
904 "name": "Demo App",985 "name": "Demo App",
905 "description": "Example connector for documentation.",986 "description": "Example connector for documentation.",
906 "logoUrl": "https://example.com/demo-app.png",987 "logoUrl": "https://example.com/demo-app.png",
988 "logoUrlDark": null,
989 "distributionChannel": null,
990 "branding": null,
991 "appMetadata": null,
992 "labels": null,
907 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",993 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",
908 "isAccessible": true,994 "isAccessible": true,
909 "isEnabled": true995 "isEnabled": true
936}1022}
937```1023```
938 1024
1025### Config RPC examples for app settings
1026
1027Use `config/read`, `config/value/write`, and `config/batchWrite` to inspect or update app controls in `config.toml`.
1028
1029Read the effective app config shape (including `_default` and per-tool overrides):
1030
1031```json
1032{ "method": "config/read", "id": 60, "params": { "includeLayers": false } }
1033{ "id": 60, "result": {
1034 "config": {
1035 "apps": {
1036 "_default": {
1037 "enabled": true,
1038 "destructive_enabled": true,
1039 "open_world_enabled": true
1040 },
1041 "google_drive": {
1042 "enabled": true,
1043 "destructive_enabled": false,
1044 "default_tools_approval_mode": "prompt",
1045 "tools": {
1046 "files/delete": { "enabled": false, "approval_mode": "approve" }
1047 }
1048 }
1049 }
1050 }
1051} }
1052```
1053
1054Update a single app setting:
1055
1056```json
1057{
1058 "method": "config/value/write",
1059 "id": 61,
1060 "params": {
1061 "keyPath": "apps.google_drive.default_tools_approval_mode",
1062 "value": "prompt",
1063 "mergeStrategy": "replace"
1064 }
1065}
1066```
1067
1068Apply multiple app edits atomically:
1069
1070```json
1071{
1072 "method": "config/batchWrite",
1073 "id": 62,
1074 "params": {
1075 "edits": [
1076 {
1077 "keyPath": "apps._default.destructive_enabled",
1078 "value": false,
1079 "mergeStrategy": "upsert"
1080 },
1081 {
1082 "keyPath": "apps.google_drive.tools.files/delete.approval_mode",
1083 "value": "approve",
1084 "mergeStrategy": "upsert"
1085 }
1086 ]
1087 }
1088}
1089```
1090
939## Auth endpoints1091## Auth endpoints
940 1092
941The JSON-RPC auth/account surface exposes request/response methods plus server-initiated notifications (no `id`). Use these to determine auth state, start or cancel logins, logout, and inspect ChatGPT rate limits.1093The JSON-RPC auth/account surface exposes request/response methods plus server-initiated notifications (no `id`). Use these to determine auth state, start or cancel logins, logout, and inspect ChatGPT rate limits.