ahm-shield
Python SDK for Agent Health Monitor — trust-routed agent payment decisions.
Sits in front of agent payment flows and automates trust-routed decisions using AHM's scoring API.
Install
pip install ahm-shield
# with FastAPI middleware support
pip install ahm-shield[fastapi]
Quick start
Pattern A — Explicit check
from ahm_shield import AHMShield
shield = AHMShield(api_key="ahm_live_...")
result = shield.route("0xABC...")
result.action # "instant_settle" | "escrow" | "reject"
result.grade # "A"–"F"
result.score # 0–100
result.confidence # 0.0–1.0
result.stale # bool
Pattern B — Guard decorator
@shield.guard(on_reject="raise", on_escrow="flag")
def process_payment(address: str, amount: float):
...
on_reject="raise"— raisesAHMRejectError(default)on_reject="return"— returnsNonewithout calling the functionon_escrow="flag"— proceeds, setsahm_decisioncontext var (default)on_escrow="raise"— raisesAHMEscrowFlagon_escrow="allow"— proceeds silently
Async functions are auto-detected and handled correctly.
Pattern C — FastAPI middleware
from ahm_shield.middleware import AHMShieldMiddleware
app.add_middleware(
AHMShieldMiddleware,
api_key="ahm_live_...",
address_extractor=lambda r: r.headers.get("x-agent-address"),
)
Rejected addresses receive a 403. Escrow-flagged requests pass through with x-ahm-action: escrow response headers. The RoutingDecision is available at request.state.ahm_decision.
Async support
Every method has a sync and async variant:
result = shield.route("0xABC...") # sync
result = await shield.aroute("0xABC...") # async
Partner / white-label support
shield = AHMShield(api_key="ahm_live_...", partner_id="partner_42")
The partner_id is sent as an x-partner-id header on every request for backend attribution.
Exceptions
| Exception | When |
|---|---|
AHMRejectError |
Address scored as reject |
AHMEscrowFlag |
Address routed to escrow (when on_escrow="raise") |
AHMAuthError |
Invalid or missing API key (401/403) |
AHMConnectionError |
API unreachable or timed out |
All inherit from AHMError.
Development
pip install -e ".[dev]"
pytest
Metadata
Release files for ahm-shield 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ahm_shield-0.1.0.tar.gz | 7.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ahm_shield-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.3 kB
Release files / ahm_shield-0.1.0.tar.gz
| Download URL | ahm_shield-0.1.0.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7acca46d8c0f4ebfc36f2906e4b7fe282187455e222e75e70e9dcd943dabd4f9
|
|
BLAKE2b-256 checksum How to use checksums |
3ffab1f193bc3a78509ed3751a503bc2527b9d791c9caf13da436c45e1bd9811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ahm_shield-0.1.0-py3-none-any.whl
| Download URL | ahm_shield-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1feb60f7cdd6d10ee3e232f1821869e268abfd3a6aeb5b8af3a0eae4da5a8136
|
|
BLAKE2b-256 checksum How to use checksums |
b4650dfa8e0f4d1f07e2a68bf9c1b2adf0fe84310d5451c0a9b39b35eeeb28e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for ahm-shield 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.