Skip to main content

maigp-agent-core

Shared agent-governance lifecycle for every MAIGP framework adapter.

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

Governs the AIGP agent loop itself — the primitive that all framework adapters build on.

Governance model

This adapter maps the framework's lifecycle onto the AIGP agent-governance loop provided by maigp-agent-core:

Framework event AIGP action
run / invocation start CHECK (pre_invoke) — allowed? under what authority?
each model reply token accounting (on_model_call)
each tool / function call tool governance (on_tool_call)
run complete RECORD + TRACE (post_invoke)
failure on_error (recorded, then re-raised)

Install

pip install maigp-agent-core

Quick start

from aigp_agent_core import AgentGovernance

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

# Start of an agent run
gov.pre_invoke(agent_name="analyst", model_id="claude-opus-4", user_id="u1")

# Agentic control points (RFC-agentic): gate tools, plans, escalations
decision = await gov.on_tool_call("search", params={"q": "..."})
await gov.plan_submit(steps=[{"tool": "search"}, {"tool": "write"}])
await gov.escalate(reason="budget exceeded", action={"type": "pause"})

# Token accounting + completion
gov.on_model_call(input_tokens=500, output_tokens=200)
await gov.step_complete(step_number=1, status="SUCCESS")
await gov.post_invoke(status="SUCCESS")

AIAP agency gate (opt-in, 1.2.0)

AIGP CHECK decides what may run; an AIAP agency grant (RFC-001) decides who may act, with what authority. The gate is off by default. When a deployment passes an AgencyGate, pre_invoke obtains a grant from the Agency Broker after an allowing CHECK, and the agent acts with the grant's credentials instead of its ambient ones.

pip install 'maigp-agent-core[agency]'        # [agency-aws] adds boto3 for agency_session()
from aigp_agent_core import AgentGovernance, AgencyGate, AgencyScope

gate = AgencyGate(
    broker_url="https://broker.example.com",
    agent_id="MY_AGENT",
    token_provider=current_agent_token,          # callable (sync or async): the agent's OWN short-lived token
    scopes={                                     # per deployment: the actions each use case really needs
        "analyst": AgencyScope(resources=("bedrock:InvokeModel",),
                               resource_arns=("arn:aws:bedrock:us-east-1::foundation-model/my-model",)),
    },
)
gov = AgentGovernance(gov_url, app_id, hmac_secret, agent_id="MY_AGENT", agency=gate)

gov.pre_invoke(agent_name="analyst", model_id="my-model")   # CHECK, then the agency grant
bedrock = gov.agency_session("us-east-1").client("bedrock-runtime")
  • Token mode only. The broker authenticates the agent's own token (aiap-client 1.1.0 token mode). There is no MAC / shared-secret mode and no static token argument: pass a provider that returns the current token.
  • Resources are configuration. A use case without a scope is refused; nothing is defaulted. The broker refuses anything outside the agent's enrolled template.
  • The AIGP trace id is sent (X-AIGP-Trace-Id), so the decision is linked to the trace.
  • The grant is kept and reused until renew_before_seconds (default 120) before it expires.
  • Fail closed in every mode, REPORT included: a refusal, an unreachable broker, a broker error, a malformed answer, an empty token, a failing provider or a missing aiap-client raise AgencyRequiredError (a GovernanceBlockedError, with a typed code).
  • Hook-based adapters that do not call pre_invoke call gov.require_agency(use_case) (or await gov.arequire_agency(...)) after their CHECK and before acting. gov.agency_grant is the current grant; await gov.release_agency() releases the kept grants (e.g. at shutdown).

Who should use this

You normally install a framework adapter (e.g. maigp-crewai, maigp-microsoft-agent-framework) which depends on this package. Install maigp-agent-core directly only when writing a custom adapter for a framework not yet covered.

Control points

pre_invoke · require_agency · on_model_call · on_tool_call · plan_submit · escalate · attest_input · step_complete · post_invoke · on_error.


License: Proprietary. © Kanjani AI Research & Causum.

Metadata

Release files for maigp-agent-core 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-agent-core 1.2.0
File Size Uploaded Provenance Actions
maigp_agent_core-1.2.0.tar.gz 23.4 kB Without provenance Details for maigp_agent_core-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 40.2 kB

Release files / maigp_agent_core-1.2.0.tar.gz

Download URL maigp_agent_core-1.2.0.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8854b1b2a82ec725c464a173eedf63ed111c07190b681f4dc18c636e56eb7137
BLAKE2b-256 checksum
How to use checksums
eb1c6efd0238074e3552fe30df173343c21e95bc0b007becaf8272b56058b440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

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

Download URL maigp_agent_core-1.2.0-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ca409fe594a960be3c2130450b159f66bd64ea60eb928ce5bd5c1a0821ebf79
BLAKE2b-256 checksum
How to use checksums
bf47a6f08d9aa94af86fd766cd126b776077ab89ccd4eb3c03e0706533a56c6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for maigp-agent-core 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