CertiorCallbackHandler taps that system and runs Guard.verify(...) before each tool execution. Allowed calls proceed; blocked calls raise CertiorBlocked and the chain stops.
Wiring it in
What the handler does
CertiorCallbackHandler(guard) subscribes to LangChain’s on_tool_start event. For each invocation:
- Resolves the tool’s name and inputs.
- Calls
guard.verify(tool=name, params=inputs, content=...). - On allow: lets LangChain proceed with the original inputs (or the redacted version when the policy redacts).
- On block: raises
CertiorBlockedcarrying theVerifyResult. The chain halts.
Declaring capabilities per tool
LangChain tools don’t carry capability metadata out of the box. The simplest pattern is to wrap the tool function with@guard.wrap(required_capabilities=...) before registering it as a LangChain tool:
CertiorBlocked synchronously inside the tool body; the callback enforces the same check at the framework boundary.
See also
- Custom loop - the same
Guard.verify()directly. - How it works - the three gates this handler enforces.