Skip to main content

objectiveai_sdk/agent/
agent.rs

1//! Core Agent types — unified enum dispatching to per-upstream implementations.
2
3use serde::{Deserialize, Serialize};
4use schemars::JsonSchema;
5
6// ── Pre-validation types (no computed ID) ──────────────────────────
7
8/// The base inline configuration for an Agent (without computed ID or metadata).
9///
10/// This is an untagged enum that dispatches to the per-upstream AgentBase.
11/// Deserialization tries each variant in order until one matches.
12#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
13#[serde(untagged)]
14#[schemars(rename = "agent.InlineAgentBase")]
15pub enum InlineAgentBase {
16    #[schemars(title = "Openrouter")]
17    Openrouter(super::openrouter::AgentBase),
18    #[schemars(title = "ClaudeAgentSdk")]
19    ClaudeAgentSdk(super::claude_agent_sdk::AgentBase),
20    #[schemars(title = "CodexSdk")]
21    CodexSdk(super::codex_sdk::AgentBase),
22    #[schemars(title = "Mock")]
23    Mock(super::mock::AgentBase),
24}
25
26impl InlineAgentBase {
27    pub fn as_ref(&self) -> InlineAgentRef<'_> {
28        match self {
29            InlineAgentBase::Openrouter(b) => InlineAgentRef::Openrouter(b),
30            InlineAgentBase::ClaudeAgentSdk(b) => InlineAgentRef::ClaudeAgentSdk(b),
31            InlineAgentBase::CodexSdk(b) => InlineAgentRef::CodexSdk(b),
32            InlineAgentBase::Mock(b) => InlineAgentRef::Mock(b),
33        }
34    }
35
36    pub fn model(&self) -> &str {
37        self.as_ref().model()
38    }
39
40    pub fn upstream(&self) -> super::Upstream {
41        self.as_ref().upstream()
42    }
43
44    pub fn output_mode(&self) -> super::OutputMode {
45        self.as_ref().output_mode()
46    }
47
48    pub fn mcp_servers(&self) -> Option<&super::McpServers> {
49        self.as_ref().mcp_servers()
50    }
51
52    pub fn prepare(&mut self) {
53        match self {
54            InlineAgentBase::Openrouter(b) => b.prepare(),
55            InlineAgentBase::ClaudeAgentSdk(b) => b.prepare(),
56            InlineAgentBase::CodexSdk(b) => b.prepare(),
57            InlineAgentBase::Mock(b) => b.prepare(),
58        }
59    }
60
61    pub fn validate(&self) -> Result<(), String> {
62        match self {
63            InlineAgentBase::Openrouter(b) => b.validate(),
64            InlineAgentBase::ClaudeAgentSdk(b) => b.validate(),
65            InlineAgentBase::CodexSdk(b) => b.validate(),
66            InlineAgentBase::Mock(b) => b.validate(),
67        }
68    }
69
70    pub fn id(&self) -> String {
71        match self {
72            InlineAgentBase::Openrouter(b) => b.id(),
73            InlineAgentBase::ClaudeAgentSdk(b) => b.id(),
74            InlineAgentBase::CodexSdk(b) => b.id(),
75            InlineAgentBase::Mock(b) => b.id(),
76        }
77    }
78
79    /// Validates and converts to an [`InlineAgent`] with computed ID.
80    pub fn convert(self) -> Result<InlineAgent, String> {
81        match self {
82            InlineAgentBase::Openrouter(b) => Ok(InlineAgent::Openrouter(b.try_into()?)),
83            InlineAgentBase::ClaudeAgentSdk(b) => {
84                Ok(InlineAgent::ClaudeAgentSdk(b.try_into()?))
85            }
86            InlineAgentBase::CodexSdk(b) => {
87                Ok(InlineAgent::CodexSdk(b.try_into()?))
88            }
89            InlineAgentBase::Mock(b) => Ok(InlineAgent::Mock(b.try_into()?)),
90        }
91    }
92}
93
94/// A remote agent base definition with metadata.
95///
96/// Like [`InlineAgentBase`] but includes a description field for remote storage.
97#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
98#[schemars(rename = "agent.RemoteAgentBase")]
99pub struct RemoteAgentBase {
100    pub description: String,
101    #[serde(flatten)]
102    #[schemars(schema_with = "crate::flatten_schema::<InlineAgentBase>")]
103    pub inner: InlineAgentBase,
104}
105
106impl RemoteAgentBase {
107    pub fn as_ref(&self) -> InlineAgentRef<'_> {
108        self.inner.as_ref()
109    }
110
111    pub fn model(&self) -> &str {
112        self.inner.model()
113    }
114
115    pub fn upstream(&self) -> super::Upstream {
116        self.inner.upstream()
117    }
118
119    pub fn output_mode(&self) -> super::OutputMode {
120        self.inner.output_mode()
121    }
122
123    pub fn mcp_servers(&self) -> Option<&super::McpServers> {
124        self.inner.mcp_servers()
125    }
126
127    pub fn prepare(&mut self) {
128        self.inner.prepare()
129    }
130
131    pub fn validate(&self) -> Result<(), String> {
132        self.inner.validate()
133    }
134
135    pub fn id(&self) -> String {
136        self.inner.id()
137    }
138
139    /// Validates and converts to a [`RemoteAgent`] with computed ID.
140    pub fn convert(self) -> Result<RemoteAgent, String> {
141        Ok(RemoteAgent {
142            description: self.description,
143            inner: self.inner.convert()?,
144        })
145    }
146}
147
148/// An Agent base definition, either remote (with metadata) or inline.
149#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
150#[serde(untagged)]
151#[schemars(rename = "agent.AgentBase")]
152pub enum AgentBase {
153    #[schemars(title = "Remote")]
154    Remote(RemoteAgentBase),
155    #[schemars(title = "Inline")]
156    Inline(InlineAgentBase),
157}
158
159impl AgentBase {
160    pub fn as_ref(&self) -> InlineAgentRef<'_> {
161        match self {
162            AgentBase::Remote(r) => r.as_ref(),
163            AgentBase::Inline(i) => i.as_ref(),
164        }
165    }
166
167    pub fn model(&self) -> &str {
168        match self {
169            AgentBase::Remote(r) => r.model(),
170            AgentBase::Inline(i) => i.model(),
171        }
172    }
173
174    pub fn upstream(&self) -> super::Upstream {
175        match self {
176            AgentBase::Remote(r) => r.upstream(),
177            AgentBase::Inline(i) => i.upstream(),
178        }
179    }
180
181    pub fn output_mode(&self) -> super::OutputMode {
182        match self {
183            AgentBase::Remote(r) => r.output_mode(),
184            AgentBase::Inline(i) => i.output_mode(),
185        }
186    }
187
188    pub fn mcp_servers(&self) -> Option<&super::McpServers> {
189        match self {
190            AgentBase::Remote(r) => r.mcp_servers(),
191            AgentBase::Inline(i) => i.mcp_servers(),
192        }
193    }
194
195    pub fn prepare(&mut self) {
196        match self {
197            AgentBase::Remote(r) => r.prepare(),
198            AgentBase::Inline(i) => i.prepare(),
199        }
200    }
201
202    pub fn validate(&self) -> Result<(), String> {
203        match self {
204            AgentBase::Remote(r) => r.validate(),
205            AgentBase::Inline(i) => i.validate(),
206        }
207    }
208
209    pub fn id(&self) -> String {
210        match self {
211            AgentBase::Remote(r) => r.id(),
212            AgentBase::Inline(i) => i.id(),
213        }
214    }
215
216    /// Validates and converts to an [`Agent`] with computed ID.
217    pub fn convert(self) -> Result<Agent, String> {
218        match self {
219            AgentBase::Remote(r) => Ok(Agent::Remote(r.convert()?)),
220            AgentBase::Inline(i) => Ok(Agent::Inline(i.convert()?)),
221        }
222    }
223}
224
225// ── Ref types ──────────────────────────────────────────────────────
226
227/// A borrowed reference into an [`InlineAgentBase`] variant.
228#[derive(Clone, Copy, Debug)]
229pub enum InlineAgentRef<'a> {
230    Openrouter(&'a super::openrouter::AgentBase),
231    ClaudeAgentSdk(&'a super::claude_agent_sdk::AgentBase),
232    CodexSdk(&'a super::codex_sdk::AgentBase),
233    Mock(&'a super::mock::AgentBase),
234}
235
236impl<'a> InlineAgentRef<'a> {
237    pub fn to_owned(self) -> InlineAgentBase {
238        match self {
239            InlineAgentRef::Openrouter(b) => InlineAgentBase::Openrouter(b.clone()),
240            InlineAgentRef::ClaudeAgentSdk(b) => {
241                InlineAgentBase::ClaudeAgentSdk(b.clone())
242            }
243            InlineAgentRef::CodexSdk(b) => InlineAgentBase::CodexSdk(b.clone()),
244            InlineAgentRef::Mock(b) => InlineAgentBase::Mock(b.clone()),
245        }
246    }
247
248    pub fn model(&self) -> &'a str {
249        match self {
250            InlineAgentRef::Openrouter(b) => &b.model,
251            InlineAgentRef::ClaudeAgentSdk(b) => &b.model,
252            InlineAgentRef::CodexSdk(b) => &b.model,
253            InlineAgentRef::Mock(_) => super::mock::AgentBase::model(),
254        }
255    }
256
257    pub fn upstream(&self) -> super::Upstream {
258        match self {
259            InlineAgentRef::Openrouter(_) => super::Upstream::Openrouter,
260            InlineAgentRef::ClaudeAgentSdk(_) => super::Upstream::ClaudeAgentSdk,
261            InlineAgentRef::CodexSdk(_) => super::Upstream::CodexSdk,
262            InlineAgentRef::Mock(_) => super::Upstream::Mock,
263        }
264    }
265
266    pub fn output_mode(&self) -> super::OutputMode {
267        match self {
268            InlineAgentRef::Openrouter(b) => b.output_mode.into(),
269            InlineAgentRef::ClaudeAgentSdk(b) => b.output_mode.into(),
270            InlineAgentRef::CodexSdk(b) => b.output_mode.into(),
271            InlineAgentRef::Mock(b) => b.output_mode.into(),
272        }
273    }
274
275    pub fn mcp_servers(&self) -> Option<&'a super::McpServers> {
276        match self {
277            InlineAgentRef::Openrouter(b) => b.mcp_servers.as_ref(),
278            InlineAgentRef::ClaudeAgentSdk(b) => b.mcp_servers.as_ref(),
279            InlineAgentRef::CodexSdk(b) => b.mcp_servers.as_ref(),
280            InlineAgentRef::Mock(b) => b.mcp_servers.as_ref(),
281        }
282    }
283
284    pub fn top_logprobs(&self) -> Option<u64> {
285        match self {
286            InlineAgentRef::Openrouter(b) => b.top_logprobs,
287            InlineAgentRef::ClaudeAgentSdk(_) => None,
288            InlineAgentRef::CodexSdk(_) => None,
289            InlineAgentRef::Mock(b) => b.top_logprobs,
290        }
291    }
292
293    pub fn merged_messages(
294        &self,
295        messages: Vec<super::completions::message::Message>,
296    ) -> Vec<super::completions::message::Message> {
297        match self {
298            InlineAgentRef::Openrouter(b) => b.merged_messages(messages),
299            InlineAgentRef::ClaudeAgentSdk(b) => b.merged_messages(messages),
300            InlineAgentRef::CodexSdk(b) => b.merged_messages(messages),
301            InlineAgentRef::Mock(b) => b.merged_messages(messages),
302        }
303    }
304}
305
306// ── Post-validation types (with computed ID) ───────────────────────
307
308/// A validated inline Agent with its computed content-addressed ID.
309///
310/// This is an untagged enum that dispatches to the per-upstream Agent.
311#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
312#[serde(untagged)]
313#[schemars(rename = "agent.InlineAgent")]
314pub enum InlineAgent {
315    #[schemars(title = "Openrouter")]
316    Openrouter(super::openrouter::Agent),
317    #[schemars(title = "ClaudeAgentSdk")]
318    ClaudeAgentSdk(super::claude_agent_sdk::Agent),
319    #[schemars(title = "CodexSdk")]
320    CodexSdk(super::codex_sdk::Agent),
321    #[schemars(title = "Mock")]
322    Mock(super::mock::Agent),
323}
324
325impl InlineAgent {
326    pub fn id(&self) -> &str {
327        match self {
328            InlineAgent::Openrouter(a) => &a.id,
329            InlineAgent::ClaudeAgentSdk(a) => &a.id,
330            InlineAgent::CodexSdk(a) => &a.id,
331            InlineAgent::Mock(a) => &a.id,
332        }
333    }
334
335    pub fn base(&self) -> InlineAgentRef<'_> {
336        match self {
337            InlineAgent::Openrouter(a) => InlineAgentRef::Openrouter(&a.base),
338            InlineAgent::ClaudeAgentSdk(a) => InlineAgentRef::ClaudeAgentSdk(&a.base),
339            InlineAgent::CodexSdk(a) => InlineAgentRef::CodexSdk(&a.base),
340            InlineAgent::Mock(a) => InlineAgentRef::Mock(&a.base),
341        }
342    }
343
344    pub fn into_base(self) -> InlineAgentBase {
345        match self {
346            InlineAgent::Openrouter(a) => InlineAgentBase::Openrouter(a.base),
347            InlineAgent::ClaudeAgentSdk(a) => InlineAgentBase::ClaudeAgentSdk(a.base),
348            InlineAgent::CodexSdk(a) => InlineAgentBase::CodexSdk(a.base),
349            InlineAgent::Mock(a) => InlineAgentBase::Mock(a.base),
350        }
351    }
352
353    pub fn top_logprobs(&self) -> Option<u64> {
354        self.base().top_logprobs()
355    }
356}
357
358/// A validated remote Agent with metadata and computed content-addressed ID.
359#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
360#[schemars(rename = "agent.RemoteAgent")]
361pub struct RemoteAgent {
362    pub description: String,
363    #[serde(flatten)]
364    #[schemars(schema_with = "crate::flatten_schema::<InlineAgent>")]
365    pub inner: InlineAgent,
366}
367
368impl RemoteAgent {
369    pub fn id(&self) -> &str {
370        self.inner.id()
371    }
372
373    pub fn base(&self) -> InlineAgentRef<'_> {
374        self.inner.base()
375    }
376
377    pub fn into_base(self) -> RemoteAgentBase {
378        RemoteAgentBase {
379            description: self.description,
380            inner: self.inner.into_base(),
381        }
382    }
383
384    pub fn top_logprobs(&self) -> Option<u64> {
385        self.inner.top_logprobs()
386    }
387}
388
389/// A validated Agent, either remote (with metadata) or inline.
390#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
391#[serde(untagged)]
392#[schemars(rename = "agent.Agent")]
393pub enum Agent {
394    #[schemars(title = "Remote")]
395    Remote(RemoteAgent),
396    #[schemars(title = "Inline")]
397    Inline(InlineAgent),
398}
399
400impl Agent {
401    pub fn id(&self) -> &str {
402        match self {
403            Agent::Remote(a) => a.inner.id(),
404            Agent::Inline(a) => a.id(),
405        }
406    }
407
408    pub fn base(&self) -> InlineAgentRef<'_> {
409        match self {
410            Agent::Remote(a) => a.inner.base(),
411            Agent::Inline(a) => a.base(),
412        }
413    }
414
415    pub fn into_base(self) -> AgentBase {
416        match self {
417            Agent::Remote(a) => AgentBase::Remote(RemoteAgentBase {
418                description: a.description,
419                inner: a.inner.into_base(),
420            }),
421            Agent::Inline(a) => AgentBase::Inline(a.into_base()),
422        }
423    }
424
425    pub fn top_logprobs(&self) -> Option<u64> {
426        self.base().top_logprobs()
427    }
428}
429
430// ── WithFallbacks types ────────────────────────────────────────────
431
432/// An [`InlineAgentBase`] with optional fallbacks (no description).
433#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
434#[schemars(rename = "agent.InlineAgentBaseWithFallbacks")]
435pub struct InlineAgentBaseWithFallbacks {
436    /// The primary agent configuration.
437    #[serde(flatten)]
438    #[schemars(schema_with = "crate::flatten_schema::<InlineAgentBase>")]
439    pub inner: InlineAgentBase,
440    /// Fallback agents to try if the primary fails.
441    #[serde(skip_serializing_if = "Option::is_none")]
442    #[schemars(extend("omitempty" = true))]
443    pub fallbacks: Option<Vec<InlineAgentBase>>,
444}
445
446impl InlineAgentBaseWithFallbacks {
447    /// Validates and converts to an [`InlineAgentWithFallbacks`] with computed IDs.
448    pub fn convert(self) -> Result<InlineAgentWithFallbacks, String> {
449        let inner = self.inner.convert()?;
450        let fallbacks = match self.fallbacks {
451            Some(fallbacks) if !fallbacks.is_empty() => {
452                let mut converted = Vec::with_capacity(fallbacks.len());
453                for fallback in fallbacks {
454                    converted.push(fallback.convert()?);
455                }
456                Some(converted)
457            }
458            _ => None,
459        };
460        Ok(InlineAgentWithFallbacks { inner, fallbacks })
461    }
462}
463
464/// A validated [`InlineAgent`] with optional fallbacks (no description).
465#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
466#[schemars(rename = "agent.InlineAgentWithFallbacks")]
467pub struct InlineAgentWithFallbacks {
468    /// The primary agent configuration.
469    #[serde(flatten)]
470    #[schemars(schema_with = "crate::flatten_schema::<InlineAgent>")]
471    pub inner: InlineAgent,
472    /// Fallback agents to try if the primary fails.
473    #[serde(skip_serializing_if = "Option::is_none")]
474    #[schemars(extend("omitempty" = true))]
475    pub fallbacks: Option<Vec<InlineAgent>>,
476}
477
478impl InlineAgentWithFallbacks {
479    /// Returns the concatenated IDs of the primary agent and all fallbacks.
480    ///
481    /// Used by swarms to compute their content-addressed ID.
482    pub fn full_id(&self) -> String {
483        match &self.fallbacks {
484            Some(fallbacks) => {
485                let id = self.inner.id();
486                let mut full_id =
487                    String::with_capacity(id.len() + fallbacks.len() * 22);
488                full_id.push_str(id);
489                for fallback in fallbacks {
490                    full_id.push_str(fallback.id());
491                }
492                full_id
493            }
494            None => self.inner.id().to_owned(),
495        }
496    }
497
498    /// Returns an iterator over the IDs of the primary agent and all fallbacks.
499    pub fn ids(&self) -> impl Iterator<Item = &str> {
500        std::iter::once(self.inner.id()).chain(
501            self.fallbacks.as_ref().into_iter().flat_map(|fallbacks| {
502                fallbacks.iter().map(|fallback| fallback.id())
503            }),
504        )
505    }
506}
507
508/// A remote agent base definition with description and optional fallbacks.
509#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
510#[schemars(rename = "agent.RemoteAgentBaseWithFallbacks")]
511pub struct RemoteAgentBaseWithFallbacks {
512    pub description: String,
513    #[serde(flatten)]
514    #[schemars(schema_with = "crate::flatten_schema::<InlineAgentBaseWithFallbacks>")]
515    pub inner: InlineAgentBaseWithFallbacks,
516}
517
518impl RemoteAgentBaseWithFallbacks {
519    /// Validates and converts to a [`RemoteAgentWithFallbacks`].
520    pub fn convert(self) -> Result<RemoteAgentWithFallbacks, String> {
521        Ok(RemoteAgentWithFallbacks {
522            description: self.description,
523            inner: self.inner.convert()?,
524        })
525    }
526}
527
528/// A validated remote agent with description and optional fallbacks.
529#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
530#[schemars(rename = "agent.RemoteAgentWithFallbacks")]
531pub struct RemoteAgentWithFallbacks {
532    pub description: String,
533    #[serde(flatten)]
534    #[schemars(schema_with = "crate::flatten_schema::<InlineAgentWithFallbacks>")]
535    pub inner: InlineAgentWithFallbacks,
536}
537
538impl RemoteAgentWithFallbacks {
539    /// Returns the concatenated IDs of the primary agent and all fallbacks.
540    pub fn full_id(&self) -> String {
541        self.inner.full_id()
542    }
543
544    /// Returns an iterator over the IDs of the primary agent and all fallbacks.
545    pub fn ids(&self) -> impl Iterator<Item = &str> {
546        self.inner.ids()
547    }
548}
549
550/// A validated agent with optional fallbacks, either remote (with description) or inline.
551#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
552#[serde(untagged)]
553#[schemars(rename = "agent.AgentWithFallbacks")]
554pub enum AgentWithFallbacks {
555    #[schemars(title = "Remote")]
556    Remote(RemoteAgentWithFallbacks),
557    #[schemars(title = "Inline")]
558    Inline(InlineAgentWithFallbacks),
559}
560
561impl AgentWithFallbacks {
562    /// Returns the inner `InlineAgentWithFallbacks` regardless of variant.
563    pub fn inline(&self) -> &InlineAgentWithFallbacks {
564        match self {
565            AgentWithFallbacks::Remote(a) => &a.inner,
566            AgentWithFallbacks::Inline(a) => a,
567        }
568    }
569
570    /// Returns the primary agent.
571    pub fn agent(&self) -> &InlineAgent {
572        &self.inline().inner
573    }
574
575    /// Returns the fallback agents.
576    pub fn fallbacks(&self) -> Option<&Vec<InlineAgent>> {
577        self.inline().fallbacks.as_ref()
578    }
579
580    /// Returns the concatenated IDs of the primary agent and all fallbacks.
581    pub fn full_id(&self) -> String {
582        self.inline().full_id()
583    }
584
585    /// Returns an iterator over the IDs of the primary agent and all fallbacks.
586    pub fn ids(&self) -> impl Iterator<Item = &str> {
587        self.inline().ids()
588    }
589
590    pub fn id(&self) -> &str {
591        self.agent().id()
592    }
593
594    pub fn base(&self) -> InlineAgentRef<'_> {
595        self.agent().base()
596    }
597
598    pub fn top_logprobs(&self) -> Option<u64> {
599        self.agent().top_logprobs()
600    }
601}
602
603// ── InlineAgentBaseWithFallbacksOrRemote ─────────────────────────────────
604
605/// An agent specification that is either an inline agent base with fallbacks
606/// or a remote path reference.
607///
608/// Used in swarm definitions to allow agents to be specified inline
609/// (with optional fallbacks) or resolved from a remote source via a
610/// hashmap during conversion.
611#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
612#[serde(untagged)]
613#[schemars(rename = "agent.InlineAgentBaseWithFallbacksOrRemote")]
614pub enum InlineAgentBaseWithFallbacksOrRemote {
615    #[schemars(title = "AgentBase")]
616    AgentBase(InlineAgentBaseWithFallbacks),
617    #[schemars(title = "Remote")]
618    Remote(crate::RemotePath),
619}
620
621/// Like [`InlineAgentBaseWithFallbacksOrRemote`] but with optional commit.
622/// Used in request types where commit resolution happens server-side.
623#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
624#[serde(untagged)]
625#[schemars(rename = "agent.InlineAgentBaseWithFallbacksOrRemoteCommitOptional")]
626pub enum InlineAgentBaseWithFallbacksOrRemoteCommitOptional {
627    #[schemars(title = "AgentBase")]
628    AgentBase(InlineAgentBaseWithFallbacks),
629    #[schemars(title = "Remote")]
630    Remote(crate::RemotePathCommitOptional),
631}
632
633// ── WithCount types (for swarm agent slots) ────────────────────────
634
635fn default_count() -> u64 {
636    1
637}
638
639/// An [`InlineAgentBaseWithFallbacksOrRemote`] with a count
640/// (pre-validation swarm agent slot).
641#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
642#[schemars(rename = "agent.InlineAgentBaseWithFallbacksOrRemoteWithCount")]
643pub struct InlineAgentBaseWithFallbacksOrRemoteWithCount {
644    /// Number of instances of this agent in the swarm. Defaults to 1.
645    #[serde(default = "default_count")]
646    #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
647    pub count: u64,
648    /// The agent configuration.
649    #[serde(flatten)]
650    #[schemars(schema_with = "crate::flatten_schema::<InlineAgentBaseWithFallbacksOrRemote>")]
651    pub inner: InlineAgentBaseWithFallbacksOrRemote,
652}
653
654/// An [`AgentWithFallbacks`] with a count (post-validation swarm agent slot).
655#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
656#[schemars(rename = "agent.AgentWithFallbacksWithCount")]
657pub struct AgentWithFallbacksWithCount {
658    /// Number of instances of this agent in the swarm. Defaults to 1.
659    #[serde(default = "default_count")]
660    pub count: u64,
661    /// The validated agent configuration.
662    #[serde(flatten)]
663    #[schemars(schema_with = "crate::flatten_schema::<AgentWithFallbacks>")]
664    pub inner: AgentWithFallbacks,
665}