- Notifications
You must be signed in to change notification settings - Fork1k
Closed
Description
Description
When using thecapture_run_messages
context manager - user errors also show an internal error from the library.
Exceptions occur inside an internal exception handler in pydanticAI and will include something like..
...LookupError: <ContextVar name='var' at 0x10635a020>During handling of the above exception, another exception occurred:...<user exception>
Which is confusing and unnecessary
example for reproduction
frompydantic_aiimport (Agent,capture_run_messages,)agent=Agent('openai:gpt-4o')withcapture_run_messages()asmessages:result=agent.run_sync('How are you?')1/0print(messages)
References
From the docs -https://ai.pydantic.dev/agents/#model-errors
Metadata
Metadata
Assignees
Labels
No labels