Skip to main content

Python SDK for PACT-AX — multi-agent collaboration primitives

Project description

pact-ax-client

Python SDK for PACT-AX — multi-agent collaboration primitives.

pip install pact-ax-client

30-second quickstart

from pact_ax_client import Agent

agent = Agent("my-agent", base_url="http://localhost:8000")

# Declare what this agent can do
agent.register_capability("contract_review", description="Reviews NDAs and MSAs")

# Find the best trusted agent for a task
decision = agent.route("contract_review")
if decision.routed:
    # Hand off state and wait for acknowledgment
    result = agent.handoff(decision.best_agent, state_data={"doc": "..."})

    # Record the outcome so trust scores update
    agent.remember("contract_review",
                   partner_id=decision.best_agent,
                   outcome="positive")

What's inside

Primitive What it does
Capabilities Register/discover agent skills
Trust Weighted, persistent trust scores between agents
Router Route tasks to the best trusted+capable agent
Episodic Memory Record and recall past interactions
Handoff / Transfer Prepare → send → receive state packets
Dead Letter Queue Park failed deliveries for retry
Consensus Weighted-vote consensus across agents

Resource clients (advanced)

The Agent class is a façade over seven focused clients. Use them directly when you need full control:

from pact_ax_client import (
    CapabilityClient, TrustClient, RouterClient,
    MemoryClient, DLQClient, ConsensusClient, TransferClient,
    HttpClient, Vote,
)

http = HttpClient(base_url="http://localhost:8000")

# Capabilities
caps = CapabilityClient(http)
caps.register("agent-a", "tax_analysis", tags=["finance"])
candidates = caps.find("tax_analysis")

# Trust
trust = TrustClient(http)
ts = trust.get("agent-a", "agent-b")
print(ts.score, ts.recommendation)

# Routing
router = RouterClient(http)
decision = router.route(from_agent="orch", skill="contract_review", min_trust=0.6)
print(decision.best_agent, decision.strategy_used)

# Episodic Memory
mem = MemoryClient(http)
ep = mem.record("agent-a", "reviewed_nda", partner_id="agent-b", outcome="positive")
episodes = mem.recall("agent-a", outcome="positive", limit=10)

# Dead Letter Queue
dlq = DLQClient(http)
entry = dlq.enqueue("pkt-xyz", "agent-a", "agent-b", reason="timeout")
dlq.retry(entry.id)

# Consensus
consensus = ConsensusClient(http)
votes = [Vote("agent-a", "deploy", 0.9), Vote("agent-b", "deploy", 0.75)]
result = consensus.run(votes)
print(result.reached, result.winning_decision)

Error handling

from pact_ax_client.exceptions import NotFoundError, ConflictError, ValidationError, ServerError

try:
    ts = agent.get_trust("unknown-agent")
except NotFoundError:
    print("agent not found")
Exception HTTP status
NotFoundError 404
ConflictError 409
ValidationError 422
ServerError 500

Async support

from pact_ax_client._http import AsyncHttpClient
from pact_ax_client.capabilities import CapabilityClient

async with AsyncHttpClient(base_url="http://localhost:8000") as http:
    caps = CapabilityClient(http)
    result = await caps.register_async("agent-a", "contract_review")

Development

git clone https://github.com/neurobloomai/pact-ax-client
cd pact-ax-client
pip install -e ".[dev]"
pytest tests/ -v

License

MIT © NeuroBloom.ai

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

pact_ax_client-0.1.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

pact_ax_client-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pact_ax_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c1afadac80cdd2c33a858e170cdac6d7161beb84335be09a85f4a92593a8631
MD5 4e48ecfffc1443d955fba34970197817
BLAKE2b-256 43ec10ced0006d31cb83eb529fd103e3600fcdd0bbbb10f6faa6666747ae109b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pact_ax_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c51ede347d2dd37db13797d9a3d347660804e693dce153b3d7e1ec75821e3ef
MD5 1e05f6a8fe4d1a1569c082b7517a7307
BLAKE2b-256 ae3010b4f401c01dbf76f15a8a054c45e05110978e9418b539248b000746d1f3

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