google / google/adk-web

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

Open
#439 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1k
Forks
267
Avg merge
1d 12h
Merged PRs (30d)
9

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

```python
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

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.