claude_api/managed_agents/mod.rs
1//! Anthropic Managed Agents API (preview).
2//!
3//! Managed Agents lets you provision long-running agent sessions backed by
4//! Anthropic-managed compute environments, persistent memory stores, and
5//! credential vaults. Each session references a versioned agent and an
6//! environment, drives a [stream of events](crate::managed_agents::events),
7//! and may produce outputs as files.
8//!
9//! # Beta status
10//!
11//! All requests in this module require the `managed-agents-2026-04-01`
12//! beta header, which the SDK adds automatically. Outcomes additionally
13//! require `managed-agents-2026-04-01-research-preview`.
14//!
15//! **The API surface is in preview and will change.** Field names,
16//! request shapes, and resource relationships are not yet stable. We
17//! follow the broader claude-api forward-compatibility contract: every
18//! union deserializes into `Other(Value)` when the wire `type` tag is
19//! unknown, so brand-new variants don't break the build. New `Known`
20//! variants are minor bumps that may require sweeping `Other` matches.
21//!
22//! Gated on the `managed-agents-preview` feature.
23//!
24//! # Layout
25//!
26//! - [`sessions`] -- create, retrieve, list, archive, delete sessions;
27//! send and stream events.
28//! - [`vaults`] -- credential vaults for MCP authentication.
29//! - [`memory_stores`] -- persistent memory across sessions.
30//! - [`agents`] -- agent definitions (create only in this version; full
31//! CRUD lands once docs are available).
32
33#![cfg(feature = "managed-agents-preview")]
34#![cfg_attr(docsrs, doc(cfg(feature = "managed-agents-preview")))]
35
36use crate::client::Client;
37
38pub mod agents;
39pub mod environments;
40pub mod events;
41pub mod memory_stores;
42pub mod resources;
43pub mod sessions;
44pub mod threads;
45pub mod vaults;
46
47/// Top-level namespace handle for the Managed Agents API.
48///
49/// Obtained via [`Client::managed_agents`].
50pub struct ManagedAgents<'a> {
51 client: &'a Client,
52}
53
54impl<'a> ManagedAgents<'a> {
55 pub(crate) fn new(client: &'a Client) -> Self {
56 Self { client }
57 }
58
59 /// Sessions sub-namespace.
60 #[must_use]
61 pub fn sessions(&self) -> sessions::Sessions<'a> {
62 sessions::Sessions::new(self.client)
63 }
64
65 /// Vaults sub-namespace (per-user MCP credential vaults).
66 #[must_use]
67 pub fn vaults(&self) -> vaults::Vaults<'a> {
68 vaults::Vaults::new(self.client)
69 }
70
71 /// Memory stores sub-namespace (persistent memory across sessions).
72 #[must_use]
73 pub fn memory_stores(&self) -> memory_stores::MemoryStores<'a> {
74 memory_stores::MemoryStores::new(self.client)
75 }
76
77 /// Agents sub-namespace (currently `create` only).
78 #[must_use]
79 pub fn agents(&self) -> agents::Agents<'a> {
80 agents::Agents::new(self.client)
81 }
82
83 /// Environments sub-namespace (full CRUD + archive).
84 #[must_use]
85 pub fn environments(&self) -> environments::Environments<'a> {
86 environments::Environments::new(self.client)
87 }
88}
89
90/// Beta header value required on every Managed Agents API request.
91pub(crate) const MANAGED_AGENTS_BETA: &str = "managed-agents-2026-04-01";
92
93/// Additional beta header value required for research-preview features
94/// like outcomes. Add **alongside** [`MANAGED_AGENTS_BETA`].
95#[allow(dead_code)] // used by the outcomes module once it lands
96pub(crate) const MANAGED_AGENTS_RESEARCH_PREVIEW_BETA: &str =
97 "managed-agents-2026-04-01-research-preview";