mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Add experimental thread queue APIs to app server (#38456)
## What changed - Add experimental `thread/queue/add`, `list`, `update`, `delete`, `reorder`, and `start` requests for persistent queued user submissions. - Automatically dispatch queued submissions in FIFO order after completed or failed turns, while leaving the queue paused after interruption. - Emit `thread/queue/changed` notifications and expose paginated queue contents with stable submission and client message IDs. - Export the new protocol types through the generated JSON Schema and TypeScript bindings. ## Testing - Add app-server integration coverage for capability gating, CRUD, pagination, capacity limits, notifications, automatic dispatch, cold-thread resume, interruption, and explicit queue starts. GitOrigin-RevId: 89caf5577192199bda77cf6c372a59d26cdd910e
This commit is contained in:
1 parent
4d9f3021c8
commit
9341b38310
35 files changed
+1952
-105
No files matched your search
@@ -574,6 +574,42 @@ client_request_definitions! {
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadGoalClearResponse,
|
||||
},
|
||||
#[experimental("thread/queue/add")]
|
||||
ThreadQueueAdd => "thread/queue/add" {
|
||||
params: v2::ThreadQueueAddParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadQueueAddResponse,
|
||||
},
|
||||
#[experimental("thread/queue/list")]
|
||||
ThreadQueueList => "thread/queue/list" {
|
||||
params: v2::ThreadQueueListParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadQueueListResponse,
|
||||
},
|
||||
#[experimental("thread/queue/update")]
|
||||
ThreadQueueUpdate => "thread/queue/update" {
|
||||
params: v2::ThreadQueueUpdateParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadQueueUpdateResponse,
|
||||
},
|
||||
#[experimental("thread/queue/delete")]
|
||||
ThreadQueueDelete => "thread/queue/delete" {
|
||||
params: v2::ThreadQueueDeleteParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadQueueDeleteResponse,
|
||||
},
|
||||
#[experimental("thread/queue/reorder")]
|
||||
ThreadQueueReorder => "thread/queue/reorder" {
|
||||
params: v2::ThreadQueueReorderParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadQueueReorderResponse,
|
||||
},
|
||||
#[experimental("thread/queue/start")]
|
||||
ThreadQueueStart => "thread/queue/start" {
|
||||
params: v2::ThreadQueueStartParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadQueueStartResponse,
|
||||
},
|
||||
ThreadMetadataUpdate => "thread/metadata/update" {
|
||||
params: v2::ThreadMetadataUpdateParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
@@ -1723,6 +1759,8 @@ server_notification_definitions! {
|
||||
ThreadNameUpdated => "thread/name/updated" (v2::ThreadNameUpdatedNotification),
|
||||
ThreadGoalUpdated => "thread/goal/updated" (v2::ThreadGoalUpdatedNotification),
|
||||
ThreadGoalCleared => "thread/goal/cleared" (v2::ThreadGoalClearedNotification),
|
||||
#[experimental("thread/queue/changed")]
|
||||
ThreadQueueChanged => "thread/queue/changed" (v2::ThreadQueueChangedNotification),
|
||||
#[experimental("thread/environment/connected")]
|
||||
EnvironmentConnected => "thread/environment/connected" (v2::EnvironmentConnectionNotification),
|
||||
#[experimental("thread/environment/disconnected")]
|
||||
|
||||
@@ -12,6 +12,7 @@ use super::ThreadSource;
|
||||
use super::Turn;
|
||||
use super::TurnEnvironmentParams;
|
||||
use super::TurnItemsView;
|
||||
use super::UserInput;
|
||||
use super::shared::v2_enum_from_core;
|
||||
use crate::JsonSchema;
|
||||
use crate::TS;
|
||||
@@ -857,6 +858,113 @@ pub struct ThreadGoalClearResponse {
|
||||
pub cleared: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct QueuedSubmission {
|
||||
pub id: String,
|
||||
pub input: Vec<UserInput>,
|
||||
pub client_user_message_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueAddParams {
|
||||
pub thread_id: String,
|
||||
pub input: Vec<UserInput>,
|
||||
pub client_user_message_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueAddResponse {
|
||||
pub queued_submission: QueuedSubmission,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueListParams {
|
||||
pub thread_id: String,
|
||||
/// Opaque pagination cursor returned by a previous call.
|
||||
#[ts(optional = nullable)]
|
||||
pub cursor: Option<String>,
|
||||
/// Optional page size; defaults to the standard thread-list page size.
|
||||
#[ts(optional = nullable)]
|
||||
pub limit: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueListResponse {
|
||||
pub data: Vec<QueuedSubmission>,
|
||||
/// Opaque cursor for the next page, or `null` when no submissions remain.
|
||||
pub next_cursor: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueUpdateParams {
|
||||
pub thread_id: String,
|
||||
pub queued_submission_id: String,
|
||||
pub input: Vec<UserInput>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueUpdateResponse {
|
||||
pub queued_submission: QueuedSubmission,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueDeleteParams {
|
||||
pub thread_id: String,
|
||||
pub queued_submission_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueDeleteResponse {
|
||||
pub deleted: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueReorderParams {
|
||||
pub thread_id: String,
|
||||
pub queued_submission_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueReorderResponse {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueStartParams {
|
||||
pub thread_id: String,
|
||||
#[ts(optional = nullable)]
|
||||
pub queued_submission_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueStartResponse {
|
||||
pub turn: Turn,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
@@ -1768,6 +1876,13 @@ pub struct ThreadGoalClearedNotification {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadQueueChangedNotification {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
/// Deprecated: Use `ContextCompaction` item type instead.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
Reference in new issue
Block a user