-
Notifications
You must be signed in to change notification settings - Fork 179
Description
Description
We're using pydantic-ai and just started using logfire as well.
When an agent run receives an error from the provider, logfire would parse the error and display at the top of the Exception Traceback the exact issue like:
pydantic_ai.exceptions.ModelHTTPError: status_code: 400, model_name: gpt-5-mini, body: {'message': 'Input tokens exceed the configured limit of 272000 tokens. Your messages resulted in 382581 tokens. Please reduce the length of the messages.', 'type': 'invalid_request_error', 'param': 'messages', 'code': 'context_length_exceeded'}
This is great as you immediately see and understand what the issue was.
However if you're using FallbackModel (which we do across all our agents), the red summary at the top shows:
pydantic_ai.exceptions.FallbackExceptionGroup: All models from FallbackModel failed (2 sub-exceptions)
which doesn't mean anything, and you need to dig into the massive dump at the bottom to find the cause.
Same goes for the retry mechanism, e.g. for non-provider exceptions, the red summary at the top shows:
pydantic_ai.exceptions.UnexpectedModelBehavior: Tool 'documents_analyzer' exceeded max retries count of 1
which is again meaningless and you have to find the cause yourself.
would be nice to see the underlining issue ("context_length_exceeded") in all 3 cases.
Thanks!