Skip to main content

Framework-neutral agent control contract: interception points, agent context, verdict, and conformance test kit. Python wrapper over the canonical Rust core. Cooperative contract, not a security boundary: the host is fully trusted (see SECURITY.md).

Project description

agent-hooks (Python SDK)

Python implementation of AGENT-HOOKS-0.1: interception-point enums, AgentContext builder, Verdict types, host-side InterceptionEmitter with the four composition profiles, the pluggable identity-provider seam, and the Conformance Test Kit.

Trust model. agent-hooks is a cooperative contract, not a security boundary: the host framework is fully trusted, interceptors run in-process with full data access, and no complete-mediation claim is made. Read SECURITY.md and spec §1.4 before relying on it.

# The 0.1.0a1 artifact on PyPI implements a superseded draft — until
# 0.1.0a2 is published, install from source:
pip install "agent-hooks-sdk[ctk] @ git+https://github.com/responsibleai/agent-hooks.git#subdirectory=sdk/python"
# import name: agent_hooks

Host (framework adapter) usage

from agent_hooks import AgentContextBuilder, InterceptionBlocked, InterceptionEmitter

builder = AgentContextBuilder(agent_id="my-agent", framework="my-fw", session_id="s-1")
emitter = InterceptionEmitter().register(MyPolicy())

await emitter.emit(builder.agent_startup(tools_registered=["http_get"]))
ctx = builder.pre_tool_call(call_id="tc-1", name="http_get", args={"url": url})
try:
    await emitter.emit(ctx)
except InterceptionBlocked as e:
    return tool_error(e.result.verdict.reason)
result = invoke_tool(ctx["tool_call"]["args"])  # post-transform args

Interceptor usage

from agent_hooks import AgentContext, Decision, Verdict

class MyPolicy:
    def intercept(self, ctx: AgentContext) -> Verdict:
        if ctx["interception_point"] == "pre_tool_call" and ctx["tool_call"]["name"] == "rm":
            return Verdict(decision=Decision.DENY, reason="dangerous")
        return Verdict(decision=Decision.ALLOW)

Verdict.warn(...) (allow + recorded warning) and Verdict.escalate(...) (liftable deny for the approval seam, §9) are the constructor shortcuts for the other two §5 shapes.

Running the CTK against your framework

Implement agent_hooks.ctk.Harness (see conformance/HARNESS.md), then:

pytest --agent-hooks-harness=my_pkg:MyHarness

The vectors ship inside the wheel; pass --agent-hooks-vectors=<dir> only to run a different vector set.

Project details


Download files

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

Source Distribution

agent_hooks_sdk-0.1.0a2.tar.gz (166.9 kB view details)

Uploaded Source

Built Distribution

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

agent_hooks_sdk-0.1.0a2-cp310-abi3-manylinux_2_34_x86_64.whl (629.6 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

File details

Details for the file agent_hooks_sdk-0.1.0a2.tar.gz.

File metadata

  • Download URL: agent_hooks_sdk-0.1.0a2.tar.gz
  • Upload date:
  • Size: 166.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for agent_hooks_sdk-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 a7814d25f7ce16f4d7908bfc1325863f28c00fde1e4ce9be837b429dd6ff70d6
MD5 30be3272ee141c4da766da401d3faf12
BLAKE2b-256 0b906e3d425d422c9b8ae98f2e74c977cbeaa120969ffcc6052ca141c7f38fc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_hooks_sdk-0.1.0a2.tar.gz:

Publisher: release.yml on responsibleai/agent-hooks

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

File details

Details for the file agent_hooks_sdk-0.1.0a2-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for agent_hooks_sdk-0.1.0a2-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5f9dd360697debd8b1aba88765fcfae914847385b9cf31326b6acb2179fdc4cb
MD5 5a9a48f84fd52d41e41aa04b3c5858fc
BLAKE2b-256 9ce4a117c49c67036289851c23bfe3acd57b5ff1566d5422092cee93d7956fb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_hooks_sdk-0.1.0a2-cp310-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on responsibleai/agent-hooks

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