Skip to main content

agent-countersign

An open governance layer for AI agents. Every tool call an agent makes goes through one gateway that applies a readable policy, sends sensitive actions to a human, redacts PII, enforces spend limits and writes a tamper-evident audit trail. It is vendor-neutral and speaks MCP, so Claude, ChatGPT, Copilot, Cursor and any other MCP client can use governed tools without code changes.

Companies are deploying agents from many vendors at once, and each vendor governs only its own. Nobody can answer the questions a CFO, CISO or auditor will ask: What can this agent do? Who approved that? What did it cost? Can you prove the log wasn't edited? agent-countersign answers them in one place, for every agent.

 agent ──► Gateway.call() ──► policy ──► allow ─────────────► tool ──► redact ──► agent
 (any vendor,                    │        deny  ────────────────────────────────► agent
  or MCP)                        │        require_approval ─► queue ─► human ─► resume()
                                 └──────► audit trail (every step, hash-chained)

What it does

Control How
Policy as plain YAML Rules a process owner can read and sign off on. First match wins; anything not covered is denied. Match on agent, tool and argument values (amount > 500, regex, lists).
Human in the loop require_approval rules queue the call. Named approvers decide from the CLI (or your own UI). Agents can't approve their own requests, and approvals are single-use.
Tamper-evident audit Every decision, approval and execution is logged with a SHA-256 chain. Edit or delete one row and countersign verify names the event where the chain breaks.
PII redaction Emails, phone numbers, SSNs and card numbers (Luhn-checked) are stripped from the audit log and from what the model sees. Tools look up sensitive values themselves, so the model never needs them.
Spend limits Give each tool a cost; set daily budgets per agent.
MCP adapter Wrap your tools once; every MCP client gets the governed versions plus countersign_check_approval.

Quick start

pip install -e ".[mcp]"
python examples/overdue_invoices/run_demo.py

The demo runs a scripted accounts-receivable agent with no LLM, so you can see every control fire: an allowed lookup with redacted output, a customer email held for approval, a $900 refund blocked by policy, a self-approval refused, the approved email sent, a replay refused, and then tampering with the audit log detected.

Use it in your code

from agent_countersign import Gateway

gw = Gateway("policy.yaml", "countersign.db")

@gw.tool(cost_usd=0.01)
def send_email(customer_id: int, subject: str, body: str) -> str:
    """Send an email to a customer."""
    ...

result = gw.call("billing-bot", "send_email", {"customer_id": 1, "subject": "...", "body": "..."})
result.status        # "executed" | "denied" | "pending" | "failed"

Policy example

defaults:
  decision: deny
budgets:
  - {agent: "*", daily_usd: 1.00}
rules:
  - name: read-only lookups
    tools: [list_overdue_invoices, get_customer]
    decision: allow
  - name: no refunds over $500
    tools: [issue_refund]
    when: {amount: {gt: 500}}
    decision: deny
  - name: customer emails need a human
    tools: [send_email]
    decision: require_approval
    approvers: [ar-manager, controller]

Dry-run a decision before you deploy:

countersign check policy.yaml issue_refund agent=billing-bot amount=200
# require_approval  (rule: small refunds need the controller)  approvers: controller

Governed MCP server

from agent_countersign.mcp_adapter import build_server
build_server(gw, agent="billing-bot").run()

See examples/overdue_invoices/server.py for a ready-to-run server and Claude Desktop config. Approve from a terminal:

countersign approvals
countersign approve 1 --by ar-manager --note "tone is fine"
countersign audit
countersign verify

Roadmap

  • Authenticated approvers (SSO / signed approvals)
  • MCP proxy mode: govern any existing MCP server without touching its code
  • Approvals in Slack, Teams and email
  • Per-model cost tracking from LLM usage data
  • Signed audit checkpoints and export for SOX/HIPAA evidence
  • Policy packs for common regulated workflows (AP/AR, healthcare scheduling, claims)
  • Postgres store and a small web console

Status

v0.1. Small core, fully tested, meant to be read in an afternoon. Issues and pull requests welcome.

Known limits in v0.1: approver identity comes from --by and is not yet authenticated (put the CLI behind your own access controls, or wire approvals to SSO); redaction is pattern-based and is a safety net, not a substitute for keeping sensitive data out of model context by design.

License

Apache-2.0

Metadata

Release files for agent-countersign 0.1.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 agent-countersign 0.1.0
File Size Uploaded Provenance Actions
agent_countersign-0.1.0.tar.gz 20.4 kB With provenance Details for agent_countersign-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-countersign 0.1.0
File Interpreter ABI Platform Actions
agent_countersign-0.1.0-py3-none-any.whl Python 3 none any Details for agent_countersign-0.1.0-py3-none-any.whl

Total release size: 40.0 kB

Release files / agent_countersign-0.1.0.tar.gz

Download URL agent_countersign-0.1.0.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a79fd17d6a6cf34f2b30c3e4a8946b60e56e20d0ddafb34519c379ecbc1b8f45
BLAKE2b-256 checksum
How to use checksums
f00ce4978b090d9155f99f2bc51994348e625a2bf3cb30b0c52781a7e6c64d01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / agent_countersign-0.1.0-py3-none-any.whl

Download URL agent_countersign-0.1.0-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c549c04dfbeb09542a892e441a5abd900ccf02c1b77445a2b2d72928ee0173b0
BLAKE2b-256 checksum
How to use checksums
0ff79fb898916aa0c8a4fb05c02b24657b279e4862d4445a3d254d5bb845266c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for agent-countersign 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agent_countersign-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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