Skip to main content

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.6

⚡ 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 multiply(a: int, b: int) -> int:
    """Multiply two numbers."""
    return a * b

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

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.

Metadata

Release files for agentflow-ai 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentflow-ai 1.0.10
File Size Uploaded Provenance
agentflow_ai-1.0.10.tar.gz 16.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agentflow-ai 1.0.10
File Interpreter ABI Platform
agentflow_ai-1.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / agentflow_ai-1.0.10.tar.gz

Download URL agentflow_ai-1.0.10.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e70241bd52cd81c3aecbe5679f6ac0bab5500457270e29c8ae47a592debba8d4
BLAKE2b-256 checksum
How to use checksums
2f78014a9905f433a747b0568a2137260b2cf49d4cda25f61492a109390aae60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / agentflow_ai-1.0.10-py3-none-any.whl

Download URL agentflow_ai-1.0.10-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15781103107a7dc874255e11090f6ddeb62d4e953b48e3cea7f41057cfd1bdf6
BLAKE2b-256 checksum
How to use checksums
312ec870d8cfb538552632c6aaeac69ac474de1ca04e5bfdc45bc0f55fae87cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for agentflow-ai 1.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page