Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: pin pydantic-ai instrumentation version (#10239)

AADETYA JAISWAL6e18b32c6861
diff --git a/marimo/_tracer.py b/marimo/_tracer.py
index a518a60daa..941a460817 100644
--- a/marimo/_tracer.py
+++ b/marimo/_tracer.py
@@ -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)
diff --git a/tests/test_tracer.py b/tests/test_tracer.py
index 759cc1c89f..b0a8405893 100644
--- a/tests/test_tracer.py
+++ b/tests/test_tracer.py
@@ -426,9 +426,21 @@ class TestInstrumentAI:
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)