//! One model response on an ephemeral fork that inherits the source's configuration and context. use super::ThreadSource; use crate::JsonSchema; use crate::RequestId; use crate::TS; use codex_protocol::openai_models::ReasoningEffort; use serde::Deserialize; use serde::Serialize; use std::collections::HashMap; #[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 turn, which must be finished (completed, failed, or interrupted) unless `allowInProgressTurn` is true. pub expected_turn_id: String, /// Allow sampling the latest turn before it finishes. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub allow_in_progress_turn: bool, pub prompt: String, /// Override the model for this sample. /// Omit or pass `null` to inherit the source thread's model. #[ts(optional = nullable)] pub model: Option, /// Applied only when the provider and model support cache-preserving reasoning-effort updates. #[ts(optional = nullable)] pub effort: Option, #[ts(optional = nullable)] pub thread_source: Option, #[ts(optional = nullable)] pub turn_trigger: Option, /// Optional metadata to enrich Codex's ResponsesAPI turn metadata. #[ts(optional = nullable)] pub responsesapi_client_metadata: Option>, /// Disable MCP servers when the inherited window uses incremental tools on Responses Lite. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub disable_mcp: bool, /// Override upstream interruption on cancellation for this sample; otherwise inherit the parent. #[ts(optional = nullable)] pub interrupt_on_cancel: Option, } #[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, pub input_tokens: Option, pub cached_input_tokens: Option, pub output_tokens: Option, } #[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 {}