Skip to main content

Build Agentic AI Systems in minutes. Now with Multi-Agent Swarms! ๐Ÿ

Project description

Axon ๐Ÿง 

[!TIP] New Documentation Site is Live! ๐Ÿ“š Check out the full guides and tutorials at ilakhunov.github.io/axon

The "FastAPI" for AI Agents

Build typed, production-ready AI agents in minutes, not hours.

License: MIT Python 3.10+

Quick Start โ€ข Features โ€ข Examples โ€ข Documentation


๐ŸŽฏ Why Axon?

The Problem: Building AI agents today feels like configuring Apache in 1999.

  • LangChain? Powerful but complex (AbstractFactories everywhere).
  • Manual OpenAI API? Too much boilerplate for tools and state management.

The Solution: Axon makes agent development as simple as FastAPI makes API development.

from axon import Agent

agent = Agent("ResearchBot")

@agent.tool
def search_web(query: str) -> str:
    """Search the internet."""
    return duckduckgo_search(query)

response = agent.ask("Find the latest AI news")

No chains. No graphs. No configurations. Just Python.


โšก Quick Start

Installation

pip install axon-framework

Create Your First Agent (60 seconds)

1. Set up environment:

echo "OPENAI_API_KEY=sk-your-key-here" > .env

2. Create app.py:

from axon import Agent

bot = Agent("Assistant", system="You are a helpful AI assistant.")

