@@ -31,7 +31,6 @@ import com.google.adk.kt.types.ToolType
3131import com.google.adk.kt.types.UsageMetadata
3232import kotlin.test.Test
3333import kotlin.test.assertEquals
34- import kotlin.test.assertNotEquals
3534import kotlin.test.assertNotNull
3635import kotlin.test.assertTrue
3736import kotlinx.coroutines.Dispatchers
@@ -108,100 +107,6 @@ class StreamingResponseAggregatorTest {
108107 assertEquals(" San Francisco" , fc.args[" location" ])
109108 }
110109
111- @Test
112- fun testStreamingFunctionCall_partialAndFinalResponseShareGeneratedId () = runBlocking {
113- val aggregator = StreamingResponseAggregator ()
114-
115- val partial1 =
116- aggregator.processResponse(
117- createFcResp(createPartialFc(" my_tool" , " $.x" , " hello" , willContinue = true ))
118- )
119- val unused =
120- aggregator.processResponse(
121- createFcResp(createPartialFc(null , " $.x" , " world" , willContinue = false ))
122- )
123- val finalResp = aggregator.aggregate()
124-
125- val finalFc = finalResp?.content?.parts?.single()?.functionCall
126- assertNotNull(finalFc)
127- assertEquals(mapOf (" x" to " hello world" ), finalFc.args)
128- val finalId = assertNotNull(finalFc.id)
129- assertTrue(finalId.startsWith(FunctionCall .ADK_FUNCTION_CALL_ID_PREFIX ))
130- assertEquals(finalId, partial1.content?.parts?.single()?.functionCall?.id)
131- }
132-
133- @Test
134- fun testStreamedCall_continuationChunkWithEmptyId_keepsFirstChunkId () = runBlocking {
135- val aggregator = StreamingResponseAggregator ()
136-
137- val partial1 =
138- aggregator.processResponse(
139- createFcResp(createPartialFc(" my_tool" , " $.x" , " hello" , willContinue = true ))
140- )
141- val unused =
142- aggregator.processResponse(
143- createFcResp(createPartialFc(null , " $.x" , " world" , willContinue = false ).copy(id = " " ))
144- )
145- val finalResp = aggregator.aggregate()
146-
147- val firstId = assertNotNull(partial1.content?.parts?.single()?.functionCall?.id)
148- assertEquals(firstId, finalResp?.content?.parts?.single()?.functionCall?.id)
149- }
150-
151- @Test
152- fun testStreamingFunctionCalls_inSeparateChunks_getDifferentIds () = runBlocking {
153- val aggregator = StreamingResponseAggregator ()
154-
155- val unused1 =
156- aggregator.processResponse(
157- createFcResp(createPartialFc(" tool_a" , " $.a" , " val_a" , willContinue = false ))
158- )
159- val unused2 =
160- aggregator.processResponse(
161- createFcResp(createPartialFc(" tool_b" , " $.b" , " val_b" , willContinue = false ))
162- )
163- val finalResp = aggregator.aggregate()
164-
165- val ids = finalResp?.content?.parts?.map { it.functionCall?.id }
166- assertNotNull(ids)
167- assertEquals(2 , ids.size)
168- assertTrue(ids.all { it != null && it.startsWith(FunctionCall .ADK_FUNCTION_CALL_ID_PREFIX ) })
169- assertNotEquals(ids[0 ], ids[1 ])
170- }
171-
172- @Test
173- fun testStreamedCallEndAndNewSameNameCall_inOneChunk_getDifferentIds () = runBlocking {
174- val aggregator = StreamingResponseAggregator ()
175-
176- val partial1 =
177- aggregator.processResponse(
178- createFcResp(createPartialFc(" get_weather" , " $.city" , " SF" , willContinue = true ))
179- )
180- val unused =
181- aggregator.processResponse(
182- LlmResponse (
183- content =
184- Content (
185- parts =
186- listOf (
187- Part (functionCall = FunctionCall (willContinue = false )),
188- Part (
189- functionCall = FunctionCall (name = " get_weather" , args = mapOf (" city" to " NY" ))
190- ),
191- )
192- )
193- )
194- )
195- val finalResp = aggregator.aggregate()
196-
197- val calls = finalResp?.content?.parts?.mapNotNull { it.functionCall }
198- assertNotNull(calls)
199- assertEquals(listOf (" SF" , " NY" ), calls.map { it.args[" city" ] })
200- assertEquals(partial1.content?.parts?.single()?.functionCall?.id, calls[0 ].id)
201- assertNotNull(calls[1 ].id)
202- assertNotEquals(calls[0 ].id, calls[1 ].id)
203- }
204-
205110 @Test
206111 fun testNestedPartialFunctionCallAggregation () = runBlocking {
207112 val aggregator = StreamingResponseAggregator ()
0 commit comments