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.0a3.tar.gz (173.4 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.0a3-cp310-abi3-manylinux_2_34_x86_64.whl (634.8 kB view details)

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

File details

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

File metadata

  • Download URL: agent_hooks_sdk-0.1.0a3.tar.gz
  • Upload date:
  • Size: 173.4 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.0a3.tar.gz
Algorithm Hash digest
SHA256 a527a42b23b748e298e9c6f5a80c824b04f57e52a100fd5ab7664e3b194feb62
MD5 d0f8ecc3acb18f879cc3c24122fb71a9
BLAKE2b-256 752276c1497ba3e56d6d14bccd9c532e80e693d900d8996c8abc854fc452b779

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_hooks_sdk-0.1.0a3.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.0a3-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for agent_hooks_sdk-0.1.0a3-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 882e7d109bf4c4818c68325d9199e99237ebf74475f792ed91b93f807e15ac48
MD5 760fcf1f72a9e71d9adb108259aa50cc
BLAKE2b-256 ced16b862b959141fb9fb5693484b728817f9f25fdbc05c35ec2184505294ff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_hooks_sdk-0.1.0a3-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