Add safety guardrails example using Sentinel AI#654
Open
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
Open
Add safety guardrails example using Sentinel AI#654MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
Conversation
Shows two approaches for adding real-time safety scanning to Claude Agent SDK: 1. PreToolUse hooks — scan tool arguments before execution 2. Tool permission callbacks — allow/deny based on safety analysis Detects dangerous commands, data exfiltration, credential access, prompt injection, and PII leaks with sub-millisecond latency using Sentinel AI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 a new example showing how to integrate real-time safety scanning into Claude Agent SDK using Sentinel AI, an open-source guardrails library.
The example demonstrates two approaches:
PermissionResultAllow/PermissionResultDenybased on safety analysis, with automatic PII redaction viaupdated_inputSentinel AI scans in ~0.05ms with zero heavy dependencies, so it adds negligible latency to tool calls.
Why this is useful
Claude Agent SDK users building agentic applications need safety guardrails for tool calls. This example shows a production-ready pattern for:
rm -rf /,curl | bash, credential access)Test plan
python examples/safety_guardrails.py hookspython examples/safety_guardrails.py callbackGenerated with Claude Code