mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
## What changed Add the experimental `thread/sample/cancel` request with a `requestId` identifying a `thread/sample` request on the same connection. Cancellation returns an empty response, stops the matching sample with `sample canceled`, and cleans up its ephemeral fork. Repeated cancellation and unknown request IDs are harmless no-ops; other request types are unaffected. ## Testing Add coverage for connection and request ID isolation, request type filtering, and repeated cancellation. Extend the sample integration test to verify cancellation keeps the parent responsive and reclaims the child thread. GitOrigin-RevId: 92d12e5c0190e1d3b06cb482543615a3ec77bdc8
49 lines
1.7 KiB
Rust
49 lines
1.7 KiB
Rust
//! One model response on an ephemeral fork that inherits the source's configuration and context.
|
|
|
|
use crate::JsonSchema;
|
|
use crate::RequestId;
|
|
use crate::TS;
|
|
use codex_protocol::openai_models::ReasoningEffort;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ThreadSampleParams {
|
|
pub thread_id: String,
|
|
/// The loaded source's latest completed turn. Stale or active sources are rejected.
|
|
pub expected_turn_id: String,
|
|
pub prompt: String,
|
|
/// Applied only when the provider and model support cache-preserving reasoning-effort updates.
|
|
#[ts(optional = nullable)]
|
|
pub effort: Option<ReasoningEffort>,
|
|
#[ts(optional = nullable)]
|
|
pub turn_trigger: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ThreadSampleResponse {
|
|
pub source_turn_id: String,
|
|
pub response_id: String,
|
|
/// Assistant text from the response, or null if it attempted a tool call or completed without text.
|
|
pub text: Option<String>,
|
|
pub input_tokens: Option<i64>,
|
|
pub cached_input_tokens: Option<i64>,
|
|
pub output_tokens: Option<i64>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ThreadSampleCancelParams {
|
|
pub request_id: RequestId,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ThreadSampleCancelResponse {}
|