File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
src/llama_stack_client/lib/agents Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,18 @@ def create_turn(
257257 chunks = [x for x in self ._create_turn_streaming (messages , session_id , toolgroups , documents )]
258258 if not chunks :
259259 raise Exception ("Turn did not complete" )
260- return chunks [- 1 ].event .payload .turn
260+
261+ last_chunk = chunks [- 1 ]
262+ if hasattr (last_chunk , "error" ):
263+ if "message" in last_chunk .error :
264+ error_msg = last_chunk .error ["message" ]
265+ else :
266+ error_msg = str (last_chunk .error )
267+ raise RuntimeError (f"Turn did not complete. Error: { error_msg } " )
268+ try :
269+ return last_chunk .event .payload .turn
270+ except AttributeError :
271+ raise RuntimeError (f"Turn did not complete. Output: { last_chunk } " ) from None
261272
262273 def _create_turn_streaming (
263274 self ,
You can’t perform that action at this time.
0 commit comments