
Skill
ai-python-subagents
implement subagent patterns in Python
Description
Use for the subagent-as-a-tool pattern.
SKILL.md
ai-python-subagents
Use a subagent tool when the parent model should choose when to call another agent.
@ai.tool
async def research(topic: str) -> ai.SubAgentTool:
child = ai.Agent(tools=[lookup])
messages = [
ai.system_message("Research briefly."),
ai.user_message(topic),
]
async with child.run(model, messages) as stream:
async for event in stream:
yield event
The parent model sees the child agent's final assistant text as the tool
result. The caller sees child events as ai.events.PartialToolCallResult.
Render nested output from event.value:
if isinstance(event, ai.events.PartialToolCallResult):
if isinstance(event.value, ai.events.TextDelta):
print(event.value.chunk, end="", flush=True)
Do not append child messages to the parent history yourself. The tool result
stores the child transcript as a MessageBundle.
For MessageBundle, preliminary output, and streaming tool details, use
ai-python-streaming-tools.
More skills from the ai-python repository
View all 9 skillsai-python-basics
build AI agents with Python SDK
Jul 29AgentsAI SDKLLMPythonai-python-custom-loop
build custom agent loops in Python
Jul 29AgentsAI SDKPythonai-python-custom-provider
implement custom AI SDK providers
Jul 29AI SDKPythonai-python-durable-execution
add durable execution to AI agents
Jul 29AgentsAI SDKPythonai-python-serverless-execution
build serverless AI SDK endpoints
Jul 29AI SDKPythonServerlessai-python-streaming-tools
stream AI SDK Python tool outputs
Jul 29AgentsAI SDKPython
More from Vercel Labs
View publisheragent-browser
automate browser interactions for AI agents
agent-browser
Jul 20AgentsAutomationBrowser Automationagentcore
run browser automation on AWS Bedrock
agent-browser
Jul 17AutomationAWSBrowser Automationcore
navigate and interact with web pages
agent-browser
Jul 26AgentsBrowser AutomationNavigationderive-client
reverse engineer internal APIs from browser traffic
agent-browser
Jul 20API DevelopmentAutomationBrowser AutomationWeb Scrapingdogfood
perform exploratory testing on web applications
agent-browser
Jul 17Browser AutomationDebuggingQATestingelectron
automate Electron desktop applications
agent-browser
Jul 17AgentsBrowser AutomationDesktop