Skip to main content
This step-by-step guide shows how to start with your first agent and progressively add tools, debugging, reasoning, knowledge, and more. Each section introduces a single capability, so you can follow the full path or jump to the parts most useful to you.

Journey Overview

Here’s a quick map of the stages and modules:

Foundation

Your first chat agent using Agent, Backend, and Tool modules

Debugging

Add logging and monitoring to debug your agent’s behavior

Requirements

Add reasoning rules, guardrails, and user permissions

Knowledge

Ground your agent in data with RAG capabilities

Orchestration

Coordinate teams of specialized agents with Workflows

Production

Scale with caching and error handling

Integration

Expose agents as services (MCP, Agent Stack, A2A, IBM wxO)

Before You Start

  • Python 3.11+
  • BeeAI Framework: pip install 'beeai-framework[wikipedia]'
  • Ollama running locally: Download Ollama
  • Model downloaded: ollama pull granite3.3
You can also use other LLM providers like OpenAI, Anthropic, or watsonx - see Backend to learn more about supported providers.

Foundation

Your First Agent

Relevant Modules: Agent, Backend
Let’s start with the simplest possible agent - one that can respond to messages.
Try it:
  1. Save as simple_agent.py
  2. Run python simple_agent.py
  3. Test different prompts
Troubleshooting
Verify it’s running: ollama list
Start the service: ollama serve
Pull the model: ollama pull granite3.3
List available models: ollama list
Create an alias: If your granite model doesn’t have the name granite3.3 give it the alias by trying this command in your terminal ollama cp <existing model name> <alias>
Update to the latest version: pip install --upgrade beeai-framework
Check Python version: python --version (must be >= 3.11)

Add Real-World Knowledge

Related Module: Tools
Give your agent the ability to access real-world information, external systems, or running code by adding tools.
Try these prompts:
  • “What’s the weather in different cities around the world?”
  • “Tell me about quantum computing and the current weather in CERN’s location”
  • “Compare the weather in New York and London, then tell me about their geographical similarity”
Learn more about the RequirementAgent, BeeAI’s suggested agent implementation for reliability and control over agent behavior.

Debugging

Related Modules: Emitter, Events, Observability.
Knowing what your application is doing is essential from the very start. The BeeAI Framework is based on the event system; each component in the framework emits events throughout its execution. You can listen and alter these events to build custom logic.

Framework Insights

The most simple way to see what’s happening in your application is by using GlobalTrajectoryMiddleware which listens to all events and prints them to the console.
Middleware can be attached per-run (affects only that run) or at agent construction (applies to all runs, no need to attach each time).

Catching events

Sometimes you want to react to specific events. To see which events are emitted, you can use the on function.
Listening for all events can be noisy. Filter to the events you are interested in capturing.
Alternatively, you can listen for events on the class itself rather than for a specific run.
All events and appropriate typings are stored in the events.py file in the given module.All emitters inherit from the root emitter, which is accessible through Emitter.root(). You can use this to monitor all events happening in the application.

Logging

Relevant Module: Logger
Logging is a way to provide visibility into the state of your application. Set the Logger level of granularity and place logging statements at key points throughout your agent process.
Logger Output: Traditional log messages with timestamps

OpenTelemetry / OpenInference

Logging to the console is great for development, but it’s not enough for production monitoring. You can easily let the framework send traces and metrics to external platforms like Arize Phoenix, LangFuse, LangSmith, and more.
To run this step: pip install openinference-instrumentation-beeai opentelemetry-sdk opentelemetry-exporter-otlp

Set the Endpoint

Set the OTEL_EXPORTER_OTLP_ENDPOINT environment variable. Some vendors also need API kesy like OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer <token>
Run your application and you should see traces and metrics in your selected dashboard.

Enforce Rules with the RequirementAgent

Use requirements to control the agent’s behavior. Let’s add the ThinkTool and set up a ConditionalRequirement to enforce rules on when and how tools should be used.
Learn more about the RequirementAgent
Learn more about Requirements and see examples in documentation

Request User Permission with the AskPermissionRequirement

Add user permission for when you want an action to be human validated before being executed:
In the console, the output looks like:

Knowledge

Now it’s time to integrate data. from a vector store using RAG (retrieval augmented generation)
Relevant Module: RAG
Install the RAG extras (if you haven’t already): pip install "beeai-framework[rag]"
Pull the nomic-embed-text model in Ollama.
Create synthetic or non-synthetic Markdown files to ingest into your vector store.
Let’s give your agent access to a knowledge base of documents.

Setup the Vector Store, Pre-process, and Load the Documents

  1. Create a new file and name it step1_knowledge_base
  2. Copy the following code into the file and replace the file_paths with your own files

Create RAG-Enabled Agent

  1. Create a new file that imports the helper functions from the step1_knowledge_base file and uses the vector store setup in the previous step
  2. Copy the following code into a new file and replace the file_paths with your own paths
  1. Add some markdown files with information about your company/project
  2. Ask questions that should be answered from your documents
  3. Compare how responses differ with vs. without the knowledge base or when using different pre-processing strategies

Orchestration

Relevant Module: Workflows

Multi-Agent Hand-offs

Create a team of specialized agents that can collaborate:
  1. Ask the coordinator mixed questions: “What’s the weather in Paris and tell me about its history?”
  2. Test how it decides which agent to use
  3. Try complex queries that need multiple specialists

Advanced Workflows

For complex, multi-step processes, a more advanced workflow system is coming soon! Join the discussion here

Production

Now it’s time for production-grade features.

Caching for Speed & Efficiency

Relevant Module: Cache
Caching helps you cut costs, reduce latency, and deliver consistent results by reusing previous computations. In BeeAI Framework, you can cache LLM responses and tool outputs.
Caching the entire agent isn’t practical—every agent run is usually unique. Instead, focus on caching the components inside your agent.
1. Caching LLM Calls Configure a cache on your LLM to avoid paying for repeated queries:
2. Caching Tool Outputs Many tools query APIs or perform expensive lookups. You can attach a cache directly:
3. Using Cached Components in an Agent
Agent-level caching is rarely effective because every input is usually unique. Focus on caching LLMs and tools individually for best performance.

Handle Errors Gracefully

Relevant Module: Errors
Make your system robust with comprehensive error management:

Integration

Relevant Module: Serve, MCP, A2A, IBM watsonX Orchestrate

Model Context Protocol (MCP)

Expose your agent as an MCP server:

Agent Stack

Expose your agent as a Agent Stack server:
Make sure you have done the following:pip install 'beeai-framework[a2a]' 'beeai-framework[agentstack]' and you have a compatible version of uvicorn installed.

Agent2Agent (A2A) Protocol

Expose your agent as an A2A server:
Make sure you have done the following:pip install 'beeai-framework[a2a]' and you have a compatible version of uvicorn installed.

IBM watsonx Orchestrate

Expose your agent as an IBM watsonx Orchestrate server:

What’s Next?

Congratulations! You’ve built a complete AI agent system from a simple chat bot to a production-ready, multi-agent workflow with knowledge bases, caching, error handling, and service endpoints. Each module page includes detailed guides, examples, and best practices. Here are some next steps:
  1. Explore Modules: Dive deeper into specific modules that interest you
  2. Scale Your System: Add more agents, tools, and knowledge bases
  3. Custom Tools: Build your own tools for domain-specific functionality
The framework is designed to scale with you. Start simple, then grow your system step by step as your needs evolve. You now have all the building blocks to create sophisticated and reliable AI agent systems!