Python SDK for AI Agent Assembly - A governance-native runtime for AI agents
Project description
Agent Assembly Python SDK
Python SDK for AI Agent Assembly — a governance-native runtime for AI agents. One init_assembly() call wires your agent into the policy gateway, applies pre-execution allow/deny on tool calls, and emits audit events without changing how the agent itself is written.
Why use it
- Framework adapters for LangChain, LangGraph, CrewAI, OpenAI Agents, Pydantic AI, Google ADK, and MCP servers — drop in, no SDK rewrites required.
- Pre-execution policy enforcement via the
FrameworkAdapterABC — block disallowed tool calls before they hit the LLM. - Audit trail — every tool call, prompt, and policy decision is emitted to the gateway with full agent lineage (parent / root / team).
- Native PyO3 fast path (optional) — drop into a Rust runtime client when you need sub-millisecond policy checks.
- Typed throughout — Pydantic models for every gateway payload, mypy strict on adapter base and registry.
Project status
Pre-1.0 (0.x) — published and usable, API not yet frozen. The SDK is released to
PyPI from the 0.0.x line (the version badge above reflects the current release). Until
1.0.0, minor versions may introduce breaking changes to the public surface; pin an exact
version (agent-assembly==0.0.x) if you need a stable contract.
- Releases — PyPI release history · GitHub releases
- Changelog — tracked via commits to
masteruntil the first tagged1.0release; see the release notes page. - Stability — the
init_assembly()entry point and the exception hierarchy are the most stable surface; framework adapters and the native fast path may evolve faster.
Requirements
- Python
>=3.12,<4.0(3.12, 3.13, 3.14 are tested in CI) - Rust toolchain (stable channel) — only required for building the optional native extension via
maturin develop. Pure-Python users do not need Rust. - uv ≥ 0.4 — recommended for managing the dev environment. (
pipworks for plain installs.)
Installation
Use the SDK in your project
The package is published on PyPI as agent-assembly:
pip install agent-assembly # pure-Python SDK
pip install 'agent-assembly[runtime]' # SDK + bundled aasm runtime binary (platform wheel)
agent-assembly[runtime] pulls a platform wheel (manylinux, macosx) that bundles the
aasm sidecar binary, so you don't need a separate runtime install. Plain agent-assembly
is the pure-Python client and expects an aasm runtime to be reachable some other way.
With uv:
uv add agent-assembly
To track unreleased changes, install from the master branch:
pip install git+https://github.com/ai-agent-assembly/python-sdk.git
Develop on the SDK
Clone the repo and sync the dev environment with uv:
git clone https://github.com/ai-agent-assembly/python-sdk.git
cd python-sdk
uv sync
To build the optional PyO3 extension locally (requires Rust):
uv tool run maturin develop --manifest-path native/aa-ffi-python/Cargo.toml --release
The pure-Python SDK works without the native extension — maturin develop is only needed if you want the sub-millisecond RuntimeClient fast path.
Quick Start
A governed LangChain ReAct agent that runs offline against a mock LLM. The example imports LangChain in addition to the SDK, so install both:
pip install agent-assembly langchain langchain-community
from langchain.agents import AgentExecutor, create_react_agent
from langchain.tools import Tool
from langchain_community.llms import FakeListLLM
from langchain_core.prompts import PromptTemplate
from agent_assembly import init_assembly
with init_assembly(
gateway_url="http://localhost:7391",
api_key="dev-key",
agent_id="quickstart-agent",
mode="sdk-only",
):
llm = FakeListLLM(responses=[
"Thought: I should look up the user.\nAction: whoami\nAction Input: alice\n",
"Thought: I have the answer.\nFinal Answer: alice is in engineering\n",
])
tools = [Tool(name="whoami", func=lambda name: f"{name} is in engineering", description="who")]
prompt = PromptTemplate.from_template(
"Use the tools.\n{tools}\nTool names: {tool_names}\nQ: {input}\n{agent_scratchpad}"
)
executor = AgentExecutor(agent=create_react_agent(llm, tools, prompt), tools=tools, max_iterations=2)
print(executor.invoke({"input": "Which team is alice on?"})["output"])
What this does:
init_assembly()registers the agent with the gateway and auto-loads the LangChain adapter — every tool call from now on goes through the policy gate.- The
FakeListLLMreplays canned responses so the example runs offline with no real LLM. - The
withblock tears down the gateway connection and unwinds adapter hooks on exit.
Public API
init_assembly(gateway_url, api_key, agent_id=None, mode="auto", *, control_plane_url=None) -> AssemblyContextasync GatewayClient.register_agent() -> dictasync GatewayClient.check_policy_compliance(action: str) -> dict- Exceptions:
AssemblyError,AgentError,PolicyError,GatewayError,ConfigurationError - Data models:
AgentConfig,AgentState,PolicyEvaluation
Control-plane routing
By default the SDK issues its HTTP routes (agent registration, policy checks,
topology edges) against gateway_url — the single-host OSS dev setup. Pass
control_plane_url to route those HTTP calls to a separate control-plane host
while gateway_url continues to serve the gRPC data path:
init_assembly(
gateway_url="http://gateway:7391",
control_plane_url="http://control-plane:9000",
api_key="dev-key",
)
Both URLs also resolve from the environment when their kwargs are omitted. Resolution order is explicit kwarg > env-var > unset:
| Argument | Env-var fallback |
|---|---|
gateway_url |
AA_GATEWAY_URL |
control_plane_url |
AA_CONTROL_PLANE_URL |
Error Handling
from agent_assembly import init_assembly
from agent_assembly.exceptions import ConfigurationError
try:
context = init_assembly(gateway_url="", api_key="my-api-key", agent_id="my-agent-001")
except ConfigurationError as exc:
print(f"Invalid configuration: {exc}")
Development
Run tests:
uv run pytest
Run integration tests:
uv run pytest -m integration
Lint and type-check:
uv run ruff check .
uv run mypy agent_assembly
Native Core Extension
Build and install the PyO3 extension locally:
uv tool run maturin develop --manifest-path native/aa-ffi-python/Cargo.toml --release
Validate native module import:
from agent_assembly._core import RuntimeClient, GovernanceEvent
Run opt-in native integration tests:
AAASM_RUN_NATIVE_CORE_TESTS=1 uv run pytest test/integration/test_native_core_runtime.py
AAASM_RUN_MATURIN_TESTS=1 uv run pytest test/integration/test_native_core_maturin.py
Documentation
- Project docs (rendered) — https://ai-agent-assembly.github.io/python-sdk/ (versioned via
mike; picklatestorstablefrom the version selector) - Quick Start — source — install and govern your first agent in five minutes (offline LangChain example).
- Core Concepts — source — the adapter pattern, native FFI vs. pure-Python, the
init_assembly()lifecycle, and modes/enforcement. Deep dive in Architecture. - Guides — Framework examples, Handling allow/deny decisions, Type checking.
- Configuration — source — gateway URL / API-key resolution, runtime modes, enforcement modes.
- API reference — rendered / source — auto-generated from package docstrings via
mkdocstrings. Per-module pages: Client, Exceptions, Models. - Compatibility & Versioning — source — Python versions, core-runtime tracking, release process, and ADRs.
- Troubleshooting — source — common integration errors and fixes.
Ecosystem
This SDK is one piece of the AI Agent Assembly project. Start from the organization profile to discover every repo, or jump directly:
| Project | What it is |
|---|---|
| agent-assembly | Core runtime — gateway, policy engine, eBPF, proxy, CLI. Also home of the protocol specification. |
| Documentation site | Canonical, cross-repo documentation hub for the whole project. |
| python-sdk | This repo — the Python SDK. |
| node-sdk · go-sdk | Sibling SDKs for TypeScript/Node and Go. |
| homebrew-agent-assembly | Homebrew tap for installing the aasm runtime CLI. |
| agent-assembly-examples | Runnable examples — learn by running small, framework-specific Python (and Node/Go) samples covering policy enforcement, approvals, audit, trace, and runtime workflows. |
The protocol specification and gateway behaviour the SDK targets live in the core runtime monorepo; see its README for the spec and architecture. For how this SDK stays in sync with the core runtime, see the Compatibility & Versioning docs.
Contributing
Please read CONTRIBUTING.md before opening a PR — it covers dev environment setup, framework adapter authoring, the test/lint command list, branch naming, and the PR checklist.
Support
- Bugs & feature requests — open a GitHub issue.
- Questions & usage help — start with the documentation site and the Troubleshooting guide, then open an issue if you're still stuck.
- Security — please do not file public issues for vulnerabilities. Report them privately via GitHub Security Advisories.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_assembly-0.0.1b3.tar.gz.
File metadata
- Download URL: agent_assembly-0.0.1b3.tar.gz
- Upload date:
- Size: 71.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
818d6987e86011ea90ab1de060f2071df1e03a74d343b557c0d05a78903fbc2b
|
|
| MD5 |
5a1ace0dd2cc186702ac693d279e3bcc
|
|
| BLAKE2b-256 |
b06d47a13fbf7395225a2c2e3611e8c095ff9f56b76255a14bd6522fe54dc038
|
Provenance
The following attestation bundles were made for agent_assembly-0.0.1b3.tar.gz:
Publisher:
release-python.yml on ai-agent-assembly/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_assembly-0.0.1b3.tar.gz -
Subject digest:
818d6987e86011ea90ab1de060f2071df1e03a74d343b557c0d05a78903fbc2b - Sigstore transparency entry: 1831560068
- Sigstore integration time:
-
Permalink:
ai-agent-assembly/python-sdk@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ai-agent-assembly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0b7f69b449aaece3a446617d17f2b3afd2fa70c3aabb6966eb1c65a648ac011
|
|
| MD5 |
18c134816d25790d546935768ecf3c26
|
|
| BLAKE2b-256 |
bc997141073833659d3d021e05f0d0f935f86c9806ccbcbc1b67f1b430e332f0
|
Provenance
The following attestation bundles were made for agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-python.yml on ai-agent-assembly/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
f0b7f69b449aaece3a446617d17f2b3afd2fa70c3aabb6966eb1c65a648ac011 - Sigstore transparency entry: 1831560600
- Sigstore integration time:
-
Permalink:
ai-agent-assembly/python-sdk@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ai-agent-assembly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d968fc879422fa0a6fe48bb7a7b34687414fa89ce889c1efee4e5d205cb60d1b
|
|
| MD5 |
f6e24e4a94315ddfc05578413843a3b6
|
|
| BLAKE2b-256 |
220a9a95fc5d872e872235aaf84092330f0ad9442ff31d9e558b24d745fda301
|
Provenance
The following attestation bundles were made for agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release-python.yml on ai-agent-assembly/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_assembly-0.0.1b3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
d968fc879422fa0a6fe48bb7a7b34687414fa89ce889c1efee4e5d205cb60d1b - Sigstore transparency entry: 1831560486
- Sigstore integration time:
-
Permalink:
ai-agent-assembly/python-sdk@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ai-agent-assembly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file agent_assembly-0.0.1b3-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: agent_assembly-0.0.1b3-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf99924468470952781991cb3cd3713a607735aca8a1185ac51b2dcb85570af8
|
|
| MD5 |
755ef85519b46818b743a14e9f8b61a4
|
|
| BLAKE2b-256 |
04e01e2b704c832d1c4c0131188f74ef6f2404ad42f32ef17e9f65e54f2a7e77
|
Provenance
The following attestation bundles were made for agent_assembly-0.0.1b3-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release-python.yml on ai-agent-assembly/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_assembly-0.0.1b3-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
cf99924468470952781991cb3cd3713a607735aca8a1185ac51b2dcb85570af8 - Sigstore transparency entry: 1831560218
- Sigstore integration time:
-
Permalink:
ai-agent-assembly/python-sdk@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ai-agent-assembly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file agent_assembly-0.0.1b3-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: agent_assembly-0.0.1b3-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 10.5 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48552225c966fd2ea7cf05cb269a8443d97feb1c726b7f26fea82e1b385bdc31
|
|
| MD5 |
0afec54f9a928b4ef05ffa53f0667031
|
|
| BLAKE2b-256 |
fa181fb55919d27f654edd3632d8da3567e15deb2c3567a33ae4c6640e533867
|
Provenance
The following attestation bundles were made for agent_assembly-0.0.1b3-cp312-cp312-macosx_10_12_x86_64.whl:
Publisher:
release-python.yml on ai-agent-assembly/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_assembly-0.0.1b3-cp312-cp312-macosx_10_12_x86_64.whl -
Subject digest:
48552225c966fd2ea7cf05cb269a8443d97feb1c726b7f26fea82e1b385bdc31 - Sigstore transparency entry: 1831560358
- Sigstore integration time:
-
Permalink:
ai-agent-assembly/python-sdk@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ai-agent-assembly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@4daf803e19f281a91cfbc1707c35ad73b1876c23 -
Trigger Event:
workflow_dispatch
-
Statement type: