Skip to content

Commit ef30bdf

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: HITL - reverting "Boolean confirmation" changes, we'll fix it differently
PiperOrigin-RevId: 858276347
1 parent 098ab36 commit ef30bdf

2 files changed

Lines changed: 3 additions & 59 deletions

File tree

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import io.reactivex.rxjava3.core.Single;
4343
import java.util.Collection;
4444
import java.util.HashMap;
45-
import java.util.List;
4645
import java.util.Map;
4746
import java.util.Objects;
4847
import java.util.Optional;
@@ -110,8 +109,8 @@ public Single<RequestProcessor.RequestProcessingResult> processRequest(
110109
continue;
111110
}
112111

113-
final Map<String, ToolConfirmation> toolsToResumeWithConfirmation = new HashMap<>();
114-
final Map<String, FunctionCall> toolsToResumeWithArgs = new HashMap<>();
112+
Map<String, ToolConfirmation> toolsToResumeWithConfirmation = new HashMap<>();
113+
Map<String, FunctionCall> toolsToResumeWithArgs = new HashMap<>();
115114

116115
event.functionCalls().stream()
117116
.filter(
@@ -164,16 +163,6 @@ public Single<RequestProcessor.RequestProcessingResult> processRequest(
164163
// Create an updated LlmRequest including the new event's content
165164
ImmutableList.Builder<Content> updatedContentsBuilder =
166165
ImmutableList.<Content>builder().addAll(llmRequest.contents());
167-
168-
final List<Part> functionCalls =
169-
toolsToResumeWithArgs.values().stream()
170-
.map(functionCall -> Part.builder().functionCall(functionCall).build())
171-
.collect(toImmutableList());
172-
Content functionCallContent =
173-
Content.builder().role("model").parts(functionCalls).build();
174-
// add function call
175-
updatedContentsBuilder.add(functionCallContent);
176-
// add function response
177166
assembledEvent.content().ifPresent(updatedContentsBuilder::add);
178167

179168
LlmRequest updatedLlmRequest =

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

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -97,48 +97,11 @@ public class RequestConfirmationLlmRequestProcessorTest {
9797
.build()))
9898
.build();
9999

100-
private static final Event FUNCTION_CALL_EVENT =
101-
Event.builder()
102-
.author("model")
103-
.content(
104-
Content.builder()
105-
.role("model")
106-
.parts(
107-
Part.builder()
108-
.functionCall(
109-
FunctionCall.builder()
110-
.id(ORIGINAL_FUNCTION_CALL_ID)
111-
.name(ECHO_TOOL_NAME)
112-
.args(ImmutableMap.of("say", "hello"))
113-
.build())
114-
.build())
115-
.build())
116-
.build();
117-
118-
private static final Event FUNCTION_RESPONSE_EVENT =
119-
Event.builder()
120-
.author("user")
121-
.content(
122-
Content.builder()
123-
.role("user")
124-
.parts(
125-
Part.builder()
126-
.functionResponse(
127-
FunctionResponse.builder()
128-
.id(ORIGINAL_FUNCTION_CALL_ID)
129-
.name(ECHO_TOOL_NAME)
130-
.response(
131-
ImmutableMap.of("result", ImmutableMap.of("say", "hello")))
132-
.build())
133-
.build())
134-
.build())
135-
.build();
136-
137100
private static final RequestConfirmationLlmRequestProcessor processor =
138101
new RequestConfirmationLlmRequestProcessor();
139102

140103
@Test
141-
public void runAsync_withConfirmation_callsOriginalFunctionAndAppendsToUpdatedRequest() {
104+
public void runAsync_withConfirmation_callsOriginalFunction() {
142105
LlmAgent agent = createAgentWithEchoTool();
143106
Session session =
144107
Session.builder("session_id")
@@ -158,14 +121,6 @@ public void runAsync_withConfirmation_callsOriginalFunctionAndAppendsToUpdatedRe
158121
assertThat(fr.id()).hasValue(ORIGINAL_FUNCTION_CALL_ID);
159122
assertThat(fr.name()).hasValue(ECHO_TOOL_NAME);
160123
assertThat(fr.response()).hasValue(ImmutableMap.of("result", ORIGINAL_FUNCTION_CALL_ARGS));
161-
assertThat(result.updatedRequest())
162-
.isEqualTo(
163-
LlmRequest.builder()
164-
.contents(
165-
ImmutableList.of(
166-
FUNCTION_CALL_EVENT.content().get(),
167-
FUNCTION_RESPONSE_EVENT.content().get()))
168-
.build());
169124
}
170125

171126
@Test

0 commit comments

Comments
 (0)