Skip to main content

Minimalist Python framework for building AI agents

Project description

AgentFlow

AgentFlow Logo

Tests Python 3.9+ License: MIT PyPI

The minimalist Python framework for building AI agents

AgentFlow is a production-ready framework that makes building AI agents simple, testable, and extensible. Inspired by FastAPI's philosophy of developer experience first.

🚀 Key Features

  • 🧪 Best-in-class Testing - MockModel + AgentTestClient (FastAPI-inspired)
  • 🔌 Native MCP Support - First Python framework with MCP integration
  • ⚡ Async-First - Built on asyncio for maximum performance
  • 🛡️ Production-Ready - Robust loop with JSON auto-repair, timeout protection, loop detection
  • 🔧 Tool Ecosystem - Mix local Python tools with MCP servers seamlessly
  • 📦 Multi-LLM - Ollama, OpenAI, Mistral support out of the box
  • 💾 Flexible Memory - InMemory and FileMemory with custom backend support

📥 Installation

pip install agentflow-ai==1.0.0

⚡ Quick Start

Basic Usage

import asyncio
from agentflow import Agent

async def main():
    agent = Agent(model="llama3")
    response = await agent.arun("What is Python?")
    print(response)

asyncio.run(main())

With Tools

agent = Agent(model="gpt-4o")

@agent.tool
def calculate(expression: str) -> float:
    """Evaluate a mathematical expression."""
    return eval(expression)

response = await agent.arun("What is 123 * 456?")

With MCP Servers

from agentflow.mcp import MCPClient

# Connect to filesystem server
async with MCPClient(
    transport="stdio",
    command=["npx", "@modelcontextprotocol/server-filesystem", "/tmp"]
) as mcp:
    await agent.add_mcp_tools(mcp)
    response = await agent.arun("List files in /tmp")

🧪 Testing (Killer Feature)

from agentflow.testing import MockModel, AgentTestClient

# Test without real LLM calls
model = MockModel(responses=["Hello! I'm an AI assistant."])
agent = Agent(model=model)
client = AgentTestClient(agent)

response = client.run("Hello")
client.assert_response_contains("Hello")
# client.assert_tool_called("my_tool")  # Use this when testing tools

🆚 Why AgentFlow?

Feature AgentFlow LangChain CrewAI AutoGen
Easy Testing ✅ MockModel + TestClient
Native MCP ✅ First framework
Async-First Partial
Minimalist ✅ <700 LOC core
Production-Ready ✅ v1.0 Partial Partial

📚 Documentation & Examples

  • Documentation - Comprehensive guides and API reference
  • Examples - 8 complete examples covering all features

🏗️ Architecture

AgentFlow follows these principles:

  • Explicit > Magic - Clear APIs, no hidden behavior
  • Minimal by default - Start simple, add complexity when needed
  • Testable - Built-in mocking and assertion helpers
  • Async-first - Non-blocking I/O for performance

🔧 Requirements

  • Python 3.9+
  • httpx

📄 License

MIT License - see LICENSE file for details.

🙏 Credits

Created by Hamadi Chaabani

Inspired by:

  • FastAPI's developer experience
  • Anthropic's MCP vision
  • The Python async ecosystem

🔗 Ecosystem

⭐ Star History

If you find AgentFlow useful, please star it on GitHub!


AgentFlow v1.0 - Production-ready. Fully tested. Simply powerful.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentflow_ai-1.0.3.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentflow_ai-1.0.3-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file agentflow_ai-1.0.3.tar.gz.

File metadata

  • Download URL: agentflow_ai-1.0.3.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agentflow_ai-1.0.3.tar.gz
Algorithm Hash digest
SHA256 17cad899fd1bad536f3fd4e9f23ec369efb0c78e5f2bfd0b4822b4efe131f0b4
MD5 67ac8d0afd19552ae275772231d7abe3
BLAKE2b-256 7ee4bfff442f1c043ddbdd396e03830312efc1e5347229377ebcc731f7f710e8

See more details on using hashes here.

File details

Details for the file agentflow_ai-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: agentflow_ai-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agentflow_ai-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6618a2fcfdcdad025ae260c531df9054309de1f71f792fc977d5da7fd654a6e7
MD5 5277aca7da5705c98b31b097ec16db3f
BLAKE2b-256 c042a98d52a083222f062b79640c5ef387dfac8f1a2ba114eefd1f2d41ebb447

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page