# Repository Briefing: responsibleai/agent-hooks
> Source: https://repoforai.com/repo/responsibleai/agent-hooks (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/responsibleai/agent-hooks
- **Official Docs / Website**: https://responsibleai.github.io/agent-hooks
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Rust
- **License**: MIT
- **Engineering Health**: A (80/100 · Maintenance 35/35 · Adoption 14/25 · Releases 11/20 · License 20/20)
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: API
- **Momentum**: 31 ★ total (+0 24h / +1 7d) · 11 forks
- **Topics**: `agent-security`, `ai-agents`, `conformance-testing`, `dotnet`, `golang`, `guardrails`, `policy-enforcement`, `python`, `rust`, `specification`, `typescript`
- **When to Use**: Best for: Framework, runtime and gateway teams that control their agent loops and need consistent policy, approval and rewrite behavior across multiple hosts. Skip if: You need a ready-made policy service, isolation for untrusted controls, guaranteed interception of every action, or only passive telemetry.

## Overview
```text
### Architecture & Core Mechanics
Agent Hooks defines the enforcement boundary between an agent host and its controls. The host builds a versioned context, emits it at an interception point, and applies the resulting verdict. An emitter can be built from a JSON host declaration supplied as a file or value, or from a builder that uses the same loader. Direct constructors and setters remain conformant but produce an unsealed emitter without a declaration. The emitter rejects a context with a mismatched spec version.

The canonical implementation in `sdk/rust/core` handles RFC 8785 canonical JSON, `jcs-sha256` context identity over a validated I-JSON domain, wire-verdict validation, transform paths and strictest-verdict aggregation. Python, TypeScript and Go bind that core but own host dispatch and timeouts. C# implements the runtime independently in managed .NET 8; shared golden fixtures check canonical JSON and identity outputs byte for byte and compare resolved declarations across all five SDKs.

### Key Capabilities & Differentiators
Eight interception points cover session startup and shutdown, ingress and egress, and both sides of model and tool calls. In `enforce` mode, `allow` proceeds, `transform` rewrites the point-specific field before proceeding, and `deny` blocks. For example, before a model call the rewrite target is `messages`; after a tool call it is `tool_result.value`. Startup and shutdown have no rewrite target. Hosted transports may return a bare verdict or an envelope with provider extensions, but only the verdict governs enforcement.

Four composition profiles cover first-deny and run-all sequencing, plus strictest and unanimous parallel aggregation. An approval resolver can lift an eligible deny by returning the identity of the context shown for review; if configured, redaction precedes identity calculation. With no resolver the deny stands. Each emission produces a payload-free record, and `evaluate_only` generates records without applying verdicts. The conformance kit runs all released vectors applicable to the host's declared surface, rather than awarding a universal conformance tier.

### Trade-offs & Limitations
Compared with framework-native middleware, the benefit is a common contract and shared test vectors across hosts, not automatic coverage. Each host must wire the call sites and honor the outcome. For a single runtime with adequate native hooks, that extra adapter and versioning work may not pay off. A standalone policy engine supplies rules and decisions that this SDK does not; it can sit behind an interceptor rather than compete with the contract.

The trusted host and in-process interceptors are a consequential boundary: interceptors have full data access, approval redaction does not isolate them, and the eight points do not guarantee complete mediation. Payload-free records reduce what the SDK records, not what a control sees. Fail-closed enforcement can turn invalid verdicts, interceptor timeouts or zero registered interceptors into denials. The per-binding `on_error: continue` exception is draft-only and does not belong in a released 0.1 design. Conformance tests declared behavior; it is not security certification.

### Hardware & Deployment Guide
Treat this MIT-licensed project as a Beta SDK embedded in a framework, runtime or gateway, not as a turnkey API service. Pin the SDK package, wire spec `agent-hooks/0.1` and declaration `agent-hooks-declaration/1.0` explicitly: these are separate version axes, and the host has no default spec. The root workspace declares Node.js 22 or newer for repository tooling; that is not a requirement for every SDK. C# targets .NET 8 and does not load the Rust native library.

An in-process deployment can run without a network dependency from the contract itself; backing policy and approval services determine whether the full path stays local. Budget for context processing, concurrent invocations and record buffering, then measure control latency and timeout behavior in the real host. Run the 0.1 conformance harness against the exact surface being shipped. The listed Stack #255 C# builds are managed-package previews, not official releases or nuget.org publications; verify package availability before making a registry install part of the rollout.
```

## Key Capabilities
```text
- Interception surface: Eight points span session startup and shutdown, input and output, and both sides of model and tool calls.
- Scoped rewrites: A pre-tool transform targets `tool_call.args`; a post-tool transform targets `tool_result.value`; lifecycle points have no rewrite target.
- Cross-language parity: Python, TypeScript and Go bind the Rust core; managed .NET 8 implements the contract independently and is checked against shared fixtures.
- Composition: Four sequential or parallel profiles define how multiple verdicts combine; each interception record identifies the active profile.
- Approval binding: The resolver echoes the identity of the context presented for approval, computed after redaction when a redactor is configured.
- Conformance scope: The kit tests every applicable vector for the host's declared surface; claims name a released spec, never the draft.
```

## Quick Start / Clone
```bash
from agent_hooks import HostRegistry, HostSurface, InterceptionEmitter

registry = (
    HostRegistry(
        HostSurface.from_capabilities(
            ["model_calls", "tool_calls", "int64_json", "host_declaration"]
        )
    )
    .kind("com.example.egress", lambda config, ctx: EgressGuard(**config))
    .kind("com.example.audit-log", lambda config, ctx: AuditLog(**config))
    .approval_resolver("operator-queue", OperatorQueue())
    .approval_redactor("strip-secrets", strip_secrets)
)
emitter = InterceptionEmitter.from_declaration_path("agent-hooks.declaration.json", registry)
```
