Skip to main content

Rust kernel with Python bindings for the Amplifier modular AI agent framework

Project description

Amplifier Core

The ultra-thin kernel of the Amplifier modular AI agent system -- now implemented in Rust with Python bindings via PyO3.

Purpose

Amplifier Core provides the mechanisms for building modular AI agent systems. Following the Linux kernel model, it's a tiny, stable center that rarely changes, with all policies and features implemented as replaceable modules at the edges.

The kernel is implemented in Rust for performance and type safety. Python bindings via PyO3 provide the same API that existing consumers already use -- existing Python code requires zero changes. Same imports, same API, same behavior.

Core responsibilities:

  • Module discovery and loading
  • Lifecycle coordination
  • Hook system and events
  • Session management
  • Stable contracts and APIs

Architecture

+---------------------------------------------------------------+
| RUST KERNEL (crates/amplifier-core/)                          |
| * Session lifecycle       * Event system                      |
| * Coordinator             * Hook registry                     |
| * Type-safe contracts     * Cancellation tokens               |
+----------------------------+----------------------------------+
                             | PyO3 bridge (bindings/python/)
                             v
+---------------------------------------------------------------+
| PYTHON BINDINGS (python/amplifier_core/)                      |
| * Same public API          * Pydantic models                  |
| * Module loader (Python)   * Backward-compatible imports      |
+----------------------------+----------------------------------+
                             | protocols (Tool, Provider, etc.)
                             v
+---------------------------------------------------------------+
| MODULES (Userspace - Swappable)                               |
| * Providers: LLM backends (Anthropic, OpenAI, Azure, Ollama) |
| * Tools: Capabilities (filesystem, bash, web, search)        |
| * Orchestrators: Execution loops (basic, streaming, events)  |
| * Contexts: Memory management (simple, persistent)           |
| * Hooks: Observability (logging, redaction, approval)        |
+---------------------------------------------------------------+

Rust Kernel

The kernel is implemented in Rust for performance and type safety. Key details:

  • Rust crate: crates/amplifier-core/ -- pure Rust kernel with all core types, traits, and engine logic
  • PyO3 bridge: bindings/python/ -- thin Python bindings that expose Rust types to Python
  • Python source: python/amplifier_core/ -- Pydantic models, module loader, and backward-compatible API surface

The RUST_AVAILABLE flag (on amplifier_core._engine) indicates whether the Rust engine loaded successfully. When available:

  • Top-level imports (from amplifier_core import AmplifierSession) return Rust-backed types
  • Submodule imports (from amplifier_core.session import AmplifierSession) return Python types for backward compatibility
  • HookRegistry uses the Rust implementation for all hook dispatch
  • CancellationToken uses the Rust implementation

For consumers, this is transparent -- the API is identical regardless of which implementation is active.

Design Philosophy

Mechanisms, Not Policies

The kernel provides capabilities without decisions:

Kernel Provides (Mechanism) Modules Decide (Policy)
Module loading Which modules to load
Event emission What to log, where
Session lifecycle Orchestration strategy
Hook registration Security policies

Litmus test: "Could two teams want different behavior?" -> If yes, it's policy -> Module, not kernel.

Stability Guarantees

  • Backward compatible: Existing modules continue working across kernel updates
  • Minimal runtime dependencies: Only pydantic, pyyaml, typing-extensions (unchanged for consumers)
  • Single maintainer scope: Can be understood by one person
  • Additive evolution: Changes extend, don't break

Installation

For consumers

pip install amplifier-core

This installs a pre-built wheel with the Rust kernel included. No Rust toolchain required.

For complete Amplifier installation and usage: -> https://github.com/microsoft/amplifier

For developers

Building from source requires the Rust toolchain:

# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Build and install in development mode
pip install maturin
maturin develop

# Or with uv
uv run maturin develop

See docs/RUST_CORE_TESTING.md for the full development setup guide.

Build dependencies: Rust 1.70+, maturin

Core Concepts

Session

Execution context with mounted modules and conversation state. Lifespan: initialize() -> execute() -> cleanup().

Mount Plan

Configuration dictionary specifying which modules to load and their configuration. Apps/bundles compile to Mount Plans.

Coordinator

Infrastructure context providing session_id, config access, hooks, and mount points. Injected into all modules.

Module Types

All modules use Python Protocol (structural typing, no inheritance required):

  • Provider - LLM backends (name, complete(), parse_tool_calls(), get_info(), list_models())
  • Tool - Agent capabilities (name, description, execute())
  • Orchestrator - Execution loops (execute())
  • ContextManager - Memory (add_message(), get_messages(), compact())
  • Hook - Observability (call(event, data) -> HookResult)

API Example

from amplifier_core import AmplifierSession

# Define mount plan (modules must be installed or discoverable)
config = {
    "session": {
        "orchestrator": "loop-basic",
        "context": "context-simple"
    },
    "providers": [
        {"module": "provider-anthropic"}
    ],
    "tools": [
        {"module": "tool-filesystem"},
        {"module": "tool-bash"}
    ]
}

# Create and use session
async with AmplifierSession(config) as session:
    response = await session.execute("List files in current directory")

Module Development

Modules implement protocols via structural typing (duck typing):

from amplifier_core.interfaces import Tool
from amplifier_core.models import ToolResult

