Human approval and dry-run actions in ADK
Require human confirmation for external actions by returning dry-run proposals with audit evidence and keeping execution rights separate.
By Invicly Tech, , in Google ADK with Python for AI Agents. About 11 minutes to read.
In short
Some actions change the outside world, such as closing a ticket or sending an email, and a person should approve them. In this course the agent never performs writes: a tool returns a dry-run proposal, ADK's tool confirmation pauses the run until a person approves or rejects it, and a separate executor with its own credentials carries out approved changes. Every step is recorded so you can show who approved what and when.
Think of it like this: The agent fills in the expense form; a manager signs it; finance, not the person who filled it in, pays it.
Explained simply
Reading a ticket's status is safe. Closing a ticket, refunding money or emailing a customer is not: it changes things outside the chat. For actions like these, a person should look and say yes before anything happens.
In this course the agent never makes a change itself. When a user asks to close a ticket, the agent calls a tool that writes down a proposal: which ticket, what change, why, and who asked. That is called a dry run, because it works out the change without doing it.
ADK has a feature called tool confirmation. You mark a tool as needing confirmation, and ADK pauses the run and asks your app to confirm. Your app shows the proposal to an approver, who clicks approve or reject, and the run continues with that answer.
Even after approval, the agent does not do the work. A separate service, the executor, reads approved proposals and makes the change with its own account. The agent's account cannot write at all. Every step is saved so you can later show who approved what and when.
Press Play on a diagram to walk through it one step at a time.
- 1Agent proposes
Dry-run tool returns the planned change
- 2Run pauses
adk_request_confirmation sent to client
- 3Person decides
Approve or reject, with their identity
- 4Audit record
Proposal, decision, approver, time
- 5Executor acts
Separate service with write rights
- 1Support agent identity
Read tickets, insert proposals, nothing else
- 2Client app
Shows proposals, sends confirmation replies
- 3Approver
Signed-in staff member, cannot approve own requests
- 4Executor service
Writes tickets, only for approved proposals
- 5Audit table
Append-only, written by app and executor
In depth
Model writes as dry-run proposals
Give the agent a tool such as propose_close_ticket instead of close_ticket. The tool checks ownership like any other tool, works out the exact change, and stores a proposal row with an ID, the action, the target record, the new value, the reason, who requested it and a status of pending. It returns the proposal ID and a short summary.
A good proposal is specific enough that an approver can say yes without reading the chat. Compare: close ticket versus set T-1001 status from open to closed, reason: customer confirmed fix. Include a before value so the executor can detect if the record changed since the proposal, and refuse instead of overwriting.
Dry-run proposals also make testing easy. You can assert on the rows the agent created without touching any real system, and you can replay a proposal to see exactly what would have happened.
- proposal_id, action, target, before, after
- reason and requested_by (from the session user)
- status: pending, approved, rejected, executed, failed
- created_at, decided_at, executed_at
Ask for confirmation on the tool
ADK offers two styles. The simple one wraps the tool: FunctionTool(propose_close_ticket, require_confirmation=True). Before the tool runs, ADK emits a function call named adk_request_confirmation and pauses. You can pass a function instead of True to decide per call, for example only ask when a refund is above a limit.
The advanced style calls tool_context.request_confirmation(hint=..., payload=...) inside the tool. hint is the text shown to the approver and payload is JSON the approver can fill in, such as an approved amount. On the next call, tool_context.tool_confirmation holds the answer, with confirmed and payload fields.
The client replies with a new message that contains a function response named adk_request_confirmation, using the same ID as the request, and a response object with confirmed true or false. The ADK docs note that confirmation is not supported with every session service, naming DatabaseSessionService and VertexAiSessionService; check the docs for your release before relying on it in production.
- User to Client app: Please close T-10011Please close T-1001
- Client app to ADK runner: run with the user's message2run with the user's message
- ADK runner to Client app: adk_request_confirmation call with hint3adk_request_confirmation call with hint
- Client app to Approver: Show proposal for review4Show proposal for review
- Approver to Client app: Approve5Approve
- Client app to ADK runner: Function response: confirmed true6Function response: confirmed true
- ADK runner to Client app: Tool runs, proposal approved7Tool runs, proposal approved
Record who approved what
The session's event history shows that a confirmation happened, but it is not an audit log. Sessions can be deleted for privacy, compacted, or stored in a service with different retention. Keep a separate, append-only audit table.
Write a row when a proposal is created, when it is approved or rejected, and when the executor finishes or fails. Take the approver's identity from their verified login in your client app, not from the confirmation payload, which any client could fill in. Record the invocation ID and session ID so you can link the audit row to traces.
Decide the rules up front: may a user approve their own proposal? In most support flows the answer is no, and the approval endpoint should check it. Also set an expiry so old proposals cannot be approved weeks later when the facts have changed.
Keep execution rights separate and resume safely
Separation of duties means the agent proposes and something else executes. In practice the agent runs with an identity, such as a Cloud Run service account, that has read-only access to tickets and write access only to the proposals table. The executor is a small, boring service with no model in it. It picks up approved proposals, re-checks the before value and the expiry, makes the change, and records the result.
This design keeps the blast radius small. A clever prompt, a model mistake or a bug in the agent can at worst create a pending proposal that a person will reject.
Resuming after approval is the other half. With tool confirmation the run waits, and the client's reply continues it. If your app uses ADK's resumable invocations, the reply must include the invocation_id of the paused run, or ADK starts a new invocation. For long waits, such as an approver replying tomorrow, store the proposal and let the executor act independently of the chat.
Learn it in 5 short steps
About 35m each. Track them with a timer in your plan.
- 1Model writes as dry-run proposals~35m
- 2Ask for confirmation on the tool~35m
- 3Record who approved what~35m
- 4Keep execution rights separate~35m
- 5Resume after approval~35m
Key points
- FunctionTool(tool, require_confirmation=True) pauses before the tool runs; a callable decides per call.
- Inside a tool, tool_context.request_confirmation(hint=..., payload=...) asks for structured approval.
- The client answers with a function response named adk_request_confirmation carrying confirmed and payload.
- The agent's identity has no write rights; only the executor does, and it re-checks the approval.
- Store proposals and decisions in your own audit table, separate from chat history.
Key terms
Tap a card to flip it. 0/6 known
Examples
def propose_close_ticket(ticket_id: str, reason: str, tool_context: ToolContext) -> dict:
"""Propose closing one of the user's tickets. Does not close it."""
if not owns(tool_context.user_id, ticket_id):
return {"error": "not_found"}
proposal = save_proposal(action="close_ticket", ticket_id=ticket_id,
reason=reason, requested_by=tool_context.user_id)
return {"proposal_id": proposal.id, "status": "pending_approval"}
propose_tool = FunctionTool(propose_close_ticket, require_confirmation=True)Even after confirmation, this tool only writes a proposal row; an executor service performs the close.
Ask for confirmation only above a threshold
Refund proposals under 20 units go straight into the queue as pending; larger ones need confirmation in the chat first. The callable receives the tool's arguments and returns True when confirmation is needed. Evidence: in adk web, a 15 unit refund creates a proposal immediately, while a 50 unit refund shows a confirmation request before the tool runs. Rollback: set require_confirmation=True to confirm every refund.
async def needs_confirmation(amount: int, tool_context: ToolContext) -> bool:
return amount >= 20
def propose_refund(ticket_id: str, amount: int, tool_context: ToolContext) -> dict:
"""Propose a refund for one of the user's tickets. Does not pay anything."""
if not owns(tool_context.user_id, ticket_id):
return {"error": "not_found"}
p = save_proposal("refund", ticket_id, after={"amount": amount},
requested_by=tool_context.user_id)
return {"proposal_id": p.id, "status": "pending"}
refund_tool = FunctionTool(propose_refund, require_confirmation=needs_confirmation)Sending the approval from the client
When the client sees an event with a function call named adk_request_confirmation, it records the call's ID and shows the hint to a signed-in approver. After the approver clicks approve, the client sends this message back on the same session. The ID below is a placeholder for the one from the request. Evidence: the next events show the tool's function response with status pending and a proposal ID, and your audit table has a row with the approver's ID.
{
"appName": "support_agent", "userId": "u_alice", "sessionId": "s_1",
"newMessage": {"role": "user", "parts": [{
"functionResponse": {
"id": "<adk-confirmation-call-id>",
"name": "adk_request_confirmation",
"response": {"confirmed": true}
}
}]}
}Quick reference
- Agent tools propose; a separate executor performs approved changes
- FunctionTool(fn, require_confirmation=True) or a callable that returns bool
- Inside a tool: tool_context.request_confirmation(hint=..., payload=...)
- Read the answer from tool_context.tool_confirmation (confirmed, payload)
- Client reply: function response named adk_request_confirmation with the same ID
- Approver identity comes from their login, never from the payload
- Audit rows: proposal, decision, approver, times, execution result
- Executor re-checks the before value and expiry before writing
Common mistakes
- Asking for confirmation but giving the agent's service account write access anyway.
- Showing the approver a vague hint instead of the exact record, field and new value.
- Treating a chat reply such as yes as approval instead of the structured confirmation response.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Turn a close_ticket tool into propose_close_ticket that returns a proposal and changes nothing.
- Exercise 2medium
Wrap the tool with require_confirmation=True and write a test that finds the adk_request_confirmation call, approves it, and checks one proposal was saved.
- Exercise 3hard
Write the executor function: it takes a proposal ID and an approver ID, refuses self-approval, expired proposals and changed records, then applies the change and writes audit rows.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is a yes in the chat good enough as approval?
- No. Free text can be faked or misunderstood. Use the structured confirmation response, tied to a specific proposal and a signed-in approver.
- Can the same person ask and approve?
- Technically yes, but for most support actions it defeats the purpose. Decide the rule up front and enforce it in the approval endpoint and the executor.
- What if the approver answers hours later?
- Do not keep a model run waiting for hours. Save the proposal, end the chat turn, and let the executor act on the approval when it arrives.