fix: use toolConfirmation.payload as submit payload instead of tool args#440
Conversation
|
In request_confirmation_function_call = types.FunctionCall(
name=REQUEST_CONFIRMATION_FUNCTION_CALL_NAME,
args={
'originalFunctionCall': original_function_call.model_dump(...),
'toolConfirmation': tool_confirmation.model_dump(by_alias=True, exclude_none=True),
},
)And class ToolConfirmation(BaseModel):
hint: str = ""
confirmed: bool = False
payload: Optional[Any] = NoneSo when the developer calls |
…ol args The confirmation form was reading originalFunctionCall.args to populate the payload field, causing the agent to receive the wrong keys and crash with KeyError when it expected the payload schema defined by the developer. Now reads toolConfirmation.payload with a fallback to originalFunctionCall.args for cases where no payload is provided. Fixes google#439
3564bc8 to
b94e643
Compare
|
Tested with different payload schemas both |
Fixes #439
Problem
I was following the official docs at https://adk.dev/tools-custom/confirmation/#confirmation-definition
to implement a custom confirmation flow. When submitting the confirmation form, the agent
receives
{ days: 5 }(the tool's original args) instead of{ approved_days: 0 }(thepayload schema defined by the developer), causing a
KeyErrorcrash.Root Cause
In
long-running-response.ts,initForm()initializesconfirmationModel.payloadfromoriginalFunctionCall.argsinstead oftoolConfirmation.payload. SinceonSend()readsconfirmationModel.payloadto build the submit request, the wrong payload gets sent.Fix
Read
toolConfirmation.payloadfirst when initializingconfirmationModel.payload, witha fallback to
originalFunctionCall.argsfor cases where the developer did not provide a payload.