attesta_approval_handler— a Runner-level approval handler that gates all tool calls across the entire run.AttestaGuardrail— an Agent-level tool guardrail that evaluates individual tool invocations.
Installation
Approval Handler (Runner-level)
attesta_approval_handler() returns an async handler that matches the approval_handler signature expected by Runner.run(). Every tool call during the run is evaluated through Attesta before execution.
API
- Returns
Trueto allow the tool call - Returns
Falseto deny (the SDK skips execution)
Full Example
deploy_tool, Attesta:
- Builds an
ActionContextfrom the tool name and arguments - Scores the risk (the word “deploy” + “production” arguments will score HIGH)
- Presents the appropriate challenge to the human operator
- Returns
True(approved) orFalse(denied) to the SDK
The
**kwargs passed to the handler are forwarded as hints in the ActionContext. This means any extra metadata the SDK provides is available to the risk scorer.Tool Guardrail (Agent-level)
AttestaGuardrail is a callable class that matches the tool_guardrails interface on the Agent class. It evaluates each tool invocation and returns None to allow or a dict with an "error" key to deny.
API
Full Example
Combining Both
You can use both integration points simultaneously. The approval handler provides a global gate, while guardrails provide per-agent control:How Denial Works
When a tool call is denied:- Approval handler returns
False. The OpenAI Agents SDK skips the tool execution entirely. The agent does not receive any output for that tool call. - Guardrail returns
{"error": "Denied by Attesta (risk: <level>)"}. The SDK passes this error back to the agent, which can then decide how to proceed (retry with different parameters, suggest alternatives, or inform the user).
Custom Attesta Configuration
Pass a fully configured Attesta instance to control risk scoring, challenge types, and trust behavior:Anthropic Claude
Gate Claude tool_use blocks
LangChain
Wrap LangChain tools and LangGraph nodes