Skip to content

Commit 7f4ff5f

Browse files
committed
fix: print error
# What does this PR do? ## Test Plan
1 parent b664564 commit 7f4ff5f

File tree

1 file changed

+9
-1
lines changed
  • src/llama_stack_client/lib/agents

1 file changed

+9
-1
lines changed

src/llama_stack_client/lib/agents/agent.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,15 @@ 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+
try:
263+
return last_chunk.event.payload.turn
264+
except Exception as e:
265+
if getattr(last_chunk, "error", None):
266+
raise RuntimeError(f"Turn did not complete. Error: {last_chunk.error}") from None
267+
else:
268+
raise RuntimeError(f"Turn did not complete with output: {last_chunk}") from None
261269

262270
def _create_turn_streaming(
263271
self,

0 commit comments

Comments
 (0)