Skip to content

Web UI sends tool args instead of confirmation payload, crashing the agent #439

Description

@vietnamesekid

Bug

I was following the official docs at https://adk.dev/tools-custom/confirmation/#confirmation-definition
to implement a custom confirmation flow using tool_context.request_confirmation(payload={...}).

After implementing it, I noticed that when submitting the confirmation form, the agent
receives the tool's original args instead of the payload schema I specified, causing a
KeyError crash.

Reproduce

def request_time_off(days: int, tool_context: ToolContext):
    tool_confirmation = tool_context.tool_confirmation
    if not tool_confirmation:
        tool_context.request_confirmation(
            payload={'approved_days': days},
        )
        return {'status': 'pending'}

    payload = tool_confirmation.payload or {}
    approved_days = payload['approved_days']  # KeyError here
  1. Run adk web
  2. Trigger request_time_off with days=4
  3. Submit the confirmation form
  4. Agent crashes with KeyError: 'approved_days' because the submitted payload is { "days": 4 } instead of { "approved_days": 4 }

Root Cause

adk-python (functions.py) correctly sends both originalFunctionCall and
toolConfirmation (including payload) in the event. The bug is in
long-running-response.ts where initForm() initializes confirmationModel.payload
from originalFunctionCall.args instead of toolConfirmation.payload. Since onSend()
reads confirmationModel.payload to build the submit request, the wrong payload gets sent.

Proposed Fix

// long-running-response.ts
this.confirmationModel.payload = JSON.stringify(
  this.functionCall.args?.toolConfirmation?.payload ??
  this.functionCall.args?.originalFunctionCall?.args ??
  {}, null, 2
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions