responsibleai/agent-hooks
Cross-language SDK and conformance kit for enforcing agent controls across hosts
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & 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.
tool_call.args; a post-tool transform targets tool_result.value; lifecycle points have no rewrite target.Framework, runtime and gateway teams that control their agent loops and need consistent policy, approval and rewrite behavior across multiple hosts.
You need a ready-made policy service, isolation for untrusted controls, guaranteed interception of every action, or only passive telemetry.
Quick Start & Installation
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)
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| agent-hooks ★ | 31 | +1 | Rust | MIT | Cross-language SDK and conformance kit for enforcing agent controls across hosts |
| headroom | 81.5k | +455 | Python | Apache-2.0 | Local context compression for LLMs via a Python library, proxy, and MCP server |
| goose | 57.3k | +219 | Rust | Apache-2.0 | Rust coding agent with MCP tools and local or hosted models, embeddable via ACP |
| OpenSpec | 76.4k | +468 | TypeScript | MIT | A CLI and agent-skill layer for keeping AI coding aligned with versioned specs |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/responsibleai/agent-hooks.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about agent-hooks
How do I integrate Agent Hooks into an existing agent host?
What hardware and runtime overhead should I budget for?
Can we use it commercially in a self-hosted product?
When is this a better fit than framework-native hooks or a standalone policy engine?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy