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