@@ -250,19 +250,17 @@ async def test_include_contents_none_sequential_agents():
250250
251251def test_include_sources_empty_list_raises ():
252252 """include_sources=[] must raise ValueError — use None to disable filtering."""
253- with pytest .raises (ValueError , match = ' include_sources=\\ [\\ ]' ):
253+ with pytest .raises (ValueError , match = " include_sources=\\ [\\ ]" ):
254254 LlmAgent (
255- name = ' agent' ,
256- model = ' gemini-2.5-flash' ,
255+ name = " agent" ,
256+ model = " gemini-2.5-flash" ,
257257 include_sources = [],
258258 )
259259
260260
261261def test_include_sources_none_is_accepted ():
262262 """include_sources=None (default) must not raise."""
263- agent = LlmAgent (
264- name = 'agent' , model = 'gemini-2.5-flash' , include_sources = None
265- )
263+ agent = LlmAgent (name = "agent" , model = "gemini-2.5-flash" , include_sources = None )
266264 assert agent .include_sources is None
267265
268266
@@ -275,43 +273,37 @@ def test_include_sources_none_is_accepted():
275273async def test_include_sources_user_only_drops_upstream_agent_entries ():
276274 """Downstream agent with include_sources=['user'] receives only the human user message."""
277275 agent1_model = testing_utils .MockModel .create (
278- responses = [' Upstream agent reply' ]
276+ responses = [" Upstream agent reply" ]
279277 )
280278 agent1 = LlmAgent (
281- name = ' upstream' ,
279+ name = " upstream" ,
282280 model = agent1_model ,
283- instruction = ' You are upstream' ,
281+ instruction = " You are upstream" ,
284282 )
285283
286284 agent2_model = testing_utils .MockModel .create (
287- responses = [' Downstream response' ]
285+ responses = [" Downstream response" ]
288286 )
289287 agent2 = LlmAgent (
290- name = ' downstream' ,
288+ name = " downstream" ,
291289 model = agent2_model ,
292- include_sources = [' user' ],
293- instruction = ' You are downstream' ,
290+ include_sources = [" user" ],
291+ instruction = " You are downstream" ,
294292 )
295293
296- sequential = SequentialAgent (
297- name = 'pipeline' , sub_agents = [agent1 , agent2 ]
298- )
294+ sequential = SequentialAgent (name = "pipeline" , sub_agents = [agent1 , agent2 ])
299295 runner = testing_utils .InMemoryRunner (sequential )
300- runner .run (' Original user request' )
296+ runner .run (" Original user request" )
301297
302298 agent2_contents = testing_utils .simplify_contents (
303299 agent2_model .requests [0 ].contents
304300 )
305301
306302 # User message must be present
307- assert any (
308- 'Original user request' in str (c ) for _ , c in agent2_contents
309- )
303+ assert any ("Original user request" in str (c ) for _ , c in agent2_contents )
310304 # Upstream agent's narrative entry must be absent
311- assert not any (
312- 'Upstream agent reply' in str (c ) for _ , c in agent2_contents
313- )
314- assert not any ('For context:' in str (c ) for _ , c in agent2_contents )
305+ assert not any ("Upstream agent reply" in str (c ) for _ , c in agent2_contents )
306+ assert not any ("For context:" in str (c ) for _ , c in agent2_contents )
315307
316308
317309# ---------------------------------------------------------------------------
@@ -326,30 +318,28 @@ async def test_include_sources_user_self_drops_upstream_across_turns():
326318 narrative entries from the upstream agent across multiple invocations.
327319 """
328320 agent1_model = testing_utils .MockModel .create (
329- responses = [' Turn1 upstream reply' , ' Turn2 upstream reply' ]
321+ responses = [" Turn1 upstream reply" , " Turn2 upstream reply" ]
330322 )
331323 agent1 = LlmAgent (
332- name = ' upstream' ,
324+ name = " upstream" ,
333325 model = agent1_model ,
334- instruction = ' You are upstream' ,
326+ instruction = " You are upstream" ,
335327 )
336328
337329 agent2_model = testing_utils .MockModel .create (
338- responses = [' Turn1 downstream' , ' Turn2 downstream' ]
330+ responses = [" Turn1 downstream" , " Turn2 downstream" ]
339331 )
340332 agent2 = LlmAgent (
341- name = ' downstream' ,
333+ name = " downstream" ,
342334 model = agent2_model ,
343- include_sources = [' user' , ' self' ],
344- instruction = ' You are downstream' ,
335+ include_sources = [" user" , " self" ],
336+ instruction = " You are downstream" ,
345337 )
346338
347- sequential = SequentialAgent (
348- name = 'pipeline' , sub_agents = [agent1 , agent2 ]
349- )
339+ sequential = SequentialAgent (name = "pipeline" , sub_agents = [agent1 , agent2 ])
350340 runner = testing_utils .InMemoryRunner (sequential )
351- runner .run (' Turn 1 user message' )
352- runner .run (' Turn 2 user message' )
341+ runner .run (" Turn 1 user message" )
342+ runner .run (" Turn 2 user message" )
353343
354344 # Second invocation of downstream agent — should see user messages + own
355345 # prior turn, but not upstream's narrative entries.
@@ -358,14 +348,10 @@ async def test_include_sources_user_self_drops_upstream_across_turns():
358348 )
359349
360350 # User messages must be present
361- assert any (
362- 'Turn 1 user message' in str (c ) for _ , c in agent2_second_contents
363- )
364- assert any (
365- 'Turn 2 user message' in str (c ) for _ , c in agent2_second_contents
366- )
351+ assert any ("Turn 1 user message" in str (c ) for _ , c in agent2_second_contents )
352+ assert any ("Turn 2 user message" in str (c ) for _ , c in agent2_second_contents )
367353 # Upstream agent's narrative entries must be absent
368354 assert not any (
369- ' upstream reply' in str (c ).lower () for _ , c in agent2_second_contents
355+ " upstream reply" in str (c ).lower () for _ , c in agent2_second_contents
370356 )
371- assert not any (' For context:' in str (c ) for _ , c in agent2_second_contents )
357+ assert not any (" For context:" in str (c ) for _ , c in agent2_second_contents )
0 commit comments