Skip to main content

Production-grade AI agent runtime for deterministic, debuggable agent systems

Project description

Hanzo Agents SDK

Production-grade AI agent runtime for building deterministic, debuggable, and scalable agent systems.

Overview

Hanzo Agents SDK provides nine first-class abstractions for building AI agent systems:

  1. Agents - Encapsulate skills and tools with zero side-effects outside tool calls
  2. Tools - Perform side-effects and mutate state in a typed, inspectable way
  3. Networks - Orchestrate agent execution with deterministic routing
  4. State - Strongly-typed, validated state containers
  5. Routers - Control agent flow (deterministic or hybrid LLM-based)
  6. History - Chronological log for replay and audit
  7. Memory - Long-term storage (KV and vector)
  8. Models - Unified adapter interface for any LLM
  9. Deployment - Production-ready with telemetry, checkpointing, and scale

Quick Start

pip install hanzo-agents[all]

# Run an example network
hanzo-agents run examples/code_fix_network.py \
              --state '{"repo":"demo"}' \
              --model claude-3-opus

Core Concepts

Agents

from hanzo_agents import Agent, Tool
from typing import List

class PlanningAgent(Agent[ProjectState]):
    name = "planner"
    description = "Creates project plans"
    model = "model://anthropic/claude-3-haiku"
    
    tools: List[Tool] = [
        CreatePlanTool(),
        UpdatePlanTool(),
    ]

Tools

from hanzo_agents import Tool
from pydantic import BaseModel

class CreatePlanTool(Tool[ProjectState]):
    name = "create_plan"
    description = "Create a new project plan"
    
    class Parameters(BaseModel):
        tasks: List[str]
        timeline: str
    
    def handle(self, tasks: List[str], timeline: str, network):
        # Mutate state in a typed way
        network.state.plan = Plan(tasks=tasks, timeline=timeline)
        return f"Created plan with {len(tasks)} tasks"

Networks & Routers

from hanzo_agents import Network, State
from dataclasses import dataclass

@dataclass
class ProjectState(State):
    repo: str
    plan: Optional[Plan] = None
    tests_passed: bool = False
    done: bool = False

def project_router(network, call_count, last_result, stack):
    """Deterministic routing logic"""
    s = network.state
    if s.done or call_count > 50:
        return None
    if s.plan is None:
        return PlanningAgent
    if not s.tests_passed:
        return TestingAgent
    s.done = True
    return None

# Run the network
network = Network(
    state=ProjectState(repo="my-project"),
    agents=[PlanningAgent, TestingAgent, ReviewAgent],
    router=project_router
)
network.run()

Memory

# Long-term memory for context across runs
network = Network(
    state=state,
    agents=agents,
    router=router,
    memory_kv=SQLiteKV("project.db"),
    memory_vector=FAISSVector(dimension=1536)
)

# Agents can query memory
class ResearchAgent(Agent):
    async def run(self, state, history):
        # Pull relevant context
        context = await self.network.memory.vector.query(
            "previous security findings", 
            k=5
        )
        # Use in prompt...

CLI

The hanzo-agents CLI provides:

# Basic execution
hanzo-agents run network.py --state '{"key": "value"}'

# Model configuration
hanzo-agents run network.py --model gpt-4 --model-config config.yaml

# GPU selection
hanzo-agents run network.py --cuda 0

# Observability
hanzo-agents run network.py --json-lines --port 9464  # Prometheus

# Checkpointing
hanzo-agents run network.py --checkpoint state.chkpt
hanzo-agents run network.py --restore state.chkpt

Production Features

  • Type Safety: Full typing with generics for compile-time guarantees
  • Deterministic: Reproducible execution with explicit state mutations
  • Observable: OpenTelemetry tracing + Prometheus metrics built-in
  • Scalable: Horizontal scaling via stateless networks
  • Debuggable: Step-through debugging with history replay
  • Extensible: Plugin architecture for tools, models, and memory backends

Architecture

hanzo_agents/
├── core/
│   ├── agent.py       # Agent base class and registry
│   ├── tool.py        # Tool base class and decorators  
│   ├── state.py       # State validation and guards
│   ├── router.py      # Router types and helpers
│   ├── network.py     # Main orchestration loop
│   ├── history.py     # Interaction logging
│   ├── memory.py      # Memory backends (KV, vector)
│   └── model.py       # Model adapters and registry
├── contrib/           # Optional integrations
│   ├── chromadb.py    # ChromaDB vector store
│   ├── neo4j.py       # Neo4j graph memory
│   └── langchain.py   # LangChain compatibility
├── cli.py             # CLI entry point
└── examples/          # Example networks

License

MIT License - see LICENSE file for details.

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

hanzo_agents-0.1.0.tar.gz (76.6 kB view details)

Uploaded Source

Built Distribution

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

hanzo_agents-0.1.0-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

Details for the file hanzo_agents-0.1.0.tar.gz.

File metadata

  • Download URL: hanzo_agents-0.1.0.tar.gz
  • Upload date:
  • Size: 76.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for hanzo_agents-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ac769974dcb21d412308fd2aa06ca11c3391a5298773e80cd3d4893f4847bc1
MD5 2f59ffdd234804aab1ed3247a0f78c3d
BLAKE2b-256 039c9b79428a3dd1bcebfdb8b0738b562d7ebc0ab3d0faf20ca5b3cde367c330

See more details on using hashes here.

File details

Details for the file hanzo_agents-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hanzo_agents-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for hanzo_agents-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc7fff1be60764ed9bb4217d3c1fa806d97b976048ac098019eb1c32cb855cc9
MD5 63464db6575c4a6b3e7b0829e8a95824
BLAKE2b-256 aea71a92ab00ebd3339b7a84d3bd6715f36cee2e9a65373fcedcf5153c6dd259

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