Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion marimo/_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ def _instrument_ai(provider: trace.TracerProvider) -> None:
from pydantic_ai import Agent
from pydantic_ai.models.instrumented import InstrumentationSettings

Agent.instrument_all(InstrumentationSettings(tracer_provider=provider))
Agent.instrument_all(
InstrumentationSettings(tracer_provider=provider, version=5)
)
LOGGER.debug("Enabled AI instrumentation")
except Exception as e:
LOGGER.debug("AI instrumentation failed: %s", e)
Expand Down
14 changes: 13 additions & 1 deletion tests/test_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,21 @@ def test_instruments_when_pydantic_ai_installed(
from pydantic_ai.models.instrumented import InstrumentationSettings

provider = MagicMock()
with patch("pydantic_ai.Agent.instrument_all") as mock_instrument:
with (
patch("pydantic_ai.Agent.instrument_all") as mock_instrument,
patch(
"pydantic_ai.models.instrumented.InstrumentationSettings",
wraps=InstrumentationSettings,
) as mock_settings,
):
_instrument_ai(provider)

# Verify version 5 is passed explicitly instead of relying on newer
# Pydantic-AI defaults.
mock_settings.assert_called_once_with(
tracer_provider=provider,
version=5,
)
mock_instrument.assert_called_once()
settings = mock_instrument.call_args.args[0]
assert isinstance(settings, InstrumentationSettings)
Expand Down
Loading