Skip to main content
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 a tool_use block:
evaluate_tool_use extracts the tool name and input, builds an ActionContext, and runs the full Attesta evaluation:
The agent_id is always set to "claude" on all contexts created by AttestaToolGate. This allows the trust engine to build a trust profile specific to Claude’s tool-calling behavior over time.

Denial Messages

When a tool call is denied, make_denial_result creates a tool_result block that Claude understands:
The 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:
When a tool name matches a risk override, the hint {"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