Skip to main content

gproxy_protocol/wire/openai/responses/
response.rs

1//! OpenAI Responses response, upstream_docs/openai/docs/Create a model response.md.
2//! Nullable usage/user also follow the native created/in_progress examples in
3//! that reference and Responses.md.
4use super::generate;
5use super::input::{self, present_nullable, present_optional, required_nullable};
6use super::tools;
7use crate::Rest;
8use serde::{Deserialize, Serialize};
9use std::collections::BTreeMap;
10
11pub type GenerateContentResponse = crate::WireResponse<GenerateContentResponseBody>;
12/// Returned instructions have the complete native input union, including history.
13pub type ResponseInstructions = input::Input;
14
15#[derive(
16    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
17)]
18#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
19#[derive(gproxy_protocol_macros::DeclaredFields)]
20#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
21pub struct GenerateContentResponseBody {
22    /// Newer API responses report this even when null; older responses omit it.
23    #[serde(
24        default,
25        deserialize_with = "present_nullable",
26        skip_serializing_if = "Option::is_none"
27    )]
28    pub access_programs: Option<Option<ResponseAccessPrograms>>,
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub prompt_cache_diagnostics: Option<super::diagnostics::PromptCacheDiagnostics>,
31
32    pub id: String,
33    pub created_at: i64,
34    #[wire(required)]
35    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
36    #[serde(deserialize_with = "required_nullable")]
37    pub error: Option<ResponseError>,
38    #[wire(required)]
39    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
40    #[serde(deserialize_with = "required_nullable")]
41    pub incomplete_details: Option<ResponseIncompleteDetails>,
42    #[wire(required)]
43    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
44    #[serde(deserialize_with = "required_nullable")]
45    pub instructions: Option<ResponseInstructions>,
46    #[wire(required)]
47    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
48    #[serde(deserialize_with = "required_nullable")]
49    pub metadata: Option<BTreeMap<String, String>>,
50    pub model: String,
51    pub object: ResponseObject,
52    pub output: Vec<ResponseOutputItem>,
53    pub parallel_tool_calls: bool,
54    #[wire(required)]
55    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
56    #[serde(deserialize_with = "required_nullable")]
57    pub temperature: Option<serde_json::Number>,
58    pub tool_choice: input::ToolChoice,
59    pub tools: Vec<tools::Tool>,
60    #[wire(required)]
61    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
62    #[serde(deserialize_with = "required_nullable")]
63    pub top_p: Option<serde_json::Number>,
64    #[serde(
65        default,
66        deserialize_with = "present_nullable",
67        skip_serializing_if = "Option::is_none"
68    )]
69    pub background: Option<Option<bool>>,
70    #[serde(
71        default,
72        deserialize_with = "present_nullable",
73        skip_serializing_if = "Option::is_none"
74    )]
75    pub completed_at: Option<Option<i64>>,
76    #[serde(
77        default,
78        deserialize_with = "present_nullable",
79        skip_serializing_if = "Option::is_none"
80    )]
81    pub conversation: Option<Option<input::ResponseConversationParam>>,
82    #[serde(
83        default,
84        deserialize_with = "present_nullable",
85        skip_serializing_if = "Option::is_none"
86    )]
87    pub max_output_tokens: Option<Option<i64>>,
88    #[serde(
89        default,
90        deserialize_with = "present_nullable",
91        skip_serializing_if = "Option::is_none"
92    )]
93    pub max_tool_calls: Option<Option<i64>>,
94    #[serde(
95        default,
96        deserialize_with = "present_nullable",
97        skip_serializing_if = "Option::is_none"
98    )]
99    pub moderation: Option<Option<ResponseModerationReport>>,
100    #[serde(
101        default,
102        deserialize_with = "present_nullable",
103        skip_serializing_if = "Option::is_none"
104    )]
105    pub output_text: Option<Option<String>>,
106    #[serde(
107        default,
108        deserialize_with = "present_nullable",
109        skip_serializing_if = "Option::is_none"
110    )]
111    pub previous_response_id: Option<Option<String>>,
112    #[serde(
113        default,
114        deserialize_with = "present_nullable",
115        skip_serializing_if = "Option::is_none"
116    )]
117    pub prompt: Option<Option<generate::ResponsePrompt>>,
118    #[serde(
119        default,
120        deserialize_with = "present_nullable",
121        skip_serializing_if = "Option::is_none"
122    )]
123    pub prompt_cache_key: Option<Option<String>>,
124    #[serde(
125        default,
126        deserialize_with = "present_optional",
127        skip_serializing_if = "Option::is_none"
128    )]
129    pub prompt_cache_options: Option<ResponsePromptCacheOptions>,
130    #[serde(
131        default,
132        deserialize_with = "present_nullable",
133        skip_serializing_if = "Option::is_none"
134    )]
135    pub prompt_cache_retention: Option<Option<generate::PromptCacheRetention>>,
136    #[serde(
137        default,
138        deserialize_with = "present_nullable",
139        skip_serializing_if = "Option::is_none"
140    )]
141    pub reasoning: Option<Option<input::ReasoningConfig>>,
142    #[serde(
143        default,
144        deserialize_with = "present_nullable",
145        skip_serializing_if = "Option::is_none"
146    )]
147    pub safety_identifier: Option<Option<String>>,
148    #[serde(
149        default,
150        deserialize_with = "present_nullable",
151        skip_serializing_if = "Option::is_none"
152    )]
153    pub service_tier: Option<Option<generate::ServiceTier>>,
154    #[serde(
155        default,
156        deserialize_with = "present_optional",
157        skip_serializing_if = "Option::is_none"
158    )]
159    pub status: Option<ResponseStatus>,
160    #[serde(
161        default,
162        deserialize_with = "present_optional",
163        skip_serializing_if = "Option::is_none"
164    )]
165    pub text: Option<input::TextConfig>,
166    #[serde(
167        default,
168        deserialize_with = "present_nullable",
169        skip_serializing_if = "Option::is_none"
170    )]
171    pub top_logprobs: Option<Option<i64>>,
172    #[serde(
173        default,
174        deserialize_with = "present_nullable",
175        skip_serializing_if = "Option::is_none"
176    )]
177    pub truncation: Option<Option<generate::GenerateTruncation>>,
178    #[serde(
179        default,
180        deserialize_with = "present_nullable",
181        skip_serializing_if = "Option::is_none"
182    )]
183    pub usage: Option<Option<ResponseUsage>>,
184    #[serde(
185        default,
186        deserialize_with = "present_nullable",
187        skip_serializing_if = "Option::is_none"
188    )]
189    pub user: Option<Option<String>>,
190    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
191    pub rest: Rest,
192}
193
194#[derive(
195    Debug,
196    Clone,
197    PartialEq,
198    Eq,
199    Serialize,
200    Deserialize,
201    gproxy_protocol_macros::WireBuilder,
202    gproxy_protocol_macros::DeclaredFields,
203)]
204#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
205#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
206pub struct ResponseAccessPrograms {
207    pub cyber: generate::CyberAccessProgram,
208    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
209    pub rest: Rest,
210}
211
212#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
213#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
214#[derive(gproxy_protocol_macros::DeclaredFields)]
215#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
216pub enum ResponseObject {
217    #[serde(rename = "response")]
218    Response,
219}
220
221#[derive(
222    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
223)]
224#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
225#[derive(gproxy_protocol_macros::DeclaredFields)]
226#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
227pub struct ResponseError {
228    #[serde(skip_serializing_if = "Option::is_none")]
229    pub misalignment: Option<MisalignmentDetails>,
230
231    pub code: ResponseErrorCode,
232    pub message: String,
233    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
234    pub type_: Option<String>,
235    #[serde(default, skip_serializing_if = "Option::is_none")]
236    pub param: Option<String>,
237    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
238    pub rest: Rest,
239}
240
241#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
242#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
243#[derive(gproxy_protocol_macros::DeclaredFields)]
244#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
245pub enum ResponseErrorCode {
246    #[serde(rename = "server_error")]
247    ServerError,
248    #[serde(rename = "rate_limit_exceeded")]
249    RateLimitExceeded,
250    #[serde(rename = "invalid_prompt")]
251    InvalidPrompt,
252    #[serde(rename = "data_residency_mismatch")]
253    DataResidencyMismatch,
254    #[serde(rename = "bio_policy")]
255    BioPolicy,
256    #[serde(rename = "vector_store_timeout")]
257    VectorStoreTimeout,
258    #[serde(rename = "invalid_image")]
259    InvalidImage,
260    #[serde(rename = "invalid_image_format")]
261    InvalidImageFormat,
262    #[serde(rename = "invalid_base64_image")]
263    InvalidBase64Image,
264    #[serde(rename = "invalid_image_url")]
265    InvalidImageUrl,
266    #[serde(rename = "image_too_large")]
267    ImageTooLarge,
268    #[serde(rename = "image_too_small")]
269    ImageTooSmall,
270    #[serde(rename = "image_parse_error")]
271    ImageParseError,
272    #[serde(rename = "image_content_policy_violation")]
273    ImageContentPolicyViolation,
274    #[serde(rename = "invalid_image_mode")]
275    InvalidImageMode,
276    #[serde(rename = "image_file_too_large")]
277    ImageFileTooLarge,
278    #[serde(rename = "unsupported_image_media_type")]
279    UnsupportedImageMediaType,
280    #[serde(rename = "empty_image_file")]
281    EmptyImageFile,
282    #[serde(rename = "failed_to_download_image")]
283    FailedToDownloadImage,
284    #[serde(rename = "image_file_not_found")]
285    ImageFileNotFound,
286    /// Preserve backend-specific and future error codes verbatim.
287    #[serde(untagged)]
288    Other(String),
289}
290
291#[derive(
292    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
293)]
294#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
295#[derive(gproxy_protocol_macros::DeclaredFields)]
296#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
297pub struct ResponseIncompleteDetails {
298    #[serde(
299        default,
300        deserialize_with = "present_optional",
301        skip_serializing_if = "Option::is_none"
302    )]
303    pub reason: Option<ResponseIncompleteReason>,
304    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
305    pub rest: Rest,
306}
307
308#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
309#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
310#[derive(gproxy_protocol_macros::DeclaredFields)]
311#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
312pub enum ResponseIncompleteReason {
313    #[serde(rename = "max_messages")]
314    MaxMessages,
315    #[serde(rename = "steered")]
316    Steered,
317    #[serde(rename = "interrupted")]
318    Interrupted,
319    #[serde(rename = "max_output_tokens")]
320    MaxOutputTokens,
321    #[serde(rename = "content_filter")]
322    ContentFilter,
323}
324
325#[derive(
326    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
327)]
328#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
329#[derive(gproxy_protocol_macros::DeclaredFields)]
330#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
331pub struct ResponsePromptCacheOptions {
332    #[serde(
333        default,
334        deserialize_with = "present_nullable",
335        skip_serializing_if = "Option::is_none"
336    )]
337    pub comparison_response_id: Option<Option<String>>,
338
339    pub mode: generate::PromptCachingMode,
340    pub ttl: generate::PromptCacheTtl,
341    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
342    pub rest: Rest,
343}
344
345#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
346#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
347#[derive(gproxy_protocol_macros::DeclaredFields)]
348#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
349pub enum ResponseStatus {
350    #[serde(rename = "completed")]
351    Completed,
352    #[serde(rename = "failed")]
353    Failed,
354    #[serde(rename = "in_progress")]
355    InProgress,
356    #[serde(rename = "cancelled")]
357    Cancelled,
358    #[serde(rename = "queued")]
359    Queued,
360    #[serde(rename = "incomplete")]
361    Incomplete,
362}
363
364#[derive(
365    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
366)]
367#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
368#[derive(gproxy_protocol_macros::DeclaredFields)]
369#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
370pub struct ResponseModerationReport {
371    pub input: ResponseModerationOutcome,
372    pub output: ResponseModerationOutcome,
373    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
374    pub rest: Rest,
375}
376
377#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
378#[serde(untagged)]
379#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
380#[derive(gproxy_protocol_macros::DeclaredFields)]
381#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
382pub enum ResponseModerationOutcome {
383    Result(ResponseModerationResult),
384    Error(ResponseModerationError),
385}
386
387#[derive(
388    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
389)]
390#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
391#[derive(gproxy_protocol_macros::DeclaredFields)]
392#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
393pub struct ResponseModerationResult {
394    pub categories: BTreeMap<String, bool>,
395    pub category_applied_input_types: BTreeMap<String, Vec<ResponseModerationInputType>>,
396    pub category_scores: BTreeMap<String, serde_json::Number>,
397    pub flagged: bool,
398    pub model: String,
399    #[serde(rename = "type")]
400    pub type_: ResponseModerationResultType,
401    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
402    pub rest: Rest,
403}
404
405#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
406#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
407#[derive(gproxy_protocol_macros::DeclaredFields)]
408#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
409pub enum ResponseModerationInputType {
410    #[serde(rename = "text")]
411    Text,
412    #[serde(rename = "image")]
413    Image,
414}
415
416#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
417#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
418#[derive(gproxy_protocol_macros::DeclaredFields)]
419#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
420pub enum ResponseModerationResultType {
421    #[serde(rename = "moderation_result")]
422    ModerationResult,
423}
424
425#[derive(
426    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
427)]
428#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
429#[derive(gproxy_protocol_macros::DeclaredFields)]
430#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
431pub struct ResponseModerationError {
432    pub code: String,
433    pub message: String,
434    #[serde(rename = "type")]
435    pub type_: ResponseModerationErrorType,
436    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
437    pub rest: Rest,
438}
439
440#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
441#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
442#[derive(gproxy_protocol_macros::DeclaredFields)]
443#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
444pub enum ResponseModerationErrorType {
445    #[serde(rename = "error")]
446    Error,
447}
448
449#[derive(
450    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
451)]
452#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
453#[derive(gproxy_protocol_macros::DeclaredFields)]
454#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
455pub struct ResponseUsage {
456    pub input_tokens: i64,
457    pub input_tokens_details: ResponseInputTokensDetails,
458    pub output_tokens: i64,
459    pub output_tokens_details: ResponseOutputTokensDetails,
460    pub total_tokens: i64,
461    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
462    pub rest: Rest,
463}
464
465#[derive(
466    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
467)]
468#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
469#[derive(gproxy_protocol_macros::DeclaredFields)]
470#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
471pub struct ResponseInputTokensDetails {
472    pub cache_write_tokens: i64,
473    pub cached_tokens: i64,
474    #[serde(skip_serializing_if = "Option::is_none")]
475    pub cache_write_tokens_details: Option<CacheWriteTokensDetails>,
476    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
477    pub rest: Rest,
478}
479
480/// Non-overlapping write counts by lifetime; their sum is `cache_write_tokens`.
481/// Source: upstream_docs/openai/docs/Prompt caching.md, Monitor cache performance.
482#[derive(
483    Debug,
484    Clone,
485    PartialEq,
486    Eq,
487    Serialize,
488    Deserialize,
489    gproxy_protocol_macros::WireBuilder,
490    gproxy_protocol_macros::DeclaredFields,
491)]
492#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
493#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
494pub struct CacheWriteTokensDetails {
495    pub ttl_30m_tokens: i64,
496    pub ttl_12h_tokens: i64,
497    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
498    pub rest: Rest,
499}
500
501#[derive(
502    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
503)]
504#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
505#[derive(gproxy_protocol_macros::DeclaredFields)]
506#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
507pub struct ResponseOutputTokensDetails {
508    pub reasoning_tokens: i64,
509    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
510    pub rest: Rest,
511}
512
513/// Native output items; input-only messages/references/triggers are excluded.
514/// Same-shape items are reused; response-specific required fields use separate structs.
515#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
516#[serde(untagged)]
517#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
518#[derive(gproxy_protocol_macros::DeclaredFields)]
519#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
520pub enum ResponseOutputItem {
521    MultiAgentCall(super::multi_agent::ResponseMultiAgentCall),
522    MultiAgentCallOutput(super::multi_agent::ResponseMultiAgentCallOutput),
523    AgentMessage(super::multi_agent::ResponseAgentMessage),
524    ConfigurationUpdate(input::ConfigurationUpdate),
525    Message(input::ResponseOutputMessage),
526    FileSearchCall(input::FileSearchCall),
527    FunctionCall(input::FunctionCall),
528    FunctionCallOutput(ResponseFunctionCallOutput),
529    WebSearchCall(input::WebSearchCall),
530    ComputerCall(input::ComputerCall),
531    ComputerCallOutput(ResponseComputerCallOutput),
532    Reasoning(input::ReasoningItem),
533    Program(input::Program),
534    ProgramOutput(input::ProgramOutput),
535    ToolSearchCall(ResponseToolSearchCall),
536    ToolSearchOutput(ResponseToolSearchOutput),
537    AdditionalTools(ResponseAdditionalTools),
538    Compaction(ResponseCompaction),
539    ImageGenerationCall(input::ImageGenerationCall),
540    CodeInterpreterCall(input::CodeInterpreterCall),
541    LocalShellCall(input::LocalShellCall),
542    LocalShellCallOutput(input::LocalShellCallOutput),
543    ShellCall(ResponseShellCall),
544    ShellCallOutput(ResponseShellCallOutput),
545    ApplyPatchCall(ResponseApplyPatchCall),
546    ApplyPatchCallOutput(ResponseApplyPatchCallOutput),
547    McpCall(input::McpCall),
548    McpListTools(input::McpListTools),
549    McpApprovalRequest(input::McpApprovalRequest),
550    McpApprovalResponse(ResponseMcpApprovalResponse),
551    CustomToolCall(input::CustomToolCall),
552    CustomToolCallOutput(ResponseCustomToolCallOutput),
553}
554
555#[derive(
556    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
557)]
558#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
559#[derive(gproxy_protocol_macros::DeclaredFields)]
560#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
561pub struct ResponseFunctionCallOutput {
562    #[serde(
563        default,
564        deserialize_with = "super::input::present_nullable",
565        skip_serializing_if = "Option::is_none"
566    )]
567    pub agent: Option<Option<super::multi_agent::Agent>>,
568    pub id: String,
569    #[serde(
570        default,
571        deserialize_with = "present_optional",
572        skip_serializing_if = "Option::is_none"
573    )]
574    pub call_id: Option<String>,
575    pub output: input::CustomOutput,
576    pub status: input::ItemStatus,
577    #[serde(rename = "type")]
578    pub type_: input::FunctionCallOutputType,
579    #[serde(
580        default,
581        deserialize_with = "present_nullable",
582        skip_serializing_if = "Option::is_none"
583    )]
584    pub caller: Option<Option<input::Caller>>,
585    #[serde(
586        default,
587        deserialize_with = "present_optional",
588        skip_serializing_if = "Option::is_none"
589    )]
590    pub created_by: Option<String>,
591    #[serde(
592        default,
593        deserialize_with = "present_optional",
594        skip_serializing_if = "Option::is_none"
595    )]
596    pub name: Option<String>,
597    #[serde(
598        default,
599        deserialize_with = "present_optional",
600        skip_serializing_if = "Option::is_none"
601    )]
602    pub namespace: Option<String>,
603    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
604    pub rest: Rest,
605}
606
607#[derive(
608    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
609)]
610#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
611#[derive(gproxy_protocol_macros::DeclaredFields)]
612#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
613pub struct ResponseComputerCallOutput {
614    #[serde(
615        default,
616        deserialize_with = "super::input::present_nullable",
617        skip_serializing_if = "Option::is_none"
618    )]
619    pub agent: Option<Option<super::multi_agent::Agent>>,
620    pub id: String,
621    pub call_id: String,
622    pub output: input::ComputerScreenshot,
623    pub status: ResponseComputerOutputStatus,
624    #[serde(rename = "type")]
625    pub type_: input::ComputerCallOutputType,
626    #[serde(
627        default,
628        deserialize_with = "present_optional",
629        skip_serializing_if = "Option::is_none"
630    )]
631    pub acknowledged_safety_checks: Option<Vec<input::PendingSafetyCheck>>,
632    #[serde(
633        default,
634        deserialize_with = "present_optional",
635        skip_serializing_if = "Option::is_none"
636    )]
637    pub created_by: Option<String>,
638    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
639    pub rest: Rest,
640}
641
642#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
643#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
644#[derive(gproxy_protocol_macros::DeclaredFields)]
645#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
646pub enum ResponseComputerOutputStatus {
647    #[serde(rename = "completed")]
648    Completed,
649    #[serde(rename = "incomplete")]
650    Incomplete,
651    #[serde(rename = "failed")]
652    Failed,
653    #[serde(rename = "in_progress")]
654    InProgress,
655}
656
657#[derive(
658    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
659)]
660#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
661#[derive(gproxy_protocol_macros::DeclaredFields)]
662#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
663pub struct ResponseToolSearchCall {
664    #[serde(
665        default,
666        deserialize_with = "super::input::present_nullable",
667        skip_serializing_if = "Option::is_none"
668    )]
669    pub agent: Option<Option<super::multi_agent::Agent>>,
670    pub id: String,
671    // Source line 10675 explicitly permits unknown (arbitrary JSON) arguments.
672    pub arguments: serde_json::Value,
673    #[wire(required)]
674    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
675    #[serde(deserialize_with = "required_nullable")]
676    pub call_id: Option<String>,
677    pub execution: tools::ToolExecution,
678    pub status: input::ItemStatus,
679    #[serde(rename = "type")]
680    pub type_: input::ToolSearchCallType,
681    #[serde(
682        default,
683        deserialize_with = "present_optional",
684        skip_serializing_if = "Option::is_none"
685    )]
686    pub created_by: Option<String>,
687    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
688    pub rest: Rest,
689}
690
691#[derive(
692    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
693)]
694#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
695#[derive(gproxy_protocol_macros::DeclaredFields)]
696#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
697pub struct ResponseToolSearchOutput {
698    #[serde(
699        default,
700        deserialize_with = "super::input::present_nullable",
701        skip_serializing_if = "Option::is_none"
702    )]
703    pub agent: Option<Option<super::multi_agent::Agent>>,
704    pub id: String,
705    #[wire(required)]
706    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
707    #[serde(deserialize_with = "required_nullable")]
708    pub call_id: Option<String>,
709    pub execution: tools::ToolExecution,
710    pub status: input::ItemStatus,
711    pub tools: Vec<tools::Tool>,
712    #[serde(rename = "type")]
713    pub type_: input::ToolSearchOutputType,
714    #[serde(
715        default,
716        deserialize_with = "present_optional",
717        skip_serializing_if = "Option::is_none"
718    )]
719    pub created_by: Option<String>,
720    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
721    pub rest: Rest,
722}
723
724#[derive(
725    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
726)]
727#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
728#[derive(gproxy_protocol_macros::DeclaredFields)]
729#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
730pub struct ResponseAdditionalTools {
731    #[serde(
732        default,
733        deserialize_with = "super::input::present_nullable",
734        skip_serializing_if = "Option::is_none"
735    )]
736    pub agent: Option<Option<super::multi_agent::Agent>>,
737    pub id: String,
738    pub role: ResponseAdditionalToolsRole,
739    pub tools: Vec<tools::Tool>,
740    #[serde(rename = "type")]
741    pub type_: input::AdditionalToolsType,
742    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
743    pub rest: Rest,
744}
745
746#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
747#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
748#[derive(gproxy_protocol_macros::DeclaredFields)]
749#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
750pub enum ResponseAdditionalToolsRole {
751    #[serde(rename = "unknown")]
752    Unknown,
753    #[serde(rename = "user")]
754    User,
755    #[serde(rename = "assistant")]
756    Assistant,
757    #[serde(rename = "system")]
758    System,
759    #[serde(rename = "critic")]
760    Critic,
761    #[serde(rename = "discriminator")]
762    Discriminator,
763    #[serde(rename = "developer")]
764    Developer,
765    #[serde(rename = "tool")]
766    Tool,
767}
768
769#[derive(
770    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
771)]
772#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
773#[derive(gproxy_protocol_macros::DeclaredFields)]
774#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
775pub struct ResponseCompaction {
776    #[serde(
777        default,
778        deserialize_with = "super::input::present_nullable",
779        skip_serializing_if = "Option::is_none"
780    )]
781    pub agent: Option<Option<super::multi_agent::Agent>>,
782    pub id: String,
783    pub encrypted_content: String,
784    #[serde(rename = "type")]
785    pub type_: input::CompactionType,
786    #[serde(
787        default,
788        deserialize_with = "present_optional",
789        skip_serializing_if = "Option::is_none"
790    )]
791    pub created_by: Option<String>,
792    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
793    pub rest: Rest,
794}
795
796#[derive(
797    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
798)]
799#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
800#[derive(gproxy_protocol_macros::DeclaredFields)]
801#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
802pub struct ResponseShellCall {
803    #[serde(
804        default,
805        deserialize_with = "super::input::present_nullable",
806        skip_serializing_if = "Option::is_none"
807    )]
808    pub agent: Option<Option<super::multi_agent::Agent>>,
809    pub id: String,
810    pub action: ResponseShellAction,
811    pub call_id: String,
812    #[wire(required)]
813    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
814    #[serde(deserialize_with = "required_nullable")]
815    pub environment: Option<ResponseShellEnvironment>,
816    pub status: input::ItemStatus,
817    #[serde(rename = "type")]
818    pub type_: input::ShellCallType,
819    #[serde(
820        default,
821        deserialize_with = "present_nullable",
822        skip_serializing_if = "Option::is_none"
823    )]
824    pub caller: Option<Option<input::Caller>>,
825    #[serde(
826        default,
827        deserialize_with = "present_optional",
828        skip_serializing_if = "Option::is_none"
829    )]
830    pub created_by: Option<String>,
831    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
832    pub rest: Rest,
833}
834
835#[derive(
836    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
837)]
838#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
839#[derive(gproxy_protocol_macros::DeclaredFields)]
840#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
841pub struct ResponseShellAction {
842    pub commands: Vec<String>,
843    #[wire(required)]
844    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
845    #[serde(deserialize_with = "required_nullable")]
846    pub max_output_length: Option<i64>,
847    #[wire(required)]
848    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
849    #[serde(deserialize_with = "required_nullable")]
850    pub timeout_ms: Option<i64>,
851    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
852    pub rest: Rest,
853}
854
855#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
856#[serde(untagged)]
857#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
858#[derive(gproxy_protocol_macros::DeclaredFields)]
859#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
860pub enum ResponseShellEnvironment {
861    Local(ResponseLocalEnvironment),
862    Reference(tools::ShellContainerReference),
863}
864
865#[derive(
866    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
867)]
868#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
869#[derive(gproxy_protocol_macros::DeclaredFields)]
870#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
871pub struct ResponseLocalEnvironment {
872    #[serde(rename = "type")]
873    pub type_: tools::ShellLocalType,
874    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
875    pub rest: Rest,
876}
877
878#[derive(
879    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
880)]
881#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
882#[derive(gproxy_protocol_macros::DeclaredFields)]
883#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
884pub struct ResponseShellCallOutput {
885    #[serde(
886        default,
887        deserialize_with = "super::input::present_nullable",
888        skip_serializing_if = "Option::is_none"
889    )]
890    pub agent: Option<Option<super::multi_agent::Agent>>,
891    pub id: String,
892    pub call_id: String,
893    #[wire(required)]
894    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
895    #[serde(deserialize_with = "required_nullable")]
896    pub max_output_length: Option<i64>,
897    pub output: Vec<ResponseShellOutputContent>,
898    pub status: input::ItemStatus,
899    #[serde(rename = "type")]
900    pub type_: input::ShellCallOutputType,
901    #[serde(
902        default,
903        deserialize_with = "present_nullable",
904        skip_serializing_if = "Option::is_none"
905    )]
906    pub caller: Option<Option<input::Caller>>,
907    #[serde(
908        default,
909        deserialize_with = "present_optional",
910        skip_serializing_if = "Option::is_none"
911    )]
912    pub created_by: Option<String>,
913    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
914    pub rest: Rest,
915}
916
917#[derive(
918    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
919)]
920#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
921#[derive(gproxy_protocol_macros::DeclaredFields)]
922#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
923pub struct ResponseShellOutputContent {
924    pub outcome: input::ShellOutputOutcome,
925    pub stderr: String,
926    pub stdout: String,
927    #[serde(
928        default,
929        deserialize_with = "present_optional",
930        skip_serializing_if = "Option::is_none"
931    )]
932    pub created_by: Option<String>,
933    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
934    pub rest: Rest,
935}
936
937#[derive(
938    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
939)]
940#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
941#[derive(gproxy_protocol_macros::DeclaredFields)]
942#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
943pub struct ResponseApplyPatchCall {
944    #[serde(
945        default,
946        deserialize_with = "super::input::present_nullable",
947        skip_serializing_if = "Option::is_none"
948    )]
949    pub agent: Option<Option<super::multi_agent::Agent>>,
950    pub id: String,
951    pub call_id: String,
952    pub operation: input::ApplyPatchOperation,
953    pub status: input::ApplyPatchStatus,
954    #[serde(rename = "type")]
955    pub type_: input::ApplyPatchCallType,
956    #[serde(
957        default,
958        deserialize_with = "present_nullable",
959        skip_serializing_if = "Option::is_none"
960    )]
961    pub caller: Option<Option<input::Caller>>,
962    #[serde(
963        default,
964        deserialize_with = "present_optional",
965        skip_serializing_if = "Option::is_none"
966    )]
967    pub created_by: Option<String>,
968    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
969    pub rest: Rest,
970}
971
972#[derive(
973    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
974)]
975#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
976#[derive(gproxy_protocol_macros::DeclaredFields)]
977#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
978pub struct ResponseApplyPatchCallOutput {
979    #[serde(
980        default,
981        deserialize_with = "super::input::present_nullable",
982        skip_serializing_if = "Option::is_none"
983    )]
984    pub agent: Option<Option<super::multi_agent::Agent>>,
985    pub id: String,
986    pub call_id: String,
987    pub status: input::ApplyPatchOutputStatus,
988    #[serde(rename = "type")]
989    pub type_: input::ApplyPatchCallOutputType,
990    #[serde(
991        default,
992        deserialize_with = "present_nullable",
993        skip_serializing_if = "Option::is_none"
994    )]
995    pub caller: Option<Option<input::Caller>>,
996    #[serde(
997        default,
998        deserialize_with = "present_optional",
999        skip_serializing_if = "Option::is_none"
1000    )]
1001    pub created_by: Option<String>,
1002    #[serde(
1003        default,
1004        deserialize_with = "present_nullable",
1005        skip_serializing_if = "Option::is_none"
1006    )]
1007    pub output: Option<Option<String>>,
1008    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1009    pub rest: Rest,
1010}
1011
1012#[derive(
1013    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1014)]
1015#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1016#[derive(gproxy_protocol_macros::DeclaredFields)]
1017#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1018pub struct ResponseMcpApprovalResponse {
1019    #[serde(
1020        default,
1021        deserialize_with = "super::input::present_nullable",
1022        skip_serializing_if = "Option::is_none"
1023    )]
1024    pub agent: Option<Option<super::multi_agent::Agent>>,
1025    pub id: String,
1026    pub approval_request_id: String,
1027    pub approve: bool,
1028    #[serde(rename = "type")]
1029    pub type_: input::McpApprovalResponseType,
1030    #[serde(
1031        default,
1032        deserialize_with = "present_nullable",
1033        skip_serializing_if = "Option::is_none"
1034    )]
1035    pub reason: Option<Option<String>>,
1036    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1037    pub rest: Rest,
1038}
1039
1040#[derive(
1041    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1042)]
1043#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1044#[derive(gproxy_protocol_macros::DeclaredFields)]
1045#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1046pub struct ResponseCustomToolCallOutput {
1047    #[serde(
1048        default,
1049        deserialize_with = "super::input::present_nullable",
1050        skip_serializing_if = "Option::is_none"
1051    )]
1052    pub agent: Option<Option<super::multi_agent::Agent>>,
1053    pub id: String,
1054    pub call_id: String,
1055    pub output: input::CustomOutput,
1056    pub status: input::ItemStatus,
1057    #[serde(rename = "type")]
1058    pub type_: input::CustomToolCallOutputType,
1059    #[serde(
1060        default,
1061        deserialize_with = "present_nullable",
1062        skip_serializing_if = "Option::is_none"
1063    )]
1064    pub caller: Option<Option<input::Caller>>,
1065    #[serde(
1066        default,
1067        deserialize_with = "present_optional",
1068        skip_serializing_if = "Option::is_none"
1069    )]
1070    pub created_by: Option<String>,
1071    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1072    pub rest: Rest,
1073}
1074
1075#[derive(
1076    Debug,
1077    Clone,
1078    PartialEq,
1079    Eq,
1080    Serialize,
1081    Deserialize,
1082    gproxy_protocol_macros::WireBuilder,
1083    gproxy_protocol_macros::DeclaredFields,
1084)]
1085#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1086#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1087pub struct MisalignmentDetails {
1088    #[serde(skip_serializing_if = "Option::is_none")]
1089    pub detailed_explanation: Option<String>,
1090    #[serde(skip_serializing_if = "Option::is_none")]
1091    pub error_type: Option<String>,
1092    #[serde(skip_serializing_if = "Option::is_none")]
1093    pub steer: Option<MisalignmentSteer>,
1094    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1095    pub rest: Rest,
1096}
1097
1098#[derive(
1099    Debug,
1100    Clone,
1101    PartialEq,
1102    Eq,
1103    Serialize,
1104    Deserialize,
1105    gproxy_protocol_macros::WireBuilder,
1106    gproxy_protocol_macros::DeclaredFields,
1107)]
1108#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1109#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1110pub struct MisalignmentSteer {
1111    pub message: String,
1112    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1113    pub rest: Rest,
1114}
1115
1116impl ResponseOutputItem {
1117    pub fn agent(&self) -> Option<&super::multi_agent::Agent> {
1118        match self {
1119            Self::ConfigurationUpdate(v) => v.agent.as_ref().and_then(Option::as_ref),
1120            Self::Message(v) => v.agent.as_ref().and_then(Option::as_ref),
1121            Self::FileSearchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1122            Self::FunctionCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1123            Self::FunctionCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1124            Self::WebSearchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1125            Self::ComputerCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1126            Self::ComputerCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1127            Self::Reasoning(v) => v.agent.as_ref().and_then(Option::as_ref),
1128            Self::Program(v) => v.agent.as_ref().and_then(Option::as_ref),
1129            Self::ProgramOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1130            Self::ToolSearchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1131            Self::ToolSearchOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1132            Self::AdditionalTools(v) => v.agent.as_ref().and_then(Option::as_ref),
1133            Self::Compaction(v) => v.agent.as_ref().and_then(Option::as_ref),
1134            Self::ImageGenerationCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1135            Self::CodeInterpreterCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1136            Self::LocalShellCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1137            Self::LocalShellCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1138            Self::ShellCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1139            Self::ShellCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1140            Self::ApplyPatchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1141            Self::ApplyPatchCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1142            Self::McpCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1143            Self::McpListTools(v) => v.agent.as_ref().and_then(Option::as_ref),
1144            Self::McpApprovalRequest(v) => v.agent.as_ref().and_then(Option::as_ref),
1145            Self::McpApprovalResponse(v) => v.agent.as_ref().and_then(Option::as_ref),
1146            Self::CustomToolCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1147            Self::CustomToolCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1148            Self::MultiAgentCall(v) => v.agent.as_ref().and_then(Option::as_ref),
1149            Self::MultiAgentCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
1150            Self::AgentMessage(v) => v.agent.as_ref().and_then(Option::as_ref),
1151        }
1152    }
1153}
1154
1155impl ResponseOutputItem {
1156    pub(crate) fn set_agent(&mut self, agent: super::multi_agent::Agent) {
1157        match self {
1158            Self::MultiAgentCall(v) => v.agent = Some(Some(agent)),
1159            Self::MultiAgentCallOutput(v) => v.agent = Some(Some(agent)),
1160            Self::AgentMessage(v) => v.agent = Some(Some(agent)),
1161            Self::ConfigurationUpdate(v) => v.agent = Some(Some(agent)),
1162            Self::Message(v) => v.agent = Some(Some(agent)),
1163            Self::FileSearchCall(v) => v.agent = Some(Some(agent)),
1164            Self::FunctionCall(v) => v.agent = Some(Some(agent)),
1165            Self::FunctionCallOutput(v) => v.agent = Some(Some(agent)),
1166            Self::WebSearchCall(v) => v.agent = Some(Some(agent)),
1167            Self::ComputerCall(v) => v.agent = Some(Some(agent)),
1168            Self::ComputerCallOutput(v) => v.agent = Some(Some(agent)),
1169            Self::Reasoning(v) => v.agent = Some(Some(agent)),
1170            Self::Program(v) => v.agent = Some(Some(agent)),
1171            Self::ProgramOutput(v) => v.agent = Some(Some(agent)),
1172            Self::ToolSearchCall(v) => v.agent = Some(Some(agent)),
1173            Self::ToolSearchOutput(v) => v.agent = Some(Some(agent)),
1174            Self::AdditionalTools(v) => v.agent = Some(Some(agent)),
1175            Self::Compaction(v) => v.agent = Some(Some(agent)),
1176            Self::ImageGenerationCall(v) => v.agent = Some(Some(agent)),
1177            Self::CodeInterpreterCall(v) => v.agent = Some(Some(agent)),
1178            Self::LocalShellCall(v) => v.agent = Some(Some(agent)),
1179            Self::LocalShellCallOutput(v) => v.agent = Some(Some(agent)),
1180            Self::ShellCall(v) => v.agent = Some(Some(agent)),
1181            Self::ShellCallOutput(v) => v.agent = Some(Some(agent)),
1182            Self::ApplyPatchCall(v) => v.agent = Some(Some(agent)),
1183            Self::ApplyPatchCallOutput(v) => v.agent = Some(Some(agent)),
1184            Self::McpCall(v) => v.agent = Some(Some(agent)),
1185            Self::McpListTools(v) => v.agent = Some(Some(agent)),
1186            Self::McpApprovalRequest(v) => v.agent = Some(Some(agent)),
1187            Self::McpApprovalResponse(v) => v.agent = Some(Some(agent)),
1188            Self::CustomToolCall(v) => v.agent = Some(Some(agent)),
1189            Self::CustomToolCallOutput(v) => v.agent = Some(Some(agent)),
1190        }
1191    }
1192}