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
- Run
adk web
- Trigger
request_time_off with days=4
- Submit the confirmation form
- 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
);
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
KeyErrorcrash.Reproduce
adk webrequest_time_offwithdays=4KeyError: 'approved_days'because the submitted payload is{ "days": 4 }instead of{ "approved_days": 4 }Root Cause
adk-python (
functions.py) correctly sends bothoriginalFunctionCallandtoolConfirmation(includingpayload) in the event. The bug is inlong-running-response.tswhereinitForm()initializesconfirmationModel.payloadfrom
originalFunctionCall.argsinstead oftoolConfirmation.payload. SinceonSend()reads
confirmationModel.payloadto build the submit request, the wrong payload gets sent.Proposed Fix