Skip to content

Commit 90cd200

Browse files
release: 0.92.0 (#1348)
* feat(api): add support for Claude Managed Agents * release: 0.92.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent 8a0885d commit 90cd200

File tree

214 files changed

+15969
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+15969
-29
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.91.0"
2+
".": "0.92.0"
33
}

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 34
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-04225437444990f383d0581df2f07022baab6ad510de0f3a8bd6b07c38d83cc9.yml
3-
openapi_spec_hash: cae9199aabfd7b87f0ff2dcc10760c92
4-
config_hash: fcc34074db6eaf64bc99b578c6c82c61
1+
configured_endpoints: 72
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-69486316563eb49043ec1ef0b8e1d4164b6fadb58c7ae27477f9971448ede066.yml
3+
openapi_spec_hash: 24c3be07d605d11323afa51c7808fa00
4+
config_hash: 60af716d2229a28075dace69c52e5aa1

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.92.0 (2026-04-08)
4+
5+
Full Changelog: [v0.91.0...v0.92.0](https://github.com/anthropics/anthropic-sdk-python/compare/v0.91.0...v0.92.0)
6+
7+
### Features
8+
9+
* **api:** add support for Claude Managed Agents ([5b879a7](https://github.com/anthropics/anthropic-sdk-python/commit/5b879a7d929bd93332d777bed067be680819dfac))
10+
311
## 0.91.0 (2026-04-07)
412

513
Full Changelog: [v0.90.0...v0.91.0](https://github.com/anthropics/anthropic-sdk-python/compare/v0.90.0...v0.91.0)

api.md

Lines changed: 252 additions & 1 deletion
Large diffs are not rendered by default.

examples/agents.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env -S uv run python
2+
3+
import os
4+
5+
from anthropic import Anthropic
6+
7+
8+
def main() -> None:
9+
anthropic = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
10+
11+
# Create an environment
12+
environment = anthropic.beta.environments.create(
13+
name="simple-example-environment",
14+
)
15+
print("Created environment:", environment.id)
16+
17+
# Create an agent
18+
agent = anthropic.beta.agents.create(
19+
name="simple-example-agent",
20+
model="claude-sonnet-4-6",
21+
)
22+
print("Created agent:", agent.id)
23+
24+
# Create a session
25+
session = anthropic.beta.sessions.create(
26+
environment_id=environment.id,
27+
agent={"type": "agent", "id": agent.id, "version": agent.version},
28+
)
29+
print("Created session:", session.id)
30+
31+
# Send a prompt and stream events until the session goes idle
32+
print("Streaming events:")
33+
anthropic.beta.sessions.events.send(
34+
session.id,
35+
events=[
36+
{
37+
"type": "user.message",
38+
"content": [{"type": "text", "text": "Hello Claude!"}],
39+
}
40+
],
41+
)
42+
43+
with anthropic.beta.sessions.events.stream(session.id) as stream:
44+
for event in stream:
45+
print(event.to_json(indent=2))
46+
if event.type == "session.status_idle":
47+
break
48+
49+
50+
if __name__ == "__main__":
51+
main()

examples/agents_comprehensive.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/usr/bin/env -S uv run python
2+
3+
import os
4+
import time
5+
6+
from anthropic import Anthropic
7+
8+
MCP_SERVER_NAME = "github"
9+
MCP_SERVER_URL = "https://api.githubcopilot.com/mcp/"
10+
11+
PROMPT = (
12+
"Hi! List every tool and skill you have access to, grouped by where they "
13+
"came from (built-in toolset, custom tool, MCP server, skills)."
14+
)
15+
16+
17+
def main() -> None:
18+
anthropic = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
19+
20+
github_token = os.environ.get("GITHUB_TOKEN")
21+
if not github_token:
22+
raise RuntimeError(
23+
"GITHUB_TOKEN is required (use a fine-grained PAT with public-repo read only)"
24+
)
25+
26+
# Create an environment
27+
environment = anthropic.beta.environments.create(
28+
name="comprehensive-example-environment",
29+
)
30+
print("Created environment:", environment.id)
31+
32+
# Create a vault and store the MCP server credential in it
33+
vault = anthropic.beta.vaults.create(display_name="comprehensive-example-vault")
34+
print("Created vault:", vault.id)
35+
36+
credential = anthropic.beta.vaults.credentials.create(
37+
vault.id,
38+
display_name="github-mcp",
39+
auth={
40+
"type": "static_bearer",
41+
"mcp_server_url": MCP_SERVER_URL,
42+
"token": github_token,
43+
},
44+
)
45+
print("Created credential:", credential.id)
46+
47+
# Upload a custom skill
48+
skill_md_path = os.path.join(os.path.dirname(__file__), "greeting-SKILL.md")
49+
with open(skill_md_path, "rb") as skill_file:
50+
skill = anthropic.beta.skills.create(
51+
display_title=f"comprehensive-greeting-{int(time.time() * 1000)}",
52+
files=[("greeting/SKILL.md", skill_file, "text/markdown")],
53+
)
54+
print("Created skill:", skill.id)
55+
56+
# Create v1 of the agent with the built-in toolset, an MCP server, and a custom tool
57+
agent_v1 = anthropic.beta.agents.create(
58+
name="comprehensive-example-agent",
59+
model="claude-sonnet-4-6",
60+
system="You are a helpful assistant.",
61+
mcp_servers=[{"type": "url", "name": MCP_SERVER_NAME, "url": MCP_SERVER_URL}],
62+
tools=[
63+
{"type": "agent_toolset_20260401"},
64+
{"type": "mcp_toolset", "mcp_server_name": MCP_SERVER_NAME},
65+
{
66+
"type": "custom",
67+
"name": "get_weather",
68+
"description": "Look up the current weather for a city.",
69+
"input_schema": {
70+
"type": "object",
71+
"properties": {"city": {"type": "string"}},
72+
"required": ["city"],
73+
},
74+
},
75+
],
76+
)
77+
print("Created agent v1:", agent_v1.id)
78+
79+
# Patch the agent to v2 by adding skills; each update bumps the version
80+
agent = anthropic.beta.agents.update(
81+
agent_v1.id,
82+
version=agent_v1.version,
83+
skills=[
84+
{"type": "custom", "skill_id": skill.id},
85+
{"type": "anthropic", "skill_id": "xlsx"},
86+
],
87+
)
88+
print("Patched agent to v2:", agent.id)
89+
90+
versions = anthropic.beta.agents.versions.list(agent.id)
91+
print("Agent versions:", versions.data)
92+
93+
# Create a session pinned to v2; the vault supplies the MCP credential
94+
session = anthropic.beta.sessions.create(
95+
environment_id=environment.id,
96+
agent={"type": "agent", "id": agent.id, "version": agent.version},
97+
vault_ids=[vault.id],
98+
)
99+
print("Created session:", session.id)
100+
101+
# Send a prompt and stream events, answering the custom tool if called
102+
print("Streaming events:")
103+
anthropic.beta.sessions.events.send(
104+
session.id,
105+
events=[
106+
{"type": "user.message", "content": [{"type": "text", "text": PROMPT}]}
107+
],
108+
)
109+
110+
with anthropic.beta.sessions.events.stream(session.id) as stream:
111+
for event in stream:
112+
print(event.to_json(indent=2))
113+
if event.type == "agent.custom_tool_use" and event.name == "get_weather":
114+
anthropic.beta.sessions.events.send(
115+
session.id,
116+
events=[
117+
{
118+
"type": "user.custom_tool_result",
119+
"custom_tool_use_id": event.id,
120+
"content": [
121+
{"type": "text", "text": '{"temperature_c": 14}'}
122+
],
123+
}
124+
],
125+
)
126+
if (
127+
event.type == "session.status_idle"
128+
and event.stop_reason
129+
and event.stop_reason.type == "end_turn"
130+
):
131+
break
132+
133+
134+
if __name__ == "__main__":
135+
main()

examples/agents_with_files.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env -S uv run python
2+
3+
import os
4+
from pathlib import Path
5+
6+
from anthropic import Anthropic
7+
8+
9+
def main() -> None:
10+
anthropic = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
11+
12+
# Create an environment
13+
environment = anthropic.beta.environments.create(
14+
name="files-example-environment",
15+
)
16+
print("Created environment:", environment.id)
17+
18+
# Create an agent with the built-in toolset and an always-allow permission policy
19+
agent = anthropic.beta.agents.create(
20+
name="files-example-agent",
21+
model="claude-sonnet-4-6",
22+
tools=[
23+
{
24+
"type": "agent_toolset_20260401",
25+
"default_config": {
26+
"enabled": True,
27+
"permission_policy": {"type": "always_allow"},
28+
},
29+
}
30+
],
31+
)
32+
print("Created agent:", agent.id)
33+
34+
# Upload a file
35+
file = anthropic.beta.files.upload(
36+
file=Path(__file__).parent / "data.csv",
37+
)
38+
print("Uploaded file:", file.id)
39+
40+
# Create a session with the file mounted as a resource
41+
session = anthropic.beta.sessions.create(
42+
environment_id=environment.id,
43+
agent={"type": "agent", "id": agent.id, "version": agent.version},
44+
resources=[
45+
{
46+
"type": "file",
47+
"file_id": file.id,
48+
"mount_path": "data.csv",
49+
}
50+
],
51+
)
52+
print("Created session:", session.id)
53+
54+
resources = anthropic.beta.sessions.resources.list(session.id)
55+
print("Listed session resources:", resources.data)
56+
57+
# Send a prompt asking the agent to read the mounted file and stream events
58+
print("Streaming events:")
59+
anthropic.beta.sessions.events.send(
60+
session.id,
61+
events=[
62+
{
63+
"type": "user.message",
64+
"content": [
65+
{
66+
"type": "text",
67+
"text": "Read /uploads/data.csv and tell me the column names.",
68+
}
69+
],
70+
}
71+
],
72+
)
73+
74+
with anthropic.beta.sessions.events.stream(session.id) as stream:
75+
for event in stream:
76+
print(event.to_json(indent=2))
77+
if event.type == "session.status_idle":
78+
break
79+
80+
81+
if __name__ == "__main__":
82+
main()

examples/data.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
alpha,bravo,charlie
2+
1,2,3
3+
4,5,6

examples/greeting-SKILL.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: greeting
3+
description: Replaces ordinary greetings with nautical ones.
4+
---
5+
6+
Whenever the user greets you, respond with "Ahoy!" instead of "Hello".

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "anthropic"
3-
version = "0.91.0"
3+
version = "0.92.0"
44
description = "The official Python library for the anthropic API"
55
dynamic = ["readme"]
66
license = "MIT"

0 commit comments

Comments
 (0)