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:
Triggering agents from Slack
You can trigger agents directly from Slack by @mentioning your bot. The agent’s output streams back to the originating Slack thread.@sales-agent is the ID of the agent you want to trigger. The bot routes the message to the right agent and streams the response back to the same thread.
To set this up, create a Slack app, configure event subscriptions, and register the app with your orchestrator. See Slack Integration for the full setup guide.
Sandbox tools
Give agents the ability to write code, run shell commands, and explore a codebase inside a controlled environment. A single call tosandboxTools() creates six tools (exec, read, write, edit, glob, grep) that share an execution environment.
| Environment | Isolation | Best for |
|---|---|---|
docker | Container | Production, untrusted code |
local | None (host machine) | Development, trusted agents |
e2b (coming soon) | Cloud sandbox | Cloud-native deployments |
exec tool supports security modes to control which commands run without approval: allow-always (default for Docker), allowlist (pattern-based), and approval-always (default for local). See Sandbox for the full configuration reference.
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
- Sandbox - Isolated execution environments for code and shell commands
- Streaming - Real-time response streaming
- Structured Outputs - Extract structured data
- Slack Integration - Trigger agents from Slack
- 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