AttestaToolGate evaluates tool_use content blocks from Claude’s API response through the Attesta approval pipeline before your application executes the requested tool. This gives you full control over which tool calls Claude is allowed to make.
Installation
API Reference
AttestaToolGate
Methods:
evaluate_tool_use accepts both the Anthropic SDK’s ToolUseBlock objects (attribute access) and plain dict representations (key access). This means it works with both the official SDK and raw API responses.Full Example
How tool_use Evaluation Works
When Claude responds with atool_use block:
evaluate_tool_use extracts the tool name and input, builds an ActionContext, and runs the full Attesta evaluation:
Denial Messages
When a tool call is denied,make_denial_result creates a tool_result block that Claude understands:
is_error=True flag tells Claude that the tool call failed. The denial message asks Claude to suggest alternatives, which typically produces more helpful responses than a silent failure.
Agentic Loop with Gating
Here is a complete agentic loop that processes multiple tool calls per turn and handles both approvals and denials:Risk Overrides
Force specific risk levels for known-dangerous tools:{"risk_override": "critical"} is passed to the scorer, which forces the specified risk level regardless of the heuristic score.
CrewAI
Gate CrewAI task outputs
OpenAI Agents SDK
Approval handlers and guardrails