Skip to main content

maigp-strands

AIGP governance for the Strands Agents SDK.

Part of MAIGP — the Mediated AI Governance Protocol: a runtime consent / scope / evidence layer for AI systems. Every governed call is CHECKed before it runs (policy, scope, jurisdiction, circuit-breaker) and RECORDed + TRACEd as tamper-evident evidence after.

What it governs

Every model call and every tool call of a Strands agent, through a Strands HookProvider (AigpHookProvider, requires strands-agents>=1.61.1,<2).

Governance model

Strands event AIGP action
BeforeModelCallEvent CHECK (client.check); not ALLOW → event.cancel (the model is not invoked)
AfterModelCallEvent RECORD (tokens, latency, status) for a call that ran
BeforeToolCallEvent TOOL_REQUEST (client.tool_request, SHA-256 of the input); not ALLOW → event.cancel_tool (the tool body never runs; the model gets an error tool result with the reason)
AfterToolCallEvent RECORD (use_case="tool:<name>", output_ref = SHA-256 of the tool result) for a call that ran

Fail closed: only ALLOW / ALLOW_WITH_CONSTRAINTS lets a call run. DENY, RATE_LIMITED, UNCHECKED, a missing decision, an unreachable authority, any error in the CHECK path, or a CHECK slower than check_timeout (default 10 s) cancels the call, in ENFORCE and REPORT mode alike. The provider refuses to register on a disabled client (empty gov_url) or on a Strands whose events cannot cancel. Its before-callbacks run after all other hooks, so the CHECK covers the call that really runs.

Install

pip install maigp-strands

Pulls in maigp-agent-core (shared lifecycle), maigp-client and strands-agents.

Quick start

from strands import Agent
from aigp_strands import AigpGovernance

gov = AigpGovernance(gov_url="https://gov.example.com",
                     app_id="my-strands-agent", hmac_secret="secret")

agent = Agent(model=..., tools=[...], hooks=[gov.hook_provider()])

gov.hook_provider(use_case=..., check_timeout=..., tool_version=...) is the same as AigpHookProvider(gov, ...). use_case defaults to the agent's name.

AIAP agency gate (opt-in, 1.2.0)

Off by default: with no gate, nothing changes. Pass an AgencyGate from maigp-agent-core to the governance and the hook provider needs an AIAP agency grant (RFC-001) after every allowing CHECK / TOOL_REQUEST and before the model or tool runs:

from aigp_agent_core import AgencyGate

gate = AgencyGate(broker_url, agent_id, token_provider,          # the agent's own token, from a callable
                  scopes={"my-strands-agent": {"resources": ["bedrock:InvokeModel"]}})
gov = AigpGovernance(gov_url=..., app_id=..., hmac_secret=..., agency=gate)
agent = Agent(name="my-strands-agent", model=..., tools=[...], hooks=[gov.hook_provider()])
  • The scope key is the hook's use_case (default: the agent's name); the CHECK's request_id is sent as the AIGP trace id.
  • The grant is kept and reused until shortly before it expires, so normally only the first model call reaches the broker. Use gov.agency_session(region) to act with the grant's credentials.
  • Fail closed in every mode: a refusal, an unreachable broker, an empty token, a failing token provider, a missing aiap-client, or a gate slower than check_timeout cancels the call (event.cancel / event.cancel_tool, text Blocked by AIAP agency: ...). A call cancelled by its CHECK never asks the broker.
  • Install: pip install 'maigp-strands[agency]' ([agency-aws] adds boto3).

Deprecated: AigpCallbackHandler

AigpCallbackHandler / gov.callback_handler() does not govern: Strands callback handlers receive streamed output only and cannot block a call, and Strands never calls its on_* methods. Before 1.1.0 it was not even callable, so Agent(callback_handler=...) failed on the first event. Since 1.1.0 it fails closed: it warns (DeprecationWarning) when built, and wired as Agent(callback_handler=...) it raises AigpCallbackHandlerNotGoverning on Strands' first event, before the model is called or any tool runs, so an agent wired the old way refuses to run rather than running ungoverned. It will be removed in 2.0. Replace callback_handler=gov.callback_handler() with hooks=[gov.hook_provider()].


License: Proprietary. © Kanjani AI Research & Causum.

Metadata

Release files for maigp-strands 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maigp-strands 1.2.0
File Size Uploaded Provenance Actions
maigp_strands-1.2.0.tar.gz 22.7 kB Without provenance Details for maigp_strands-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for maigp-strands 1.2.0
File Interpreter ABI Platform Actions
maigp_strands-1.2.0-py3-none-any.whl Python 3 none any Details for maigp_strands-1.2.0-py3-none-any.whl

Total release size: 33.9 kB

Release files / maigp_strands-1.2.0.tar.gz

Download URL maigp_strands-1.2.0.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bc0885e711fa79ca19f21092d2e83b9241ceb52368f998b26368d7e58dc77dc6
BLAKE2b-256 checksum
How to use checksums
27e06acf3c24c3d8a2de8c81b4c3f4ba55feda63ab1c9ce3347979e666bc2e7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / maigp_strands-1.2.0-py3-none-any.whl

Download URL maigp_strands-1.2.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6fcebe5aded96747a97064f5f84728db2f53056ee81d6935268e42a724595590
BLAKE2b-256 checksum
How to use checksums
1bd93273f0a2ecb0fbf51418fa6f0fbbf2e278edf585efdc72ed3694ec7109d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for maigp-strands 1.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page