Skip to content

Commit 962a796

Browse files
Fix duplicate command execution after streaming
1 parent af9a99c commit 962a796

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,13 @@ private fun processCommands(text: String) {
22652265
val commandBatch = PhotoReasoningCommandProcessing.parseForFinalExecution(text)
22662266
val commands = commandBatch.commands
22672267
val hasTakeScreenshotCommand = commandBatch.hasTakeScreenshotCommand
2268-
val commandsToExecute = commands.filterNot { it is Command.Retrieve }
2268+
val commandsToExecute = commands.mapIndexedNotNull { index, command ->
2269+
when {
2270+
command is Command.Retrieve -> null
2271+
index < incrementalCommandCount && command !is Command.TakeScreenshot -> null
2272+
else -> command
2273+
}
2274+
}
22692275

22702276
if (hasTakeScreenshotCommand) {
22712277
pendingRetrievedInfoForNextScreenshot = buildRetrievedInfoForNextScreenshot(commands)

0 commit comments

Comments
 (0)