File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed
adapter_ag_ui/adapter_ag_ui
pydantic_ai_slim/pydantic_ai/models Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -313,7 +313,7 @@ async def _tool_events(
313
313
pass
314
314
case Iterable () as iter :
315
315
for item in iter :
316
- if isinstance (item , BaseEvent ):
316
+ if isinstance (item , BaseEvent ): # pragma: no branch
317
317
self .logger .debug ('ag-ui event: %s' , item )
318
318
yield encoder .encode (item )
319
319
case _: # pragma: no cover
@@ -481,11 +481,8 @@ async def _handle_agent_event(
481
481
tool_call_id = agent_event .part .tool_call_id ,
482
482
),
483
483
),
484
+ None , # Signal continuation of the stream.
484
485
]
485
-
486
- # TODO(steve): Merge with above list if we don't remove the local_tool_calls case.
487
- if tool_name :
488
- stream_ctx .part_ends .append (None ) # Signal continuation of the stream.
489
486
case ThinkingPart (): # pragma: no cover
490
487
# No equivalent AG-UI event yet.
491
488
pass
@@ -574,7 +571,7 @@ def _convert_history(messages: list[Message]) -> list[ModelMessage]:
574
571
]
575
572
)
576
573
)
577
- case DeveloperMessage ():
574
+ case DeveloperMessage (): # pragma: no branch
578
575
# TODO(steve): Should these be handled differently?
579
576
result .append (ModelRequest (parts = [SystemPromptPart (content = msg .content )]))
580
577
Original file line number Diff line number Diff line change @@ -265,21 +265,21 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
265
265
event = self ._parts_manager .handle_tool_call_delta (
266
266
vendor_part_id = i , tool_name = part .tool_name , args = '' , tool_call_id = part .tool_call_id
267
267
)
268
- if event is not None :
268
+ if event is not None : # pragma: no branch
269
269
yield event
270
270
271
271
# Stream the args as JSON string in chunks.
272
272
args_json = pydantic_core .to_json (part .args ).decode ()
273
273
* chunks , last_chunk = args_json .split (',' ) if ',' in args_json else [args_json ]
274
274
chunks = [f'{ chunk } ,' for chunk in chunks ] if chunks else []
275
- if last_chunk :
275
+ if last_chunk : # pragma: no branch
276
276
chunks .append (last_chunk )
277
277
278
278
for chunk in chunks :
279
279
event = self ._parts_manager .handle_tool_call_delta (
280
280
vendor_part_id = i , tool_name = None , args = chunk , tool_call_id = part .tool_call_id
281
281
)
282
- if event is not None :
282
+ if event is not None : # pragma: no branch
283
283
yield event
284
284
else :
285
285
yield self ._parts_manager .handle_tool_call_part (
You can’t perform that action at this time.
0 commit comments