Skip to main content

Python SDK for Axon Protocol — persistent memory, coordination, and reasoning receipts for AI agents

Project description

Axon Protocol — Python SDK (axon-protocol)

Official Python client library for integration with the Axon core server. Handles semantic memory, coordination locks, and tamper-proof reasoning receipts for multi-agent AI environments.


Installation

Install the library locally:

pip install axon-protocol

Quickstart

Async Usage

import asyncio
from axon import AxonClient

async def main():
    async with AxonClient(api_key="axon-...", project_id="my-project") as axon:
        # Store memory
        await axon.memory.store("User prefers dark mode")
        
        # Search memory
        results = await axon.memory.search("ui preferences")
        print(results.results[0].content)

        # Acquire lock
        async with axon.lock("resource_1"):
            print("Lock held!")

asyncio.run(main())

Sync Usage

from axon import AxonSyncClient

with AxonSyncClient(api_key="axon-...", project_id="my-project") as axon:
    # Store memory
    axon.memory.store("User prefers dark mode")
    
    # Search memory
    results = axon.memory.search("ui preferences")
    print(results.results[0].content)

    # Acquire lock
    with axon.lock("resource_1"):
        print("Lock held!")

Features

A. Persistent Memory (Semantic Vector Search)

Store memories and query them with semantic similarity matching:

# Async
memory_id = await axon.memory.store(
    content="The API service key is stored in the vault.",
    tags={"category": "vault"},
    scope="project",
    ttl=3600  # auto-expire in 1 hour
)

results = await axon.memory.search(
    query="Where is the API key?",
    limit=5,
    min_similarity=0.6
)

B. Resource Locking (Mutex)

Prevent race conditions in multi-agent environments. Use the lock context manager to automatically release locks:

# Sync Lock Context Manager
with axon.lock("resource_lock", timeout=60) as lock:
    # Exclusive access section
    print(f"Lock acquired, expires at: {lock.expires_at}")

C. Reasoning Steps Recording

Generate cryptographically chained, signed receipts validating agent reasoning processes:

# Async receipt creation
receipt = await axon.receipts.create(
    input="Fix the login bug in auth.py",
    steps=[
        ReasoningStep(thought="Read the login function"),
        ReasoningStep(
            thought="Found missing token validation",
            tool_called="read_file",
            result="Null check missing at line 47"
        )
    ],
    output="Bug fixed"
)

# Automated decoration
@axon.receipts.track(input_param="task")
async def agent_function(task: str, steps_logger=None) -> str:
    steps_logger.add(thought="Analyzing the task")
    return "Done"

D. Real-Time Events Stream

Listen to event streams (like memory additions or lock releases) happening across your project:

# Async stream
async for event in axon.events.listen():
    print(f"Event Captured: {event['event_type']}")

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_protocol-0.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

axon_protocol-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: axon_protocol-0.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for axon_protocol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9a958c08e5d9629466bda41fe7164db9963db1d175d086bbfd35d17526a60910
MD5 8548e9814addc319bbb792ee899baca9
BLAKE2b-256 4385b92f050ca3abf50fa3f0c37fc4850d290948f07ea2a63ecb45a743937dc3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: axon_protocol-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for axon_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64dc49878ecb016bb59fa605c659568aa11664096cb91995f1c21c2a7347e58a
MD5 ce8ebca3d827c3783c12741b4daf9698
BLAKE2b-256 5248fcb5b9a6c31907ce13d2e65948c0898eaf85158b6fadaa522cf5d4e15aa4

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