Skip to content

Tool confirmation ID mismatch: toolsToResumeWithConfirmation uses adk-request call ID instead of original function call ID #688

@yuhao101

Description

@yuhao101

** Please make sure you read the contribution guide and file the issues in the rigth place. **
Contribution guide.

Describe the bug
There is an ID mismatch issue in the tool confirmation flow in RequestConfirmationLlmRequestProcessor.java. The problem occurs when building the toolsToResumeWithConfirmation map:

  1. In filterToolsToResumeWithArgs method (lines 172-186): The method returns a map where:
    Key: The adk-request confirmation function call ID (the ID of the adk_request_confirmation function call itself)
    Value: The original function call (extracted from originalFunctionCall argument)
    In processRequest method (lines 90-95): When building toolsToResumeWithConfirmation, the code uses the adk-request call ID as the key to look up confirmations from requestConfirmationFunctionResponses

  2. In Functions.handleFunctionCalls method (line 154): When assigning tool confirmation to ToolContext, it uses functionCall.id() (which is the original function call ID) to look up the confirmation from the toolConfirmations map

  3. The mismatch: The toolConfirmations map has adk-request call IDs as keys, but the lookup uses original function call IDs, causing confirmations to never be found and tools never receive their confirmations.

To Reproduce
Steps to reproduce the behavior:

  1. Create an agent with a tool that requires confirmation (using ToolConfirmation)
  2. Trigger the tool execution which requests confirmation
  3. Provide the confirmation response through the adk_request_confirmation function response
  4. Observe that the tool is executed without the confirmation being passed to ToolContext
  5. The tool's toolContext.toolConfirmation() will always return null

Expected behavior
The toolsToResumeWithConfirmation map should use the original function call ID as the key (not the adk-request call ID), so that when Functions.handleFunctionCalls looks up the confirmation using functionCall.id(), it can correctly find the confirmation.

Fix Suggestion
In RequestConfirmationLlmRequestProcessor.java, line 95, change:
.collect(toImmutableMap(k -> k, requestConfirmationFunctionResponses::get));
to
.collect(toImmutableMap(
k -> toolsToResumeWithArgs.get(k).id().orElse(k),
requestConfirmationFunctionResponses::get));

Screenshots
If applicable, add screenshots to help explain your problem.

Image

Desktop (please complete the following information):

  • OS: macOS
  • Java version: 17
  • ADK version(see maven dependency): 0.4.0

Additional context
Add any other context about the problem here.

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