> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool Confirmation

> Describes tool-level confirmation requiring human approval for high-risk tool calls, structured approval payloads, and limiting tool exposure to enforce least privilege and reduce operational risk.

Your support agent can now reach a payments API, a file-server, and Google Search — and it didn't require any special wrapper code. That capability is powerful, but it also requires safeguards. Reading data is usually harmless; executing irreversible actions (refunds, cancellations, database deletes) has real-world consequences. Those actions should never run solely because a model decided to do so.

There are two complementary ways to introduce human approval into a flow:

* Workflow-level gates: pause the entire workflow at a decision point and wait for human approval (for example, a refund workflow that stops until a manager authorizes payment).
* Tool-level confirmation: pause only a single tool call right before it executes, and require explicit approval.

Tool-level confirmation is useful when risk is localized to a specific tool call rather than to an entire workflow. It lets models and agents proceed normally except for the single high-risk operation that must be approved.

## How tool-level confirmation works

Wrap a function in a FunctionTool and set `require_confirmation=True`. When the model attempts the tool call, the ADK suspends execution and prompts for confirmation; the underlying function does not run until a human approves.

```python theme={null}
from google.adk.tools import FunctionTool

def cancel_order(order_id: str) -> dict:
    """Cancel a customer's order."""
    return orders.cancel(order_id)

cancel_tool = FunctionTool(
    func=cancel_order,
    require_confirmation=True,
)
```

If the model decides to cancel order `A1001` the attempted call looks like:

```python theme={null}
cancel_order("A1001")
```

With confirmation enabled, execution pauses and the approver sees a prompt such as "Do you want to cancel order A1001?" If approved, the tool runs; if denied, it does not.

![A diagram titled "Workflow Gate vs Tool Confirmation" showing process icons and arrows such as Billing → Approval → Refund. A manager avatar is shown above the approval gate, and a second row depicts a Model/Support-agent flow leading to a cancel\_order action.](https://mintcdn.com/kodekloud-c4ac6d9a/heceQKBf52UJgxP-/images/Google-ADK-20/Advanced-Tools/Tool-Confirmation/workflow-gate-tool-confirmation.jpg?fit=max\&auto=format\&n=heceQKBf52UJgxP-\&q=85\&s=4243cf7154aa1b89292bfa8f50cafc61)

## Structured confirmations (more than Yes/No)

Tool confirmation can be structured: instead of a simple approve/deny, the approver can modify or fill in a structured payload — for example, approving a refund but entering a reduced amount.

![An illustrated slide titled "Structured Confirmation" showing a manager's avatar on the left and a "Refund approval" dialog on the right. The dialog displays a refund amount of \$45 and buttons to Approve or Deny.](https://mintcdn.com/kodekloud-c4ac6d9a/heceQKBf52UJgxP-/images/Google-ADK-20/Advanced-Tools/Tool-Confirmation/structured-confirmation-refund-45-approval.jpg?fit=max\&auto=format\&n=heceQKBf52UJgxP-\&q=85\&s=105c448b93064351f20271e2621be76d)

## ToolContext API: request confirmation and read the result

Each tool receives a compact `ToolContext` object describing the session and current user. The context exposes a method to request confirmation and a property that returns the confirmation payload once provided. The request can include a `hint` and a `payload` (for instance, `{ "amount": 45, "customer": "Jane Doe" }`). The approver may change the payload values before approving.

```python theme={null}
from google.adk.tools import ToolContext

def issue_refund(amount: float, customer: str, tool_context: ToolContext):
    # If no confirmation has been provided yet, request it and pause.
    if not tool_context.tool_confirmation:
        tool_context.request_confirmation(
            hint="Approve this refund?",
            payload={"amount": amount, "customer": customer},
        )
        return {"status": "waiting_for_approval"}

    # Confirmation received — extract the payload and perform the refund.
    data = tool_context.tool_confirmation.payload
    return refunds.issue(data["amount"], customer)
```

Because confirmation can be provided via the ADK UI or an external application, the approver does not have to be using the same interface where the agent started.

![A flow diagram titled "Approval From Another App." It shows an ADK UI refund approval dialog, a support agent, and an external mobile app screen with a \$30 refund request and Approve/Deny buttons.](https://mintcdn.com/kodekloud-c4ac6d9a/heceQKBf52UJgxP-/images/Google-ADK-20/Advanced-Tools/Tool-Confirmation/external-app-refund-approval-dialog.jpg?fit=max\&auto=format\&n=heceQKBf52UJgxP-\&q=85\&s=68ff7301ea7c02ffff7ec2962c2b161b)

## Limiting tool exposure: a second line of defense

Confirmation protects high-risk operations, but preventing unnecessary access reduces risk even further. Do not expose every tool to every agent. Giving a support agent access to deployment or administration tools increases the attack surface and makes it harder to apply policy.

Example: restrict a support agent to only the tools required for support (customer lookup, order status, refunds) and add identifying headers to requests.

```python theme={null}
def team_headers(ctx):
    return {
        "X-Team": "support-tier-2",
        "Authorization": f"Bearer {TOKEN}"
    }

support_tools = McpToolset(
    connection_params=StreamableHTTPConnectionParams(url=SUPPORT_MCP_URL),
    tool_filter=["customer_lookup", "order_status", "issue_refund"],
    # or supply a function: tool_filter=tools_for_task
    header_provider=team_headers,
)
```

![A dark-themed diagram titled "Too Many Tools" showing a central "Support agent" box connected by arrows to a "Database" above and four surrounding tools labeled Refund, Administration, Customer lookup, and Deployment. The arrows indicate data flow between the support agent and each tool.](https://mintcdn.com/kodekloud-c4ac6d9a/heceQKBf52UJgxP-/images/Google-ADK-20/Advanced-Tools/Tool-Confirmation/too-many-tools-support-agent-diagram.jpg?fit=max\&auto=format\&n=heceQKBf52UJgxP-\&q=85\&s=7f298b51df34046925f969197c16035b)

You can make the filter dynamic: choose which tools to expose based on the task or the current context. Combined with tool-level confirmation for high-risk calls, this yields a practical security model:

* A support task receives only support-related tools.
* A data analysis task receives only data-processing tools.
* High-risk operations are wrapped with confirmation so a human must approve them.

That way, you never trust the model with a destructive call by default — a human stands in front of it. If something goes wrong, the scope of damage stays limited.

## Best practices

* Apply the principle of least privilege: limit tools per role or per task.
* Wrap destructive operations (payments, deletions, cancellations) with confirmation.
* Use structured confirmations when the approver must change values (e.g., reduce a refund).
* Add team and authorization headers to requests so downstream systems can enforce policy and auditing.
* Prefer task-based dynamic filters to a single static tool list.

Protect destructive operations with confirmation and restrict tool exposure to the minimum set required for each role or task.

## Example tool set for a support agent

Give an agent exactly the tools they need — and no more:

```text theme={null}
customer_lookup
order_status
issue_refund
execute_sql
get_table_info
cancel_order
```

Further reading and references

* Principle of least privilege — [https://en.wikipedia.org/wiki/Principle\_of\_least\_privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege)

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/google-adk-2-0/module/73e63dcd-2829-46d7-bbaa-5ac2336079d7/lesson/8a980cf2-4730-4cbd-8f62-b612f1ef47af)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.