-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
OpenTelemetrybugReport that something isn't working, or PR implementing a fixReport that something isn't working, or PR implementing a fixgood first issueGood for newcomersGood for newcomers
Description
Initial Checks
- I'm using the latest version of Pydantic AI
- I've searched for my issue in the issue tracker before opening this issue
Description
Previously pydantic/logfire#1515
All exceptions are being automatically caught and recorded as errors by tracer.start_as_current_span. But CallDeferred and ApprovalRequired aren't really errors. They show up as red in the logfire UI. And this isn't good for other OTel backends either. So exceptions need to be handled more manually for the running tool span.
Some queries may be checking for these exceptions already, so this should be changed in a new InstrumentationSettings version.
The exception and metadata should also be recorded (regardless of InstrumentationSettings version) as new regular span attributes on the span so that there's an alternative way to query this info.
Minimal, Reproducible Example
from pydantic_ai import Agent, DeferredToolRequests, CallDeferred
import logfire
logfire.configure()
logfire.instrument_pydantic_ai()
agent = Agent("openai:gpt-5.2", output_type=[DeferredToolRequests, str])
@agent.tool_plain
def delete_file(path: str) -> str:
raise CallDeferred()
r1 = agent.run_sync("Delete `__init__.py`.")Logfire Trace
Python, Pydantic AI & LLM client version
Pydantic AI 1.63.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
OpenTelemetrybugReport that something isn't working, or PR implementing a fixReport that something isn't working, or PR implementing a fixgood first issueGood for newcomersGood for newcomers