Defining an agent
Create an agent by specifying a model provider, system prompt, and optional tools:Agent configuration
Required parameters:id- Unique identifier for the agentprovider- LLM provider (see supported providers below)model- Model name (e.g., “gpt-4o”, “claude-sonnet-4”)
system_prompt- Instructions that guide the agent’s behaviortools- List of tools the agent can calloutput_schema- Pydantic model for structured outputsstop_conditions- Conditions that terminate agent execution
Supported providers
openai- OpenAI (GPT-5, GPT-5-mini, GPT-4o, etc.)anthropic- Anthropic (Claude Sonnet, Claude Opus, etc.)gemini- Google Geminigroq- Groqfireworks- Fireworks AItogether- Together AIazure- Azure OpenAI
Running agents
Synchronous execution with agent.run()
Use agent.run() for complete execution:
- Agent receives your message
- LLM analyzes the request and decides if tools are needed
- If tools are needed, agent executes them. If multiple tool calls are needed, they are executed in parallel.
- Agent feeds tool results back to the LLM
- Process repeats until the agent has a final answer or hits a stop condition
- Returns the complete response
Provider-specific parameters
You can pass any keyword argument supported by your provider:Streaming with agent.stream()
Stream responses for real-time feedback:
- Real-time token streaming
- Access to intermediate tool calls
- Progress tracking
agent.stream():
Agent responses
Bothagent.run() and agent.stream() return response objects with useful information:
Agent durability
Agents in Polos are durable - they survive failures and resume from the last completed step. What gets persisted:- Tool call inputs and outputs
- LLM reasoning steps
- Conversation history
- Agent state
- No duplicate tool calls
- No wasted API tokens
- No lost progress
Using agents in workflows
Agents are workflows, so you can compose them with other workflow steps:Next steps
Core features:- Tools - Give agents the ability to take actions
- Streaming - Real-time response streaming
- Structured Outputs - Extract structured data
- Stop Conditions - Control when agents stop
- Conversation Memory - Multi-turn conversations
- Human-in-the-Loop - Approval workflows
- Guardrails - Safety and compliance
- Lifecycle Hooks - Customize agent behavior