chore: improve error logging for RuntimeError (#6055)

This commit is contained in:
Xingyao Wang 2025-01-05 18:02:42 -05:00 committed by GitHub
parent 00d7395e09
commit f8735efadf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -209,10 +209,15 @@ class AgentController:
try:
await self._step()
except Exception as e:
traceback.print_exc()
self.log('error', f'Error while running the agent: {e}')
self.log(
'error',
f'Error while running the agent (session ID: {self.id}): {e}. '
f'Traceback: {traceback.format_exc()}',
)
reported = RuntimeError(
'There was an unexpected error while running the agent.'
'There was an unexpected error while running the agent. Please '
f'report this error to the developers. Your session ID is {self.id}. '
f'Exception: {e}.'
)
if isinstance(e, litellm.AuthenticationError) or isinstance(
e, litellm.BadRequestError