Skip to content

Commit 562a748

Browse files
committed
Add detailed debugging and improve status checking
1 parent 0c147dc commit 562a748

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

main.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,24 @@ async def chat_with_agent(self, message: str) -> ChatResponse:
271271
)
272272
logger.info(f"Created run, ID: {run.id}, Status: {run.status}")
273273

274+
# Log detailed run information for debugging
275+
logger.info(f"Run object type: {type(run)}")
276+
logger.info(f"Run object attributes: {dir(run)}")
277+
if hasattr(run, '__dict__'):
278+
logger.info(f"Run object dict: {run.__dict__}")
279+
if hasattr(run, 'last_error'):
280+
logger.info(f"Run last_error: {run.last_error}")
281+
if hasattr(run, 'required_action'):
282+
logger.info(f"Run required_action: {run.required_action}")
283+
274284
# Check run status (detailed debugging like sample script)
275285
logger.info(f"Run completed with status: {run.status}")
276-
if run.status == "failed":
277-
logger.error(f"Run failed: {getattr(run, 'last_error', 'Unknown error')}")
278-
assistant_response = f"Run failed: {getattr(run, 'last_error', 'Unknown error')}"
286+
if hasattr(run, 'last_error') and run.last_error:
287+
logger.error(f"Run failed: {run.last_error}")
288+
assistant_response = f"Run failed: {run.last_error}"
289+
elif "failed" in str(run.status).lower():
290+
logger.error(f"Run failed with status: {run.status}")
291+
assistant_response = f"Run failed with status: {run.status}"
279292

280293
# Display run steps and tool calls (like sample script)
281294
try:
@@ -296,7 +309,7 @@ async def chat_with_agent(self, message: str) -> ChatResponse:
296309
except Exception as e:
297310
logger.error(f"Error retrieving run steps: {e}")
298311

299-
if run.status == "completed":
312+
if "completed" in str(run.status).lower():
300313
# Get the response
301314
messages_paged = fresh_client.messages.list(thread_id=thread.id)
302315
messages = list(messages_paged) # Convert ItemPaged to list

0 commit comments

Comments
 (0)