Basic Agent
Minimal agent setup
Streaming
Real-time responses
With Tools
Add capabilities
Requirements: Python 3.11 or higher
What Weโre Building
Weโll create an agent that can:- Search for information on any topic
- Analyze and summarize findings
- Save research reports to files
- Remember previous conversations
1
Set Up Your Project
First, create a new project directory:Install the required packages:
- uv (Recommended)
- pip
2
Create Your First Agent
Create a file called
agent.py:Choosing between
.stream() and .run():-
Use
agent.stream(thread)for:- Chat interfaces and real-time UIs
- Watching the agent work (great for debugging)
- Progressive UI updates as content generates
-
Use
await agent.run(thread)for:- Batch processing and automation
- Testing (when you just need the final result)
- Simple scripts where streaming isnโt needed
.stream() - itโs what makes agents feel alive!3
Run Your Agent
- uv
- python
- Thread Creation: A conversation thread is created to hold messages
- Message Processing: The agent receives your message and plans its approach
- Tool Usage: The agent uses web search tools to find information
- Response Generation: The agent synthesizes findings into a response
Understanding What Happened
When you stream, you get real-time events showing everything your agent does:Add Persistence to Your Agent
Letโs upgrade the agent to maintain conversation history:Interactive Research Session
Letโs create an interactive version where you can have a conversation:Understanding Tools
Letโs explore what tools your agent can use:Debugging Your Agent
Basic Logging
Enable detailed logging to see what your agent is doing:Advanced tracing with Weave
For comprehensive debugging and observability, Slide integrates with Weights & Biases Weave. Weave provides:- Visual traces of every agent action and decision
- LLM call tracking with inputs, outputs, and token usage
- Tool execution monitoring to see which tools were called and their results
- Performance insights to identify bottlenecks
- Error tracking with full context
Next steps
Youโve built your first agent! Hereโs what to explore next:Adding More Tools
Give your agent more capabilities
Streaming Responses
Build real-time interactive agents
Testing Your Agent
Ensure your agent behaves correctly
Deploy to Slack
Turn your agent into a Slack agent
Tips for Success
Clear Purpose Statements
Clear Purpose Statements
The
purpose parameter significantly affects agent behavior. Be specific:Tool Selection
Tool Selection
Only give your agent the tools it needs:
Error Handling
Error Handling
Always handle potential errors:
Processing Complex Files
Processing Complex Files
Your agent can handle various file types out of the box. For enhanced capabilities:
- Scanned PDFs: Install
popplerfor OCR support