Skip to main content

ag_ui/
capabilities.rs

1//! What an agent can do — a categorized snapshot for discovery UIs, routing,
2//! and debugging.
3//!
4//! Every field is optional and omission means *not declared*, which is not the
5//! same as *unsupported*. Agents fill in only what they mean to advertise.
6
7use serde::{Deserialize, Serialize};
8
9use crate::JsonObject;
10use crate::tool::Tool;
11
12/// A sub-agent a parent agent can invoke.
13#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
14#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
15#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
16pub struct SubagentInfo {
17    /// Unique name or identifier of the sub-agent.
18    pub name: String,
19    /// What this sub-agent specializes in. Helps clients build selection UIs.
20    #[serde(default, skip_serializing_if = "Option::is_none")]
21    pub description: Option<String>,
22}
23
24/// The old spelling of [`SubagentInfo`], which is the AG-UI 1.0 name.
25#[deprecated(since = "0.5.0", note = "renamed to `SubagentInfo`")]
26pub type SubAgentInfo = SubagentInfo;
27
28/// Agent identity and metadata.
29#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
30#[serde(rename_all = "camelCase")]
31#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
32#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
33pub struct IdentityCapabilities {
34    /// Human-readable name shown in UIs and agent selectors.
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    pub name: Option<String>,
37    /// The framework powering this agent, for example `"langgraph"`.
38    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
39    pub kind: Option<String>,
40    /// What this agent does — helps users and routing logic pick it.
41    #[serde(default, skip_serializing_if = "Option::is_none")]
42    pub description: Option<String>,
43    /// Semantic version of the agent, for compatibility checks.
44    #[serde(default, skip_serializing_if = "Option::is_none")]
45    pub version: Option<String>,
46    /// Organization or team that maintains this agent.
47    #[serde(default, skip_serializing_if = "Option::is_none")]
48    pub provider: Option<String>,
49    /// URL of the agent's documentation or homepage.
50    #[serde(default, skip_serializing_if = "Option::is_none")]
51    pub documentation_url: Option<String>,
52    /// Integration-specific identity extras.
53    #[serde(default, skip_serializing_if = "Option::is_none")]
54    #[cfg_attr(
55        feature = "schemars",
56        schemars(with = "Option<std::collections::BTreeMap<String, serde_json::Value>>")
57    )]
58    #[cfg_attr(feature = "utoipa", schema(value_type = Option<Object>))]
59    pub metadata: Option<JsonObject>,
60}
61
62/// Transports the agent speaks.
63#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
64#[serde(rename_all = "camelCase")]
65#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
66#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
67pub struct TransportCapabilities {
68    /// The agent streams responses over SSE. Most agents set this.
69    #[serde(default, skip_serializing_if = "Option::is_none")]
70    pub streaming: Option<bool>,
71    /// The agent accepts persistent WebSocket connections.
72    #[serde(default, skip_serializing_if = "Option::is_none")]
73    pub websocket: Option<bool>,
74    /// The agent supports the AG-UI binary protocol (protobuf over HTTP).
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    pub http_binary: Option<bool>,
77    /// The agent can push async updates via webhooks after a run finishes.
78    #[serde(default, skip_serializing_if = "Option::is_none")]
79    pub push_notifications: Option<bool>,
80    /// The agent supports resuming interrupted streams via sequence numbers.
81    #[serde(default, skip_serializing_if = "Option::is_none")]
82    pub resumable: Option<bool>,
83}
84
85/// Tool-calling support, and the tools the agent brings itself.
86#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
87#[serde(rename_all = "camelCase")]
88#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
89#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
90pub struct ToolsCapabilities {
91    /// The agent can make tool calls at all. `Some(false)` disables tool
92    /// calling explicitly even when `items` is populated.
93    #[serde(default, skip_serializing_if = "Option::is_none")]
94    pub supported: Option<bool>,
95    /// Tools the agent provides on its own, distinct from the client-provided
96    /// tools in [`RunAgentInput::tools`](crate::input::RunAgentInput::tools).
97    #[serde(default, skip_serializing_if = "Option::is_none")]
98    pub items: Option<Vec<Tool>>,
99    /// The agent can invoke several tools concurrently within one step.
100    #[serde(default, skip_serializing_if = "Option::is_none")]
101    pub parallel_calls: Option<bool>,
102    /// The agent uses tools the client passes at runtime.
103    #[serde(default, skip_serializing_if = "Option::is_none")]
104    pub client_provided: Option<bool>,
105}
106
107/// Output formats the agent can produce.
108#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
109#[serde(rename_all = "camelCase")]
110#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
111#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
112pub struct OutputCapabilities {
113    /// The agent can return JSON matching a supplied schema.
114    #[serde(default, skip_serializing_if = "Option::is_none")]
115    pub structured_output: Option<bool>,
116    /// MIME types the agent can produce. Omit when it only produces plain text.
117    #[serde(default, skip_serializing_if = "Option::is_none")]
118    pub supported_mime_types: Option<Vec<String>>,
119}
120
121/// State and memory handling.
122#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
123#[serde(rename_all = "camelCase")]
124#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
125#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
126pub struct StateCapabilities {
127    /// The agent emits `STATE_SNAPSHOT` events.
128    #[serde(default, skip_serializing_if = "Option::is_none")]
129    pub snapshots: Option<bool>,
130    /// The agent emits `STATE_DELTA` events.
131    #[serde(default, skip_serializing_if = "Option::is_none")]
132    pub deltas: Option<bool>,
133    /// The agent has long-term memory beyond the current thread.
134    #[serde(default, skip_serializing_if = "Option::is_none")]
135    pub memory: Option<bool>,
136    /// State survives across runs within a thread. When `Some(false)`, state
137    /// resets each run.
138    #[serde(default, skip_serializing_if = "Option::is_none")]
139    pub persistent_state: Option<bool>,
140}
141
142/// Multi-agent coordination.
143#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
144#[serde(rename_all = "camelCase")]
145#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
146#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
147pub struct MultiAgentCapabilities {
148    /// The agent takes part in multi-agent coordination at all.
149    #[serde(default, skip_serializing_if = "Option::is_none")]
150    pub supported: Option<bool>,
151    /// The agent delegates subtasks while retaining control.
152    #[serde(default, skip_serializing_if = "Option::is_none")]
153    pub delegation: Option<bool>,
154    /// The agent can hand the conversation over entirely.
155    #[serde(default, skip_serializing_if = "Option::is_none")]
156    pub handoffs: Option<bool>,
157    /// Sub-agents this agent can invoke. AG-UI 1.0 spells the key `subagents`;
158    /// the earlier `subAgents` is not read.
159    #[serde(rename = "subagents", default, skip_serializing_if = "Option::is_none")]
160    pub sub_agents: Option<Vec<SubagentInfo>>,
161}
162
163/// Visibility into the agent's reasoning.
164#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
165#[serde(rename_all = "camelCase")]
166#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
167#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
168pub struct ReasoningCapabilities {
169    /// The agent produces reasoning visible to the client.
170    #[serde(default, skip_serializing_if = "Option::is_none")]
171    pub supported: Option<bool>,
172    /// Reasoning is streamed incrementally rather than delivered at once.
173    #[serde(default, skip_serializing_if = "Option::is_none")]
174    pub streaming: Option<bool>,
175    /// Reasoning is encrypted (zero-data-retention). Clients should expect
176    /// opaque `encryptedValue` fields instead of readable content.
177    #[serde(default, skip_serializing_if = "Option::is_none")]
178    pub encrypted: Option<bool>,
179}
180
181/// Modalities the agent accepts as input.
182#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
183#[serde(rename_all = "camelCase")]
184#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186pub struct MultimodalInputCapabilities {
187    /// Images.
188    #[serde(default, skip_serializing_if = "Option::is_none")]
189    pub image: Option<bool>,
190    /// Audio.
191    #[serde(default, skip_serializing_if = "Option::is_none")]
192    pub audio: Option<bool>,
193    /// Video.
194    #[serde(default, skip_serializing_if = "Option::is_none")]
195    pub video: Option<bool>,
196    /// PDF documents.
197    #[serde(default, skip_serializing_if = "Option::is_none")]
198    pub pdf: Option<bool>,
199    /// Arbitrary file uploads.
200    #[serde(default, skip_serializing_if = "Option::is_none")]
201    pub file: Option<bool>,
202}
203
204/// Modalities the agent can produce.
205#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
206#[serde(rename_all = "camelCase")]
207#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209pub struct MultimodalOutputCapabilities {
210    /// The agent can generate images.
211    #[serde(default, skip_serializing_if = "Option::is_none")]
212    pub image: Option<bool>,
213    /// The agent can produce audio.
214    #[serde(default, skip_serializing_if = "Option::is_none")]
215    pub audio: Option<bool>,
216}
217
218/// Multimodal input and output support, split so clients can query each side
219/// independently.
220#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
221#[serde(rename_all = "camelCase")]
222#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
224pub struct MultimodalCapabilities {
225    /// What the agent accepts.
226    #[serde(default, skip_serializing_if = "Option::is_none")]
227    pub input: Option<MultimodalInputCapabilities>,
228    /// What the agent produces.
229    #[serde(default, skip_serializing_if = "Option::is_none")]
230    pub output: Option<MultimodalOutputCapabilities>,
231}
232
233/// Execution controls and limits.
234///
235/// The two caps are integers, not floats. The upstream Zod schema types them as
236/// a bare `z.number()`, which is a JavaScript double — but the Python SDK
237/// declares them `Optional[int]`, and both an iteration count and a millisecond
238/// budget are whole numbers everywhere they are produced. Modelling them as
239/// `f64` would re-emit a received `"maxIterations": 10` as `10.0`, so a Rust
240/// proxy between two upstream implementations would silently rewrite the
241/// payload. They are signed because Python's `int` is: some frameworks spell
242/// "no limit" as `-1`, and rejecting that at parse time would fail the whole
243/// capabilities document over a value the reference implementations accept.
244#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
245#[serde(rename_all = "camelCase")]
246#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
247#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
248pub struct ExecutionCapabilities {
249    /// The agent can execute code during a run.
250    #[serde(default, skip_serializing_if = "Option::is_none")]
251    pub code_execution: Option<bool>,
252    /// Code execution is sandboxed. Only meaningful with `code_execution`.
253    #[serde(default, skip_serializing_if = "Option::is_none")]
254    pub sandboxed: Option<bool>,
255    /// Cap on tool-call / reasoning iterations per run.
256    ///
257    /// The schema says `minimum: 0`. A negative number, which some frameworks
258    /// send for "no limit", reads as `None`: no cap declared.
259    #[serde(
260        default,
261        deserialize_with = "crate::serde_util::non_negative",
262        serialize_with = "crate::serde_util::serialize_safe_integer",
263        skip_serializing_if = "Option::is_none"
264    )]
265    pub max_iterations: Option<u64>,
266    /// Wall-clock cap per run, in milliseconds. Read like `max_iterations`.
267    #[serde(
268        default,
269        deserialize_with = "crate::serde_util::non_negative",
270        serialize_with = "crate::serde_util::serialize_safe_integer",
271        skip_serializing_if = "Option::is_none"
272    )]
273    pub max_execution_time: Option<u64>,
274}
275
276/// Human-in-the-loop support.
277#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
278#[serde(rename_all = "camelCase")]
279#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
281pub struct HumanInTheLoopCapabilities {
282    /// The agent supports human-in-the-loop interaction at all.
283    #[serde(default, skip_serializing_if = "Option::is_none")]
284    pub supported: Option<bool>,
285    /// The agent pauses for explicit approval before sensitive actions.
286    #[serde(default, skip_serializing_if = "Option::is_none")]
287    pub approvals: Option<bool>,
288    /// Humans can modify the agent's plan mid-execution.
289    #[serde(default, skip_serializing_if = "Option::is_none")]
290    pub interventions: Option<bool>,
291    /// The agent incorporates user feedback within a thread.
292    #[serde(default, skip_serializing_if = "Option::is_none")]
293    pub feedback: Option<bool>,
294    /// The agent speaks the interrupt protocol: it emits `RUN_FINISHED` with
295    /// [`RunOutcome::Interrupt`](crate::outcome::RunOutcome::Interrupt) and
296    /// accepts `resume` entries.
297    #[serde(default, skip_serializing_if = "Option::is_none")]
298    pub interrupts: Option<bool>,
299    /// Tool-call interrupts accept `editedArgs` in the resume payload. Only
300    /// meaningful with `interrupts`.
301    #[serde(default, skip_serializing_if = "Option::is_none")]
302    pub approve_with_edits: Option<bool>,
303}
304
305/// A typed, categorized snapshot of what an agent supports.
306#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
307#[serde(rename_all = "camelCase")]
308#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
310pub struct AgentCapabilities {
311    /// Identity and metadata.
312    #[serde(default, skip_serializing_if = "Option::is_none")]
313    pub identity: Option<IdentityCapabilities>,
314    /// Supported transports.
315    #[serde(default, skip_serializing_if = "Option::is_none")]
316    pub transport: Option<TransportCapabilities>,
317    /// Tool calling and agent-provided tools.
318    #[serde(default, skip_serializing_if = "Option::is_none")]
319    pub tools: Option<ToolsCapabilities>,
320    /// Output formats.
321    #[serde(default, skip_serializing_if = "Option::is_none")]
322    pub output: Option<OutputCapabilities>,
323    /// State and memory.
324    #[serde(default, skip_serializing_if = "Option::is_none")]
325    pub state: Option<StateCapabilities>,
326    /// Multi-agent coordination.
327    #[serde(default, skip_serializing_if = "Option::is_none")]
328    pub multi_agent: Option<MultiAgentCapabilities>,
329    /// Reasoning visibility.
330    #[serde(default, skip_serializing_if = "Option::is_none")]
331    pub reasoning: Option<ReasoningCapabilities>,
332    /// Multimodal input and output.
333    #[serde(default, skip_serializing_if = "Option::is_none")]
334    pub multimodal: Option<MultimodalCapabilities>,
335    /// Execution controls and limits.
336    #[serde(default, skip_serializing_if = "Option::is_none")]
337    pub execution: Option<ExecutionCapabilities>,
338    /// Human-in-the-loop support.
339    #[serde(default, skip_serializing_if = "Option::is_none")]
340    pub human_in_the_loop: Option<HumanInTheLoopCapabilities>,
341    /// Escape hatch for capabilities the standard categories do not cover.
342    #[serde(default, skip_serializing_if = "Option::is_none")]
343    #[cfg_attr(
344        feature = "schemars",
345        schemars(with = "Option<std::collections::BTreeMap<String, serde_json::Value>>")
346    )]
347    #[cfg_attr(feature = "utoipa", schema(value_type = Option<Object>))]
348    pub custom: Option<JsonObject>,
349}