File tree Expand file tree Collapse file tree
pydantic_ai_lightspeed/llamastack
tests/unit/pydantic_ai_lightspeed/llamastack Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7474from models .common .responses .types import ResponseInput
7575from models .common .turn_summary import TurnSummary
7676from models .config import Action
77- from utils .agents .streaming import generate_agent_response , retrieve_agent_response_generator
77+ from utils .agents .streaming import (
78+ generate_agent_response ,
79+ retrieve_agent_response_generator ,
80+ )
7881from utils .conversation_compaction import (
7982 CompactionResult ,
8083 CompactionStartedEvent ,
@@ -348,6 +351,7 @@ async def streaming_query_endpoint_handler( # pylint: disable=too-many-locals
348351 context = context ,
349352 responses_params = responses_params ,
350353 turn_summary = turn_summary ,
354+ background_topic_summary_tasks = _background_topic_summary_tasks ,
351355 ),
352356 media_type = response_media_type ,
353357 )
Original file line number Diff line number Diff line change 1+ # pylint: disable=too-many-branches, too-many-locals, too-many-statements
2+
13"""Custom OpenAI Responses model that works around Llama Stack streaming quirks.
24
35Llama Stack's Responses API emits MCP tool argument events *before*
@@ -190,15 +192,15 @@ async def _filtered_iter(
190192 yield buffer .pending_output_done
191193 self ._pre_args_buffers .pop (item_id , None )
192194
193- for item_id , buffer in list (self ._list_tools_buffers .items ()):
194- if not buffer .has_content ():
195+ for item_id , list_tools_buffer in list (self ._list_tools_buffers .items ()):
196+ if not list_tools_buffer .has_content ():
195197 continue
196198 logger .warning (
197199 "Flushing buffered mcp_list_tools event(s) without output_item.added "
198200 "for item_id=%s" ,
199201 item_id ,
200202 )
201- for replayed in self ._replay_list_tools_events (buffer ):
203+ for replayed in self ._replay_list_tools_events (list_tools_buffer ):
202204 yield replayed
203205 self ._list_tools_buffers .pop (item_id , None )
204206
Original file line number Diff line number Diff line change @@ -292,9 +292,7 @@ async def agent_response_generator(
292292 logger .debug ("Starting agent streaming response processing" )
293293 async with agent .run_stream_events (prompt ) as stream :
294294 async for event in stream :
295- logger .error (f"event: { event .event_kind } { repr (event )} " )
296295 if payload := dispatch_stream_event (event , dispatch_state ):
297- # print(f"payload: {payload.serialize_json()}")
298296 yield serialize_event (payload , media_type )
299297
300298 if dispatch_state .run_result is None :
@@ -428,7 +426,6 @@ def _(
428426
429427 if isinstance (part , NativeToolReturnPart ):
430428 if tool_result := process_native_tool_result (state , part ):
431- # print(f"Tool result summarized: {tool_result.model_dump_json()}")
432429 return ToolResultStreamPayload (data = tool_result )
433430 return None
434431
You can’t perform that action at this time.
0 commit comments