Skip to content

Commit 0724330

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: Remove checking ToolConfirmation from Functions to align with Python SDK
PiperOrigin-RevId: 859196582
1 parent f65e58b commit 0724330

File tree

2 files changed

+0
-49
lines changed

2 files changed

+0
-49
lines changed

core/src/main/java/com/google/adk/flows/llmflows/Functions.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,6 @@ private static Function<FunctionCall, Maybe<Event>> getFunctionCallMapper(
254254
.toolConfirmation(functionCall.id().map(toolConfirmations::get).orElse(null))
255255
.build();
256256

257-
ToolConfirmation toolConfirmation = toolContext.toolConfirmation().orElse(null);
258-
if (toolConfirmation != null && !toolConfirmation.confirmed()) {
259-
return Maybe.just(
260-
buildResponseEvent(
261-
tool,
262-
ImmutableMap.of("error", "User declined tool execution for " + tool.name()),
263-
toolContext,
264-
invocationContext));
265-
}
266-
267257
Map<String, Object> functionArgs = functionCall.args().orElse(new HashMap<>());
268258

269259
Maybe<Map<String, Object>> maybeFunctionResult =

core/src/test/java/com/google/adk/flows/llmflows/RequestConfirmationLlmRequestProcessorTest.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,6 @@ public class RequestConfirmationLlmRequestProcessorTest {
8282
.build()))
8383
.build();
8484

85-
private static final Event USER_DECLINE_EVENT =
86-
Event.builder()
87-
.author("user")
88-
.content(
89-
Content.fromParts(
90-
Part.builder()
91-
.functionResponse(
92-
FunctionResponse.builder()
93-
.id(FUNCTION_CALL_ID)
94-
.name(REQUEST_CONFIRMATION_FUNCTION_CALL_NAME)
95-
.response(ImmutableMap.of("confirmed", false))
96-
.build())
97-
.build()))
98-
.build();
99-
10085
private static final RequestConfirmationLlmRequestProcessor processor =
10186
new RequestConfirmationLlmRequestProcessor();
10287

@@ -123,30 +108,6 @@ public void runAsync_withConfirmation_callsOriginalFunction() {
123108
assertThat(fr.response()).hasValue(ImmutableMap.of("result", ORIGINAL_FUNCTION_CALL_ARGS));
124109
}
125110

126-
@Test
127-
public void runAsync_withDecline_returnsErrorFunctionResponse() {
128-
LlmAgent agent = createAgentWithEchoTool();
129-
Session session =
130-
Session.builder("session_id")
131-
.events(ImmutableList.of(REQUEST_CONFIRMATION_EVENT, USER_DECLINE_EVENT))
132-
.build();
133-
134-
InvocationContext context = createInvocationContext(agent, session);
135-
136-
RequestProcessor.RequestProcessingResult result =
137-
processor.processRequest(context, LlmRequest.builder().build()).blockingGet();
138-
139-
assertThat(result).isNotNull();
140-
assertThat(result.events()).hasSize(1);
141-
Event event = result.events().iterator().next();
142-
assertThat(event.functionResponses()).hasSize(1);
143-
FunctionResponse fr = event.functionResponses().get(0);
144-
assertThat(fr.id()).hasValue(ORIGINAL_FUNCTION_CALL_ID);
145-
assertThat(fr.name()).hasValue(ECHO_TOOL_NAME);
146-
assertThat(fr.response())
147-
.hasValue(ImmutableMap.of("error", "User declined tool execution for echo_tool"));
148-
}
149-
150111
@Test
151112
public void runAsync_withConfirmationAndToolAlreadyCalled_doesNotCallOriginalFunction() {
152113
LlmAgent agent = createAgentWithEchoTool();

0 commit comments

Comments
 (0)