Build an Agent
Use the Agentor class to initialize an Agent providing the name, instructions, and tools. You can run the Agent with therun method or stream the response with the stream method.
GetWeatherTool() reads a free WeatherAPI.com key from WEATHER_API_KEY, and raises if it is not set.Connect to a tool
Agents has access to tools to perform tasks and get information from the world. You can define your own tools or use the ones provided by Celesto AI ToolHub.Stream the response
You can stream the response from the Agent with thestream method.
type: alwaysrun_item_stream_event.message: text — a tool’s return value, or the agent’s answer.tool_action:nameandtypefor a tool call (tool_called) or its result (tool_output).chunk: reserved, alwaysnull.reasoning: reserved, alwaysnull.raw_event: reserved, alwaysnull.
stream_chat streams steps, not tokens. For token-by-token text, see token-level streaming.Tracing and observability
Agentor supports tracing out of the box. Traces capture agent runs and tool calls so you can inspect them in Celesto.1
Set your Celesto API key
Add your Celesto API key to the environment.
2
Enable tracing
Choose the setup that fits your workflow.
- Automatic (recommended)
- Explicit
If
CELESTO_API_KEY is set, Agentor enables tracing automatically.After you run the agent, open the Celesto dashboard to view the trace.
Troubleshooting tracing setup
No traces appear in the dashboard
No traces appear in the dashboard
- Confirm you set
CELESTO_API_KEYin the same environment where you run the agent. - Confirm you opted in with
enable_tracing=True, an explicittracer=, ortracing=Trueon the call - tracing is off by default. - A failed upload is logged as a warning, never raised. Turn on warning-level logging to see it.
Next steps
Structured output
Return a validated Pydantic object instead of free text.
Durable runs
Save a run so another process can finish it after a crash.
Model providers
Point the agent at OpenRouter, Groq, Ollama, or any compatible endpoint.
Tool use
Build custom tools and connect MCP servers.
