Skip to content

Commit e516812

Browse files
committed
Delete ai.agent factory function
1 parent f34f6a4 commit e516812

19 files changed

Lines changed: 39 additions & 53 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def contact_mothership(query: str) -> str:
3737

3838
async def main() -> None:
3939
model = ai.get_model("anthropic/claude-sonnet-4")
40-
agent = ai.agent(tools=[contact_mothership])
40+
agent = ai.Agent(tools=[contact_mothership])
4141

4242
messages = [
4343
ai.system_message(

docs/ai-python/content/docs/basics/agents.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def contact_mothership(query: str) -> str:
3030

3131
async def main() -> None:
3232
model = ai.get_model("anthropic/claude-sonnet-4")
33-
agent = ai.agent(tools=[contact_mothership])
33+
agent = ai.Agent(tools=[contact_mothership])
3434
messages = [
3535
ai.system_message(
3636
"Use the contact_mothership tool when asked about the future."

docs/ai-python/content/docs/basics/subagents-and-multi-agent.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mothership_model = ai.get_model("anthropic/claude-sonnet-4")
2020
@ai.tool
2121
async def ask_mothership(topic: str) -> ai.SubAgentTool:
2222
"""Ask a specialist agent for mothership guidance."""
23-
sub_agent = ai.agent()
23+
sub_agent = ai.Agent()
2424
sub_messages = [
2525
ai.system_message("Answer as the mothership operations desk."),
2626
ai.user_message(topic),

docs/ai-python/content/docs/basics/tools.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ tools = await ai.mcp.get_http_tools(
167167
headers={"Authorization": "Bearer your_access_token_here"},
168168
)
169169

170-
agent = ai.agent(tools=tools)
170+
agent = ai.Agent(tools=tools)
171171
```
172172

173173
Use `ai.mcp.get_stdio_tools` for subprocess-based MCP servers.

docs/ai-python/content/docs/reference/ai/index.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,19 @@ Part builder exports:
236236

237237
## Tools and Agents
238238

239-
### agent
239+
### Agent
240240

241-
`agent` creates an `Agent`.
241+
`Agent` runs the default agent loop.
242242

243243
```python
244-
agent = ai.agent(tools=[contact_mothership])
244+
agent = ai.Agent(tools=[contact_mothership])
245245
```
246246

247247
Arguments:
248248

249249
- `tools`: Optional `AgentTool` values from `tool` and schema-only `Tool`
250250
declarations for provider-executed tools.
251251

252-
Returns `Agent`.
253-
254252
### AgentTool
255253

256254
`AgentTool` binds a model-facing `Tool` declaration to an executable Python
@@ -264,7 +262,7 @@ tool.validator
264262
tool.require_approval
265263
```
266264

267-
Pass `AgentTool` values to `agent(tools=[...])`.
265+
Pass `AgentTool` values to `Agent(tools=[...])`.
268266

269267
### Context
270268

docs/ai-python/content/docs/reference/mcp.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ uv add "ai[mcp]"
1616
## get_stdio_tools
1717

1818
`get_stdio_tools` starts an MCP server subprocess and returns `AgentTool`
19-
values that can be passed to `ai.agent`.
19+
values that can be passed to `ai.Agent`.
2020

2121
```python
2222
tools = await ai.mcp.get_stdio_tools(
@@ -35,7 +35,7 @@ Arguments:
3535
## get_http_tools
3636

3737
`get_http_tools` connects to an MCP HTTP server and returns `AgentTool` values
38-
that can be passed to `ai.agent`.
38+
that can be passed to `ai.Agent`.
3939

4040
```python
4141
tools = await ai.mcp.get_http_tools("https://example.com/mcp")

skills/ai-python-basics/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def get_weather(city: str) -> str:
5959

6060
async def main() -> None:
6161
model = ai.get_model("anthropic/claude-sonnet-4")
62-
agent = ai.agent(tools=[get_weather])
62+
agent = ai.Agent(tools=[get_weather])
6363
messages = [
6464
ai.system_message("Use tools when useful."),
6565
ai.user_message("What is the weather in San Francisco?"),

skills/ai-python-streaming-tools/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Use `ai.SubAgentTool` when a tool runs another agent and streams its events.
5050
```python
5151
@ai.tool
5252
async def research(topic: str) -> ai.SubAgentTool:
53-
researcher = ai.agent()
53+
researcher = ai.Agent()
5454

5555
messages = [
5656
ai.system_message("Research briefly."),

skills/ai-python-subagents/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ agent.
1313
```python
1414
@ai.tool
1515
async def research(topic: str) -> ai.SubAgentTool:
16-
child = ai.agent(tools=[lookup])
16+
child = ai.Agent(tools=[lookup])
1717
messages = [
1818
ai.system_message("Research briefly."),
1919
ai.user_message(topic),

src/ai/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ToolCall,
1111
ToolRunner,
1212
abort_pending_hook,
13-
agent,
1413
cancel_hook,
1514
hook,
1615
mcp,
@@ -176,7 +175,6 @@
176175
"UnsupportedProviderError",
177176
"VideoParams",
178177
"abort_pending_hook",
179-
"agent",
180178
"assistant_message",
181179
"cancel_hook",
182180
"content_output",

0 commit comments

Comments
 (0)