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

Open Beginner friendly
#439 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
frontend

Research direction

Start in long-running-response.ts and inspect initForm(), then follow onSend() to see how confirmationModel.payload becomes the submit request. Verify that the confirmation form uses toolConfirmation.payload when present, falls back to the original function arguments when it is absent, and no longer sends the wrong payload for the documented request_time_off flow.

Written by the indexing model from the issue text.

Description

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
);
Dominant language
TypeScript
Stars
1k
Forks
266
Avg merge
1d 12h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/adk-web

All issues in google/adk-web

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.