Put an AI agent's tool calls behind an Agent Approval Protocol (AAP) approval provider.
pip install agentapprovalprotocol==0.3.0 Copy PIP instructions
AsyncGate and AsyncClient provide the same API for asyncio.
With mode="async", check returns Pending when there is no decision yet, so the run can pause and the process can exit. Mount a Receiver where the provider can reach it. When a decision arrives it wakes the run, and the gate checks the decision again before anything runs.
Framework integrations handle pausing and resuming for you.
Start the receiver first, because the provider checks that it answers before registering it:
from fastapi import FastAPI from agentapprovalprotocol import Receiver receiver = Receiver(resumers={"langgraph": resumer(agent)}) app = FastAPI() app.add_route("/aap/events", receiver.asgi(), methods=["POST"]) Add it as a route, as shown. app.mount("/aap/events", ...) redirects /aap/events to /aap/events/, and providers do not follow redirects.
Once the server is running, register the receiver:
provisioned = await receiver.provision( provider_url="https://approvals.example.com/api/aap", provisioner_token=provisioner_token, url="https://agent.example.com/aap/events", ) provision creates the signing secret and registration ID, and the receiver starts using the new instance credential. Save token, secret, registration_id and instance_id from the result. Nothing is saved for you. If it raises WebhookVerificationFailed, check the receiver is reachable at url and call provision again.
On later starts, pass the saved values. client can be a function, called the first time a run is woken:
receiver = Receiver( secret=secret, registration_id=registration_id, instance_id=instance_id, client=lambda: AsyncClient("https://approvals.example.com/api/aap", load_token()), resumers={"langgraph": resumer(agent)}, ) To register in your provider's app instead, start the receiver with the secret and registration ID you enter there. Without the registration ID, the receiver refuses the provider's check.
For Deep Agents (Python 3.11 or later), install agentapprovalprotocol[deep-agents] and add the middleware to every subagent:
from agentapprovalprotocol.langgraph import deep_agent_subagents agent = create_deep_agent(model, tools=tools, middleware=[approvals], subagents=deep_agent_subagents(approvals, my_subagents)) To pause instead of waiting, use ApprovalMiddleware(..., mode="async") with a checkpointer, and mount a Receiver with resumers={"langgraph": resumer(agent)}. On LangSmith Deployment, use deployment_resumer(get_client()) in a custom route instead. Resuming a thread any other way cannot approve a call: the middleware asks the provider again.
from agentapprovalprotocol.pydantic_ai import ApprovalCapability approvals = ApprovalCapability("https://approvals.example.com/api/aap", token) agent = Agent(model, tools=tools, capabilities=[approvals]) Every tool call the agent makes goes to the provider, including MCP and other toolset tools. A denied call returns the reason to the model as a failed tool result. Add the same capability to every agent you run as a sub-agent.
Tools that run at the model provider, such as native web search or code execution, cannot be sent for approval. A run that includes one stops with an error. Use a local tool instead.
To pause instead of waiting, use ApprovalCapability(..., mode="async") and add DeferredToolRequests to the agent's output_type. When a run ends with DeferredToolRequests, save result.conversation. Mount a Receiver with resumers={"pydantic-ai": resumer(agent, load=load, save=save)}, where load(conversation_id) returns the saved conversation and save(conversation) stores the resumed one. Calls inside a sub-agent wait instead of pausing. Continuing a conversation any other way cannot approve a call: the capability asks the provider again, and an approval with edited arguments is refused.
check_coverage raises an error for agents whose calls the plugin cannot see: code executors, remote agents, and agents used as tools with include_plugins=False. Gemini built-in tools such as google_search run on Google's servers, so the plugin stops the run when an agent uses one.
protect refuses tools that run inside OpenAI's response, such as web search, file search and code interpreter, because their calls cannot be stopped. It also refuses local shell, computer and apply patch tools: wrap the action in a function tool instead. Hosted MCP servers are supported, and their calls always wait for the decision.
options() does not load your user settings (~/.claude/settings.json) unless you set setting_sources yourself. If the Claude Code approval hook is installed there, loading them asks for approval twice for every call.
Tools that the Claude API runs itself, such as the advisor, never reach the hooks, so they are not sent for approval.
CrewAI and the OpenAI Agents SDK need different major versions of openai, so the crewai and openai-agents extras can't be installed together.
from agentapprovalprotocol.crewai import ApprovalHooks ApprovalHooks("https://approvals.example.com/api/aap", token).install() crew.kickoff() Every tool call any crew, agent or flow in the process makes goes to the provider, including delegation to coworkers. A denied call returns the reason to the model as the tool result.
CrewAI cannot pause a run at a tool call, so each call waits for the decision. In akickoff the wait blocks the event loop.
adk claude-agent-sdk crewai deep-agents langgraph openai-agents pydantic-ai
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.




