Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

app-server: document thread and turn IDs are UUID7 (#27714)

Owen Lin8d80b0176a35
diff --git a/codex-rs/app-server-protocol/schema/json/ServerNotification.json b/codex-rs/app-server-protocol/schema/json/ServerNotification.json
index b79e3cb13f..3f3263b3a1 100644
--- a/codex-rs/app-server-protocol/schema/json/ServerNotification.json
+++ b/codex-rs/app-server-protocol/schema/json/ServerNotification.json
@@ -3626,6 +3626,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -5111,6 +5112,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
index 597fd5a1b8..82b874be1f 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
@@ -16831,6 +16831,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -19699,6 +19700,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
index 3af48cc6c0..81e427ec88 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
@@ -14610,6 +14610,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -17478,6 +17479,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json
index 545ae64d4a..4eb3489663 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json
@@ -1438,6 +1438,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json
index c19251667a..97d0746049 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json
@@ -1059,6 +1059,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -2017,6 +2018,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json
index 9925c5411e..d06ee75c42 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json
@@ -865,6 +865,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -1823,6 +1824,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json
index 1e142947ed..ed63f14984 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json
@@ -865,6 +865,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -1823,6 +1824,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json
index 532a712807..51b3dbb278 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json
@@ -865,6 +865,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -1823,6 +1824,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json
index 1a3b22f12c..de5cfb147a 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json
@@ -1059,6 +1059,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -2017,6 +2018,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json
index 9f394b31cf..fe235b41d1 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json
@@ -865,6 +865,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -1823,6 +1824,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json
index a754c6bc0f..5f9f0a72ae 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json
@@ -1059,6 +1059,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -2017,6 +2018,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json
index 22801809cd..457b081cdb 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json
@@ -865,6 +865,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -1823,6 +1824,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json
index 3009e86e70..079bd0f8f6 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json
@@ -865,6 +865,7 @@
"description": "Optional Git metadata captured when the thread was created."
},
"id": {
+ "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
"type": "string"
},
"modelProvider": {
@@ -1823,6 +1824,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json
index b9a940157c..fb703d511f 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json
@@ -1438,6 +1438,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json
index da10713dd1..a8a9d5a62b 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json
@@ -1438,6 +1438,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json
index 6b93498221..becf0d87cd 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json
@@ -1438,6 +1438,7 @@
"description": "Only populated when the Turn's status is failed."
},
"id": {
+ "description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
"type": "string"
},
"items": {
diff --git a/codex-rs/app-server-protocol/schema/typescript/ThreadId.ts b/codex-rs/app-server-protocol/schema/typescript/ThreadId.ts
index bfb3b4b4d7..801ffb35e4 100644
--- a/codex-rs/app-server-protocol/schema/typescript/ThreadId.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/ThreadId.ts
@@ -2,4 +2,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+/**
+ * Identifier for a Codex thread.
+ *
+ * Codex-generated thread IDs are UUIDv7, and some use cases rely on that.
+ */
export type ThreadId = string;
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts b/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts
index 1c288ccbd4..06df74f0ad 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts
@@ -8,7 +8,11 @@ import type { ThreadSource } from "./ThreadSource";
import type { ThreadStatus } from "./ThreadStatus";
import type { Turn } from "./Turn";
-export type Thread = { id: string,
+export type Thread = {
+/**
+ * Identifier for this thread. Codex-generated thread IDs are UUIDv7.
+ */
+id: string,
/**
* Session id shared by threads that belong to the same session tree.
*/
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/Turn.ts b/codex-rs/app-server-protocol/schema/typescript/v2/Turn.ts
index 6505ec345f..b8680256d1 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/Turn.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/Turn.ts
@@ -6,7 +6,11 @@ import type { TurnError } from "./TurnError";
import type { TurnItemsView } from "./TurnItemsView";
import type { TurnStatus } from "./TurnStatus";
-export type Turn = { id: string,
+export type Turn = {
+/**
+ * Identifier for this turn. Codex-generated turn IDs are UUIDv7.
+ */
+id: string,
/**
* Thread items currently included in this turn payload.
*/
diff --git a/codex-rs/app-server-protocol/src/protocol/v2/thread_data.rs b/codex-rs/app-server-protocol/src/protocol/v2/thread_data.rs
index 52a8d7017a..176172dd8c 100644
--- a/codex-rs/app-server-protocol/src/protocol/v2/thread_data.rs
+++ b/codex-rs/app-server-protocol/src/protocol/v2/thread_data.rs
@@ -133,6 +133,7 @@ pub struct GitInfo {
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct Thread {
+ /// Identifier for this thread. Codex-generated thread IDs are UUIDv7.
pub id: String,
/// Session id shared by threads that belong to the same session tree.
pub session_id: String,
@@ -186,6 +187,7 @@ pub struct Thread {
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct Turn {
+ /// Identifier for this turn. Codex-generated turn IDs are UUIDv7.
pub id: String,
/// Thread items currently included in this turn payload.
pub items: Vec<ThreadItem>,
diff --git a/codex-rs/core/src/session/mod.rs b/codex-rs/core/src/session/mod.rs
index e452e36757..7c5b853d75 100644
--- a/codex-rs/core/src/session/mod.rs
+++ b/codex-rs/core/src/session/mod.rs
@@ -724,7 +724,7 @@ impl Codex {
op: Op,
trace: Option<W3cTraceContext>,
) -> CodexResult<String> {
- let id = Uuid::now_v7().to_string();
+ let id = new_submission_id();
let sub = Submission {
id: id.clone(),
op,
@@ -742,7 +742,7 @@ impl Codex {
client_user_message_id: Option<String>,
) -> CodexResult<String> {
debug_assert!(matches!(op, Op::UserInput { .. }));
- let id = Uuid::now_v7().to_string();
+ let id = new_submission_id();
let sub = Submission {
id: id.clone(),
op,
@@ -869,6 +869,15 @@ impl Codex {
}
}
+/// Generate a core submission ID. App-server exposes submission IDs that
+/// create turns as a public-facing turn ID.
+///
+/// Some use cases take advantage of the fact that these are UUID7 which
+/// encodes a timestamp, so think carefully before changing this.
+fn new_submission_id() -> String {
+ Uuid::now_v7().to_string()
+}
+
fn get_service_tier(
configured_service_tier: Option<String>,
fast_mode_enabled: bool,
diff --git a/codex-rs/protocol/src/thread_id.rs b/codex-rs/protocol/src/thread_id.rs
index d6e9a8825e..dcfedc7f52 100644
--- a/codex-rs/protocol/src/thread_id.rs
+++ b/codex-rs/protocol/src/thread_id.rs
@@ -10,6 +10,9 @@ use uuid::Uuid;
#[derive(Debug, Clone, Copy, PartialEq, Eq, TS, Hash)]
#[ts(type = "string")]
+/// Identifier for a Codex thread.
+///
+/// Codex-generated thread IDs are UUIDv7, and some use cases rely on that.
pub struct ThreadId {
pub(crate) uuid: Uuid,
}