class MyTool:
    """Implements Tool protocol without inheritance."""

    @property
    def name(self) -> str:
        return "my_tool"

    @property
    def description(self) -> str:
        return "Does something useful"

    async def execute(self, input: dict) -> ToolResult:
        """Execute tool with input dict."""
        return ToolResult(
            output=f"Processed: {input.get('param')}",
            error=None
        )

# Mount function (entry point)
async def mount(coordinator, config):
    tool = MyTool()
    await coordinator.mount("tools", tool, name="my_tool")

    async def cleanup():
        pass  # Cleanup resources

    return cleanup

Entry point (pyproject.toml):

[project.entry-points."amplifier.modules"]
my-tool = "amplifier_module_my_tool:mount"

For complete module development guide: -> https://github.com/microsoft/amplifier

Documentation

Rust/Python Type Mapping:

  • CONTRACTS.md - Authoritative Rust/Python type mapping for the PyO3 boundary

Module Contracts (Entry Point for Developers):

Specifications (Detailed Design):

Detailed Guides:

Philosophy:

Testing

# Rust kernel tests
cargo test -p amplifier-core

# Python tests (includes binding tests)
uv run pytest tests/ bindings/python/tests/ -q --tb=short

# Full coverage
uv run pytest tests/ bindings/python/tests/ --cov

# Validate Rust kernel integration
uv run python tests/validate_rust_kernel.py

Contributing

[!NOTE] This project is not currently accepting external contributions, but we're actively working toward opening this up. We value community input and look forward to collaborating in the future. For now, feel free to fork and experiment!

Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit Contributor License Agreements.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

amplifier_core-1.2.6-cp314-cp314t-win_arm64.whl (7.6 MB view details)

Uploaded CPython 3.14tWindows ARM64

amplifier_core-1.2.6-cp313-cp313t-win_arm64.whl (7.6 MB view details)

Uploaded CPython 3.13tWindows ARM64

amplifier_core-1.2.6-cp311-abi3-win_arm64.whl (7.6 MB view details)

Uploaded CPython 3.11+Windows ARM64

amplifier_core-1.2.6-cp311-abi3-win_amd64.whl (8.8 MB view details)

Uploaded CPython 3.11+Windows x86-64

amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

amplifier_core-1.2.6-cp311-abi3-macosx_11_0_arm64.whl (7.2 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

amplifier_core-1.2.6-cp311-abi3-macosx_10_12_x86_64.whl (8.1 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file amplifier_core-1.2.6-cp314-cp314t-win_arm64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 5cee149dcfc929aee9e6c21b7031a714db5bcf2dea4654320119482a69f08913
MD5 4608d00bb2299784a85b35650f787487
BLAKE2b-256 f55164b2502cced14569c2259f798287f314c88a9c5ecf06ac07d3fd2fc483cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp314-cp314t-win_arm64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amplifier_core-1.2.6-cp313-cp313t-win_arm64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp313-cp313t-win_arm64.whl
Algorithm Hash digest
SHA256 22a8979008c9cbd35fcdae3ae73f0df9dda0eefdbc55471aca45ede2d44977c5
MD5 ebdf3eb7a36f5581ba61114274a6f563
BLAKE2b-256 c50d916c4cec23a6c9f58f7a067bd7d50abefab05c536cfb381495cb233e4879

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp313-cp313t-win_arm64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amplifier_core-1.2.6-cp311-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp311-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 dc51e84344936fc5f10eaca6780c65436999309b40bbf17553d164b07d985839
MD5 a47836fdb0a171ebee4905cd792fcc42
BLAKE2b-256 9a0c38bcb48c5d54c5909325c9f04b4949c518354a67c7a5cf1d01b9bff795fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp311-abi3-win_arm64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amplifier_core-1.2.6-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 73afe22be1cba30abb2f5dc13be554a62a4d6d0951e1ffeab3f83326a5f2a515
MD5 b82859c4dc96ce072fee22d4361e0e49
BLAKE2b-256 3178fd2e6248a0b92bc972d3aa8599e330f5e92730b1b435a6d4e29d6f6f43d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp311-abi3-win_amd64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b19028618dc0cc492a3e3d438a5b12593b06bea59ca46a65b72ec5605af97636
MD5 ebe9c32730f4314538ce819c1c87d63e
BLAKE2b-256 54ffbffd1ade8ea316e0f763ff02c3fa982361c2e1746f97d3a318a2aea526b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7bc0dcfe6dac72072051711711ca93060039dc581c5f841a641dd82a84af5485
MD5 d45168c9ad3f255f9ca48e25baf4699a
BLAKE2b-256 c8720bb60eb5576b7c4aba0ca9ad4bdf2ce943f72843b5eea1f781be4797a62e

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amplifier_core-1.2.6-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d3a53259e4ec2cf9f00c039c935662b25cb8b88fdf76dc602e36ffe2f699dbd
MD5 f2b3386beb203410be3b3d960184f75f
BLAKE2b-256 5c1bfd8d21c3cd61e5eecc2ba15e7cc617dee897f9bdde7080f0270ccf0d03dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amplifier_core-1.2.6-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for amplifier_core-1.2.6-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3d03feb6f61540a0f1384beef902cabaaf81a6e8387b07ef47b683666a5f28e9
MD5 70fe96c578a4f1e9b37e77023a60a6c3
BLAKE2b-256 c5ee0bd6a8a879441f89a49a199619fe201479555c0cd2e0480858d9c14aed1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for amplifier_core-1.2.6-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: rust-core-wheels.yml on microsoft/amplifier-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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