@bot.tool
def calculate(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

print(bot.ask("What is 15 + 27?"))

3. Run:

python app.py

That's it! ๐ŸŽ‰


๐Ÿ›  Features

โšก Features (v0.8)

  • ๐Ÿง  Cognitive Architecture: Chains of Thought, Tool Use, and Memory.
  • โšก Async & Serving: Native async support and 1-line FastAPI deployment (agent.serve()).
  • ๐Ÿ” Observability: Trace agent execution and thoughts with built-in trace_viewer.html.
  • โš–๏ธ Evaluations: "LLM-as-a-Judge" framework for automated testing (axon.evaluation).
  • ๐Ÿ“š Context (RAG): Built-in knowledge retrieval from files (knowledge="...").
  • ๐Ÿ Multi-Agent Swarms: Intelligent Handoffs and shared Context.
  • ๐Ÿ› ๏ธ Developer CLI: Scaffold projects in seconds with axon new.

๐Ÿ“š Examples

Basic Math Agent

from axon import Agent

agent = Agent("MathBot")

@agent.tool
def multiply(a: int, b: int) -> int:
    """Multiply two numbers."""
    return a * b

print(agent.ask("What's 12 times 8?"))
# Agent calls multiply(12, 8) โ†’ "The result is 96"

Structured Output (v0.3 ๐Ÿ†•)

from axon import Agent
from pydantic import BaseModel

class Email(BaseModel):
    address: str
    confidence: float

agent = Agent("EmailBot")
result = agent.ask(
    "Extract email from: contact me at john@example.com",
    response_model=Email
)
print(result.address)  # "john@example.com"
print(result.confidence)  # 0.95

Context/State Management (v0.3 ๐Ÿ†•)

from axon import Agent, Context

agent = Agent("DataBot")

@agent.tool
def fetch_data(source: str, ctx: Context) -> str:
    """Fetch data and store in context."""
    data = get_data(source)
    ctx.set("data", data)  # Share with other tools
    return "Data fetched"

@agent.tool
def analyze(ctx: Context) -> str:
    """Analyze data from context."""
    data = ctx.get("data")  # Access shared state
    return f"Analysis: {analyze(data)}"

# Agent automatically passes data between tools!
agent.ask("Fetch data from database and analyze it")

Web Research Agent

from axon import Agent
from axon_tools import web_search, write_file

agent = Agent("Researcher")
agent.tool(web_search)
agent.tool(write_file)

agent.ask("Search for Python AI frameworks and save a summary to report.txt")
# โœ… Searches web, writes formatted report

More examples: See examples/ directory

Persistent Memory (v0.5 ๐Ÿ†•)

from axon import Agent

# Enable memory for agent
agent = Agent("MemoryBot", memory="./memory.db")

# Session 1
agent.ask("My name is Alice and I love Python")

# Session 2 (new instance, same memory!)
agent2 = Agent("MemoryBot", memory="./memory.db")
agent2.ask("What's my name?")
# โ†’ "Your name is Alice" โœจ Remembers!

Error Retry (v0.5 ๐Ÿ†•)

from axon import Agent, retry

agent = Agent("ReliableBot")

@agent.tool
@retry(max_attempts=3, backoff=2.0)
def flaky_api(url: str) -> str:
    """Call unreliable API with auto-retry."""
    return requests.get(url).json()

# Automatically retries on failure with exponential backoff!

More examples: See examples/ directory


๐ŸŽฏ Advanced Features

History Management (v0.3)

Control conversation token usage to prevent context overflow:

agent = Agent(
    "LongConversationBot",
    max_history_tokens=4000  # Auto-truncates when exceeded
)

# After many questions, old messages are automatically removed
# System message is always preserved

Custom Configuration

agent = Agent(
    name="CustomBot",
    system="You are a helpful assistant specialized in...",
    model="gpt-4o",  # or "gpt-4o-mini"
    max_history_tokens=2000
)

๐Ÿ”Œ Built-in Tools

Web Search

from axon_tools import web_search

@agent.tool
def search(query: str) -> str:
    return web_search(query, max_results=5)
  • Uses DuckDuckGo (no API key!)
  • Returns formatted results with URLs

File Operations

from axon_tools import read_file, write_file

@agent.tool
def save_data(filename: str, content: str) -> str:
    return write_file(filename, content)

๐Ÿ“ฆ Project Structure

axon/
โ”œโ”€โ”€ axon/              # Core framework
โ”‚   โ”œโ”€โ”€ core.py        # Agent class
โ”‚   โ”œโ”€โ”€ types.py       # Type definitions
โ”‚   โ””โ”€โ”€ utils.py       # Logging & utilities
โ”œโ”€โ”€ axon_tools/        # Built-in plugins
โ”‚   โ”œโ”€โ”€ web.py         # Web search
โ”‚   โ””โ”€โ”€ filesystem.py  # File operations
โ”œโ”€โ”€ examples/          # Demo scripts
โ”‚   โ”œโ”€โ”€ hello_world.py
โ”‚   โ”œโ”€โ”€ web_researcher.py
โ”‚   โ””โ”€โ”€ simple_file_demo.py
โ””โ”€โ”€ tests/             # Test suite

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Quick contributions:

  • ๐Ÿ› Report bugs via Issues
  • ๐Ÿ’ก Request features via Discussions
  • ๐Ÿ”ง Submit PRs for fixes or new tools

๐Ÿ—บ๏ธ Roadmap

  • v0.1: Core Agent + Tool decorator
  • v0.2: Plugin ecosystem (Web Search, File System)
  • v0.3: Production essentials (Structured Outputs, History Management, Context/State)
  • v0.4: Essential tools (Streaming, HTTP/API, Database)
  • v0.5: Intelligence & Memory (Persistent Memory, Error Retry, Plugin System) โœจ CURRENT
  • v0.6: Multi-agent collaboration
  • v1.0: Axon Studio (Visual debugging UI) + Enterprise features

๐Ÿ“– Documentation

๐Ÿง  Intelligence & Memory (v0.5 ๐Ÿ†•)

  • Persistent Memory: Chat history saved to SQLite (memory="path/to.db")
  • Auto-Retries: @retry decorator for flaky tools
  • Context Awareness: Agents remember user details across sessions

๐Ÿ Multi-Agent Swarms (v0.6 Alpha ๐Ÿ†•)

  • Swarm Orchestration: Manage teams of specialized agents
  • Intelligent Handoffs: Agents automatically transfer tasks to specialists
  • Shared Context: Memory shared across the entire swarm
from axon import Agent, Swarm, Handoff

triage = Agent("Triage")
billing = Agent("Billing")

@triage.tool
def transfer_to_billing(reason: str) -> Handoff:
    return Handoff(target_agent="Billing", context=reason)

swarm = Swarm([triage, billing])
swarm.run(triage, "I need a refund")

Core Concepts

Agent

The main orchestrator. Manages LLM calls, tool execution, and conversation history.

agent = Agent(
    name="MyBot",
    system="You are...",         # System prompt
    model="gpt-4o",               # OpenAI model
    max_history_tokens=4000       # Token limit (v0.3)
)

Tools

Functions that agents can call. Automatically registered with @agent.tool:

@agent.tool
def my_function(param: str) -> str:
    """This docstring becomes the tool description."""
    return f"Result: {param}"

Requirements:

  • Must have type hints
  • Must have a docstring
  • Return value should be string or serializable

Structured Outputs (v0.3)

Return typed Pydantic models instead of strings:

from pydantic import BaseModel

class Person(BaseModel):
    name: str
    age: int
    email: str

result = agent.ask(
    "Extract person info from: John Doe, 30, john@example.com",
    response_model=Person
)
# result is a Person instance with validated fields
print(result.name)  # "John Doe"

Context/State (v0.3)

Share data between tools:

from axon import Context

@agent.tool
def step_one(data: str, ctx: Context) -> str:
    """Process data and store result."""
    result = process(data)
    ctx.set("result", result)  # Store for next tool
    return "Done"

@agent.tool
def step_two(ctx: Context) -> str:
    """Use data from previous tool."""
    result = ctx.get("result")  # Retrieve
    return f"Final: {result}"

Context API:

  • ctx.set(key, value) - Store value
  • ctx.get(key, default=None) - Retrieve value
  • ctx.has(key) - Check if key exists
  • ctx.delete(key) - Remove key
  • ctx.clear() - Clear all data
  • ctx.keys() - Get all keys

History Management (v0.3)

Automatic conversation truncation:

agent = Agent("Bot", max_history_tokens=2000)

# When token count exceeds limit:
# - System message is preserved
# - Oldest messages are removed
# - Automatic truncation on each ask()

โš–๏ธ License

MIT License - see LICENSE for details


๐ŸŒŸ Star History

If Axon saves you time, give us a star! โญ


๐Ÿ™ Acknowledgments

Inspired by:

  • FastAPI: For proving that DX matters
  • LangChain: For pioneering agent frameworks
  • OpenAI: For making this possible

Built with โค๏ธ by developers, for developers

Report Bug โ€ข Request Feature โ€ข โญ Star


โญ Stargazers over time

Stargazers over time

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

axon_framework-0.9.0.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

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

axon_framework-0.9.0-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file axon_framework-0.9.0.tar.gz.

File metadata

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

File hashes

Hashes for axon_framework-0.9.0.tar.gz
Algorithm Hash digest
SHA256 81a81a992cfbc2013c559cc61b04d5b3bea1058438e5bb55eaa1643fd7060a65
MD5 c78da8a1ce686556ebdb3a9f2a6ebf2c
BLAKE2b-256 b3ae90881a1ee44c9a7c772239b1c276ae94919ade7006be772fbf28dc267b4f

See more details on using hashes here.

File details

Details for the file axon_framework-0.9.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for axon_framework-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fddbf229f63fb90aa7ac341be9ac7cd6f8f7dee6be4985d555778b62246366da
MD5 efdf0ccd500368ddae88b17bc65fd4e4
BLAKE2b-256 fe7922492777c0905a2f1bcaec65e9245ca0f43e55218eac777851b98925c77c

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