Framework-neutral agent control contract: interception points, agent context, verdict, and conformance test kit. Python wrapper over the canonical Rust core.
Project description
agent-hooks (Python SDK)
Python implementation of AGENT-HOOKS-0.1:
interception-point enums, AgentContext builder, Verdict types, host-side
InterceptionEmitter, and the Conformance Test Kit.
# Not yet on PyPI (the name "agent-hooks" is held by an unrelated
# project; the distribution is named agent-hooks-sdk). Install from source:
pip install "agent-hooks-sdk @ git+https://github.com/responsibleai/agent-hooks#subdirectory=sdk/python"
Host (framework adapter) usage
from agent_hooks import AgentContextBuilder, InterceptionEmitter, InterceptionBlocked
builder = AgentContextBuilder(agent_id="...", framework="my-fw", session_id="...")
emitter = InterceptionEmitter().register(my_consumer)
await emitter.emit(builder.agent_startup(tools_registered=[...]))
ctx = builder.pre_tool_call(call_id="tc-1", name="http_get", args={"url": u})
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 Interceptor, AgentContext, Verdict, Decision
class MyPolicy:
def intercept(self, ctx: AgentContext) -> Verdict:
if ctx["interception_point"] == "pre_tool_call" and ctx["tool_call"]["name"] == "rm":
return Verdict(Decision.DENY, reason="dangerous")
return Verdict.ALLOW
Running the CTK against your framework
Implement agent_hooks.ctk.Harness (see conformance/HARNESS.md), then:
pytest --agent-hooks-harness=my_pkg:MyHarness \
--agent-hooks-vectors=path/to/conformance/vectors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_hooks_sdk-0.1.0a1.tar.gz.
File metadata
- Download URL: agent_hooks_sdk-0.1.0a1.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7bbaa7e25b2bddaa9cec5c11f491e9caab244a2e39e714df5d76fe6032b4c2e
|
|
| MD5 |
c44634427ad56b21b6c2954714919524
|
|
| BLAKE2b-256 |
d0b5eae512064a6bee68864863677ed51b1e8b7738d4b8757f6dcf1c034f20eb
|
File details
Details for the file agent_hooks_sdk-0.1.0a1-cp310-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: agent_hooks_sdk-0.1.0a1-cp310-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 535.3 kB
- Tags: CPython 3.10+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaae02d42753940af1fa578bca433c3b73e709f54f82e81e18701a5ab5d833bb
|
|
| MD5 |
0847f4b2cb1a162e89638cf64acb897e
|
|
| BLAKE2b-256 |
825d96d37d0619e32468a12906fe40906158007aaf61194ec8ca3a54a9de0f8d
|