Mamba Agents¶
A simple, extensible AI Agent framework built on pydantic-ai.
Installation¶
Quick Start¶
from mamba_agents import Agent, AgentSettings
# Load settings from env vars, .env, ~/mamba.env, config.toml
settings = AgentSettings()
# Create agent using settings
agent = Agent(settings=settings)
# Run the agent - context and usage are tracked automatically
result = await agent.run("What files are in the current directory?")
print(result.output)
# Check usage and cost
print(agent.get_usage()) # TokenUsage(prompt_tokens=..., request_count=1)
print(agent.get_cost()) # Cost in USD
Features¶
-
Agent Basics
Thin wrapper around pydantic-ai with tool-calling support and automatic context management.
-
Built-in Tools
Filesystem, glob, grep, and bash operations with security controls.
-
MCP Integration
Connect to Model Context Protocol servers (stdio and SSE transports).
-
Token Tracking
Track usage with tiktoken, estimate costs automatically.
-
Message Analytics
Query, filter, export, and visualize conversation history with rich formatting.
-
Context Compaction
5 strategies to manage long conversations without losing important context.
-
Workflows
Orchestration patterns for multi-step execution (ReAct, Plan-Execute, etc.).
-
Model Backends
OpenAI-compatible adapter for Ollama, vLLM, LM Studio.
-
Observability
Structured logging, tracing, and OpenTelemetry hooks.
Choose Your Path¶
-
New to Mamba Agents?
Get up and running in under 5 minutes with the quick start guide.
-
Want to use local models?
Set up Ollama, vLLM, or LM Studio for offline inference.
-
Building a code assistant?
Step-by-step tutorial for building an AI coding assistant.
-
Need multi-step workflows?
Learn the ReAct pattern for complex reasoning tasks.
Quick Reference¶
| Use Case | Import |
|---|---|
| Basic agent | from mamba_agents import Agent |
| With settings | from mamba_agents import Agent, AgentSettings |
| Built-in tools | from mamba_agents.tools import read_file, run_bash, glob_search |
| ReAct workflow | from mamba_agents.workflows import ReActWorkflow, ReActConfig |
| Token tracking | from mamba_agents.tokens import TokenCounter, CostEstimator |
| Message analytics | from mamba_agents import MessageQuery, print_stats |
| MCP servers | from mamba_agents.mcp import MCPClientManager, MCPServerConfig |
Explore the Docs¶
-
Getting Started
Install the package and configure your environment.
-
User Guide
Learn how to use all the features of Mamba Agents.
-
Tutorials
Step-by-step guides for common use cases.
-
Concepts
Understand the architecture and design patterns.
-
API Reference
Complete reference for all classes and functions.