Add verification hook example using VeroQ Shield#799
Open
JohnnyTarrr wants to merge 1 commit intoanthropics:mainfrom
Open
Add verification hook example using VeroQ Shield#799JohnnyTarrr wants to merge 1 commit intoanthropics:mainfrom
JohnnyTarrr wants to merge 1 commit intoanthropics:mainfrom
Conversation
Demonstrates two hook patterns for fact-checking Claude's responses: - Stop hook: verifies the final assistant message after the agent finishes - PostToolUse hook: verifies Bash tool output before Claude uses it Includes graceful fallback when veroq package is not installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
examples/verification_hook.py-- a self-contained example that demonstrates how to use SDK hooks for post-response fact-checking with VeroQ Shield.Two hook patterns are shown:
veroq.verify_output. If any claim is contradicted, it injects a warning into the conversation (or optionally halts the session).BashviaHookMatcher(matcher="Bash", ...).Both hooks follow the existing conventions in
examples/hooks.py:HookCallbacksignature (input_data,tool_use_id,context)HookJSONOutputwithhookSpecificOutput,reason, andsystemMessageHookMatcherwithClaudeAgentOptions.hookssys.argvdispatchThe example degrades gracefully when the
veroqpackage is not installed -- it logs a warning and returns simulated results so the hook wiring itself can still be studied.Why this is useful
The hooks system is powerful but the current examples focus on permission gating and context injection. This example shows a real-world pattern: calling an external verification API inside a hook to audit Claude's outputs before they reach the user. That pattern generalizes to any trust/safety/compliance layer.
Test plan
python examples/verification_hook.pyprints usage helppython examples/verification_hook.py stopruns the Stop hook demo (requiresclaude-agent-sdkinstalled)python examples/verification_hook.py post_tool_useruns the PostToolUse hook demopython examples/verification_hook.py allruns both demosveroqnot installed, the example still runs and logs a fallback warning