Skip to main content

gproxy_protocol/wire/openai/responses/
multi_agent.rs

1//! Responses Multi-agent beta: hosted collaboration and in-flight tool outputs.
2//! Source: https://developers.openai.com/api/reference/resources/beta/subresources/responses
3//! Guide: https://developers.openai.com/api/docs/guides/responses-multi-agent
4use super::input;
5use crate::Rest;
6use serde::{Deserialize, Serialize};
7
8#[derive(
9    Debug,
10    Clone,
11    PartialEq,
12    Eq,
13    Serialize,
14    Deserialize,
15    gproxy_protocol_macros::WireBuilder,
16    gproxy_protocol_macros::DeclaredFields,
17)]
18#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
19pub struct Agent {
20    pub agent_name: String,
21    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
22    pub rest: Rest,
23}
24
25#[derive(
26    Debug,
27    Clone,
28    PartialEq,
29    Eq,
30    Serialize,
31    Deserialize,
32    gproxy_protocol_macros::WireBuilder,
33    gproxy_protocol_macros::DeclaredFields,
34)]
35#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
36pub struct MultiAgentConfig {
37    pub enabled: bool,
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub max_concurrent_subagents: Option<serde_json::Number>,
40    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
41    pub rest: Rest,
42}
43
44#[derive(
45    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
46)]
47#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
48#[serde(rename_all = "snake_case")]
49pub enum Action {
50    SpawnAgent,
51    InterruptAgent,
52    ListAgents,
53    SendMessage,
54    FollowupTask,
55    WaitAgent,
56}
57
58#[derive(
59    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
60)]
61#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
62pub enum MultiAgentCallType {
63    #[serde(rename = "multi_agent_call")]
64    MultiAgentCall,
65}
66
67#[derive(
68    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
69)]
70#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
71pub enum MultiAgentCallOutputType {
72    #[serde(rename = "multi_agent_call_output")]
73    MultiAgentCallOutput,
74}
75
76#[derive(
77    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
78)]
79#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
80pub enum AgentMessageType {
81    #[serde(rename = "agent_message")]
82    AgentMessage,
83}
84
85#[derive(
86    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
87)]
88#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
89pub enum EncryptedContentType {
90    #[serde(rename = "encrypted_content")]
91    EncryptedContent,
92}
93
94#[derive(
95    Debug,
96    Clone,
97    PartialEq,
98    Eq,
99    Serialize,
100    Deserialize,
101    gproxy_protocol_macros::WireBuilder,
102    gproxy_protocol_macros::DeclaredFields,
103)]
104#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
105pub struct MultiAgentCall {
106    #[serde(rename = "type")]
107    pub type_: MultiAgentCallType,
108    #[serde(
109        default,
110        deserialize_with = "super::input::present_nullable",
111        skip_serializing_if = "Option::is_none"
112    )]
113    pub id: Option<Option<String>>,
114    pub action: Action,
115    pub arguments: String,
116    pub call_id: String,
117    #[serde(
118        default,
119        deserialize_with = "super::input::present_nullable",
120        skip_serializing_if = "Option::is_none"
121    )]
122    pub agent: Option<Option<super::multi_agent::Agent>>,
123    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
124    pub rest: Rest,
125}
126
127#[derive(
128    Debug,
129    Clone,
130    PartialEq,
131    Eq,
132    Serialize,
133    Deserialize,
134    gproxy_protocol_macros::WireBuilder,
135    gproxy_protocol_macros::DeclaredFields,
136)]
137#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
138pub struct MultiAgentCallOutput {
139    #[serde(rename = "type")]
140    pub type_: MultiAgentCallOutputType,
141    #[serde(
142        default,
143        deserialize_with = "super::input::present_nullable",
144        skip_serializing_if = "Option::is_none"
145    )]
146    pub id: Option<Option<String>>,
147    pub action: Action,
148    pub call_id: String,
149    pub output: Vec<ReplayOutputText>,
150    #[serde(
151        default,
152        deserialize_with = "super::input::present_nullable",
153        skip_serializing_if = "Option::is_none"
154    )]
155    pub agent: Option<Option<super::multi_agent::Agent>>,
156    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
157    pub rest: Rest,
158}
159
160#[derive(
161    Debug,
162    Clone,
163    PartialEq,
164    Eq,
165    Serialize,
166    Deserialize,
167    gproxy_protocol_macros::WireBuilder,
168    gproxy_protocol_macros::DeclaredFields,
169)]
170#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
171pub struct AgentMessage {
172    #[serde(rename = "type")]
173    pub type_: AgentMessageType,
174    #[serde(
175        default,
176        deserialize_with = "super::input::present_nullable",
177        skip_serializing_if = "Option::is_none"
178    )]
179    pub id: Option<Option<String>>,
180    pub author: String,
181    pub recipient: String,
182    pub content: Vec<AgentContent>,
183    #[serde(
184        default,
185        deserialize_with = "super::input::present_nullable",
186        skip_serializing_if = "Option::is_none"
187    )]
188    pub agent: Option<Option<super::multi_agent::Agent>>,
189    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
190    pub rest: Rest,
191}
192
193#[derive(
194    Debug,
195    Clone,
196    PartialEq,
197    Eq,
198    Serialize,
199    Deserialize,
200    gproxy_protocol_macros::WireBuilder,
201    gproxy_protocol_macros::DeclaredFields,
202)]
203#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
204pub struct ResponseMultiAgentCall {
205    #[serde(rename = "type")]
206    pub type_: MultiAgentCallType,
207    pub id: String,
208    pub action: Action,
209    pub arguments: String,
210    pub call_id: String,
211    #[serde(
212        default,
213        deserialize_with = "super::input::present_nullable",
214        skip_serializing_if = "Option::is_none"
215    )]
216    pub agent: Option<Option<super::multi_agent::Agent>>,
217    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
218    pub rest: Rest,
219}
220
221#[derive(
222    Debug,
223    Clone,
224    PartialEq,
225    Eq,
226    Serialize,
227    Deserialize,
228    gproxy_protocol_macros::WireBuilder,
229    gproxy_protocol_macros::DeclaredFields,
230)]
231#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
232pub struct ResponseMultiAgentCallOutput {
233    #[serde(rename = "type")]
234    pub type_: MultiAgentCallOutputType,
235    pub id: String,
236    pub action: Action,
237    pub call_id: String,
238    pub output: Vec<input::ResponseOutputText>,
239    #[serde(
240        default,
241        deserialize_with = "super::input::present_nullable",
242        skip_serializing_if = "Option::is_none"
243    )]
244    pub agent: Option<Option<super::multi_agent::Agent>>,
245    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
246    pub rest: Rest,
247}
248
249#[derive(
250    Debug,
251    Clone,
252    PartialEq,
253    Eq,
254    Serialize,
255    Deserialize,
256    gproxy_protocol_macros::WireBuilder,
257    gproxy_protocol_macros::DeclaredFields,
258)]
259#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
260pub struct ResponseAgentMessage {
261    #[serde(rename = "type")]
262    pub type_: AgentMessageType,
263    pub id: String,
264    pub author: String,
265    pub recipient: String,
266    pub content: Vec<AgentContent>,
267    #[serde(
268        default,
269        deserialize_with = "super::input::present_nullable",
270        skip_serializing_if = "Option::is_none"
271    )]
272    pub agent: Option<Option<super::multi_agent::Agent>>,
273    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
274    pub rest: Rest,
275}
276
277#[derive(
278    Debug,
279    Clone,
280    PartialEq,
281    Eq,
282    Serialize,
283    Deserialize,
284    gproxy_protocol_macros::WireBuilder,
285    gproxy_protocol_macros::DeclaredFields,
286)]
287#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
288pub struct ReplayOutputText {
289    #[serde(rename = "type")]
290    pub type_: input::ResponseOutputTextType,
291    pub text: String,
292    #[serde(skip_serializing_if = "Option::is_none")]
293    pub annotations: Option<Vec<input::OutputAnnotation>>,
294    #[serde(skip_serializing_if = "Option::is_none")]
295    pub logprobs: Option<Vec<input::OutputLogprob>>,
296    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
297    pub rest: Rest,
298}
299
300#[derive(
301    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
302)]
303#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
304#[serde(untagged)]
305pub enum AgentContent {
306    InputText(input::ResponseInputText),
307    OutputText(ReplayOutputText),
308    Text(AgentText),
309    Summary(input::SummaryText),
310    Reasoning(input::ReasoningContent),
311    Refusal(input::ResponseOutputRefusal),
312    Image(input::ResponseInputImage),
313    Screenshot(input::ComputerScreenshot),
314    File(input::ResponseInputFile),
315    Encrypted(EncryptedContent),
316}
317
318#[derive(
319    Debug,
320    Clone,
321    PartialEq,
322    Eq,
323    Serialize,
324    Deserialize,
325    gproxy_protocol_macros::WireBuilder,
326    gproxy_protocol_macros::DeclaredFields,
327)]
328#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
329pub struct AgentText {
330    #[serde(rename = "type")]
331    pub type_: AgentTextType,
332    pub text: String,
333    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
334    pub rest: Rest,
335}
336
337#[derive(
338    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
339)]
340#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
341#[serde(rename_all = "snake_case")]
342pub enum AgentTextType {
343    Text,
344}
345
346#[derive(
347    Debug,
348    Clone,
349    PartialEq,
350    Eq,
351    Serialize,
352    Deserialize,
353    gproxy_protocol_macros::WireBuilder,
354    gproxy_protocol_macros::DeclaredFields,
355)]
356#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
357pub struct EncryptedContent {
358    #[serde(rename = "type")]
359    pub type_: EncryptedContentType,
360    pub encrypted_content: String,
361    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
362    pub rest: Rest,
363}
364
365#[derive(
366    Debug,
367    Clone,
368    PartialEq,
369    Eq,
370    Serialize,
371    Deserialize,
372    gproxy_protocol_macros::WireBuilder,
373    gproxy_protocol_macros::DeclaredFields,
374)]
375#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
376pub struct InjectRequest {
377    pub response_id: String,
378    pub input: Vec<input::InputItem>,
379    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
380    pub rest: Rest,
381}
382
383#[derive(
384    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
385)]
386#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
387#[serde(tag = "type")]
388pub enum InjectionEvent {
389    #[serde(rename = "response.inject.created")]
390    Created(InjectCreated),
391    #[serde(rename = "response.inject.failed")]
392    Failed(InjectFailed),
393}
394
395#[derive(
396    Debug,
397    Clone,
398    PartialEq,
399    Eq,
400    Serialize,
401    Deserialize,
402    gproxy_protocol_macros::WireBuilder,
403    gproxy_protocol_macros::DeclaredFields,
404)]
405#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
406pub struct InjectCreated {
407    pub sequence_number: i64,
408    pub response_id: String,
409    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
410    pub rest: Rest,
411}
412
413#[derive(
414    Debug,
415    Clone,
416    PartialEq,
417    Eq,
418    Serialize,
419    Deserialize,
420    gproxy_protocol_macros::WireBuilder,
421    gproxy_protocol_macros::DeclaredFields,
422)]
423#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
424pub struct InjectFailed {
425    pub sequence_number: i64,
426    pub response_id: String,
427    pub input: Vec<input::InputItem>,
428    pub error: InjectError,
429    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
430    pub rest: Rest,
431}
432
433#[derive(
434    Debug,
435    Clone,
436    PartialEq,
437    Eq,
438    Serialize,
439    Deserialize,
440    gproxy_protocol_macros::WireBuilder,
441    gproxy_protocol_macros::DeclaredFields,
442)]
443#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
444pub struct InjectError {
445    pub code: InjectErrorCode,
446    pub message: String,
447    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
448    pub rest: Rest,
449}
450
451#[derive(
452    Debug,
453    Clone,
454    Copy,
455    PartialEq,
456    Eq,
457    Serialize,
458    Deserialize,
459    gproxy_protocol_macros::DeclaredFields,
460)]
461#[serde(rename_all = "snake_case")]
462#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
463pub enum InjectErrorCode {
464    ResponseAlreadyCompleted,
465    ResponseNotFound,
466}