Skip to content

Commit 60d4446

Browse files
fix(pydantic-ai): enforce the background tools version gate
> 🤖 **This text was AI-generated.** The patcher looked like it required Pydantic AI 2.x, but the patcher base class does not consult min_version. Use version_spec so 1.x skips the Harness patch even when both hook targets can be resolved. Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 4703a9e commit 60d4446

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎py/src/braintrust/integrations/pydantic_ai/harness/test_background_tools.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import asyncio
22
from importlib import import_module
33

4+
import pydantic_ai
45
import pytest
56
from braintrust import setup_pydantic_ai
7+
from braintrust.integrations.pydantic_ai.patchers import BackgroundToolExecutionPatcher
68
from braintrust.span_types import SpanTypeAttribute
79
from braintrust.test_helpers import find_span_by_name, find_spans_by_type, init_test_logger
810
from braintrust.test_helpers import with_memory_logger as with_memory_logger
@@ -12,6 +14,11 @@
1214
from pydantic_ai.usage import UsageLimits
1315

1416

17+
def test_background_tool_patcher_version_gate():
18+
assert BackgroundToolExecutionPatcher.applies(pydantic_ai, "2.75.0")
19+
assert not BackgroundToolExecutionPatcher.applies(pydantic_ai, "1.107.9")
20+
21+
1522
@pytest.mark.asyncio
1623
@pytest.mark.parametrize(
1724
("fails", "use_iter"),

‎py/src/braintrust/integrations/pydantic_ai/patchers.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class _BackgroundToolHandlerPatcher(FunctionWrapperPatcher):
224224

225225
class BackgroundToolExecutionPatcher(CompositeFunctionWrapperPatcher):
226226
name = "pydantic_ai.harness.background_tool_execution"
227-
min_version: ClassVar[str] = "2.75.0"
227+
version_spec = ">=2.0.0"
228228
sub_patchers = (_BackgroundToolHandlerPatcher, _BackgroundToolsRunPatcher)
229229

230230
@classmethod

0 commit comments

Comments
 (0)