Skip to main content

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

Project description

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

๐Ÿš€ Zero Boilerplate

  • Auto-schema generation: Type hints โ†’ OpenAI function schemas
  • Decorator-based tools: Just use @agent.tool
  • .env support: No manual environment handling

๐ŸŽจ Beautiful DX

  • Rich console logging: See agent reasoning in real-time
  • Helpful errors: No cryptic stack traces
  • 5-minute promise: From zero to working agent in 5 minutes

๐Ÿ”Œ Production Tools (v0.4 ๐Ÿ†•)

Built-in batteries for real-world apps:

  • Web Search (web_search): DuckDuckGo integration, no API key
  • File System (read_file, write_file): Safe file operations
  • HTTP/API (http_get, http_post): REST API integration
  • Database (query_db, create_table): SQLite queries & analytics

๐Ÿงช Type-Safe & Production-Ready

  • Streaming Responses (v0.4): Real-time text generation
  • Structured Outputs (v0.3): Return typed Pydantic models instead of strings
  • History Management (v0.3): Auto-truncates conversation to stay within token limits
  • Context/State (v0.3): Share data between tools without manual passing
  • Persistent Memory (v0.5 ๐Ÿ†•): Agents remember conversations across sessions
  • Error Retry (v0.5 ๐Ÿ†•): Automatic retry with exponential backoff
  • Full type inference support

๐Ÿ“š 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.6.0a0.tar.gz (25.8 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.6.0a0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file axon_framework-0.6.0a0.tar.gz.

File metadata

  • Download URL: axon_framework-0.6.0a0.tar.gz
  • Upload date:
  • Size: 25.8 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.6.0a0.tar.gz
Algorithm Hash digest
SHA256 337c1b604b4d7df9ae9b4443935abf3fff845dd124a9cb80fde1f110010f2bc7
MD5 495a713063937254246089c6bfd8c499
BLAKE2b-256 7738ad9d463aee2d32166ca34a2c05acd64d98f0b75418fea3574b9b606ace1c

See more details on using hashes here.

File details

Details for the file axon_framework-0.6.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for axon_framework-0.6.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba3e7fd50fcb730a6b5ba16601c40e15e4980c88f337751375bf016cc37b5ba8
MD5 c1ee36a0d30242d90b5f4cf9274962fb
BLAKE2b-256 35b27bbf93e89f204930cd04ceb0450c07371c10ac4d5697bd36070ccbad5b48

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