Claude Agent Guardrails: Anthropic SDK Security
Secure your Claude agents with runtime guardrails. Implement tool authorization, approval workflows, and audit logging.
Claude is one of the most capable models for agentic applications. But even Claude needs guardrails when given tool access.
Claude's Tool Use
Claude can use tools through function calling. When you give Claude tools, it decides when and how to use them. Without guardrails, this can lead to unintended actions.
Adding Veto to Claude Agents
claude_guardrails.pypython
import anthropic
from veto import Veto, Policy
client = anthropic.Anthropic()
veto = Veto(api_key="veto_live_xxx")
# Define guarded tools
@veto.wrap_tool(
rules=[
Policy.deny_path("/etc/*"),
Policy.require_approval_if(path_contains="production"),
]
)
def read_file(path: str) -> str:
with open(path) as f:
return f.read()
# Pass to Claude
tools = [{
"name": "read_file",
"description": "Read file contents",
"input_schema": {...}
}]
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
tools=tools,
messages=[...]
)Related posts
Ready to secure your agents?