Skip to content

Commit 18be56d

Browse files
test(pydantic-ai): replay a recorded harness tool run (#1197)
## Summary Replace the fake model in the Harness smoke test from #1191 with two recorded OpenAI Responses API calls using `gpt-4.1-mini`. The first response requests the registered `echo` tool and the second returns its result. Replay still checks step persistence and Braintrust agent, model, and tool span parentage. Remove the unused fake-model helpers. Link to Devin session: https://braintrust.devinenterprise.com/sessions/5c5011629ab54592879e094639413ace Open in Devin Desktop: https://braintrust.devinenterprise.com/desktop/session/5c5011629ab54592879e094639413ace?variant=devin Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
1 parent 9878cf7 commit 18be56d

3 files changed

Lines changed: 260 additions & 32 deletions

File tree

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

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎py/src/braintrust/integrations/pydantic_ai/harness/cassettes/latest/test_harness_run_traces_model_and_tool.yaml‎

Lines changed: 249 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
from importlib import import_module
22

33
import pytest
4-
from braintrust.integrations.pydantic_ai._test_harness import OFFLINE_ANSWER, call_tool_once, make_harness_agent
54
from braintrust.span_types import SpanTypeAttribute
65
from braintrust.test_helpers import find_span_by_name, find_spans_by_type
6+
from pydantic_ai import Agent, ModelSettings
77

88

9+
@pytest.mark.vcr
910
@pytest.mark.asyncio
1011
async def test_harness_run_traces_model_and_tool(harness_spans):
1112
persistence = import_module("pydantic_ai_harness.step_persistence")
1213
store = persistence.InMemoryStepStore()
13-
agent = make_harness_agent(
14-
"harness_smoke",
15-
call_tool_once("echo", {"text": "hello"}),
14+
agent = Agent(
15+
"openai:gpt-4.1-mini",
16+
name="harness_smoke",
17+
model_settings=ModelSettings(temperature=0, max_tokens=64),
1618
capabilities=[persistence.StepPersistence(store=store)],
1719
)
1820

1921
@agent.tool_plain
2022
def echo(text: str) -> str:
2123
return text
2224

23-
result = await agent.run("Echo hello.", run_id="harness-smoke")
25+
result = await agent.run(
26+
"Call the echo tool with text 'hello', then reply with the tool's exact output.",
27+
run_id="harness-smoke",
28+
)
2429

25-
assert result.output == OFFLINE_ANSWER
30+
assert result.output == "hello"
2631
assert await store.list_events(run_id="harness-smoke")
2732

2833
spans = harness_spans.pop()

0 commit comments

Comments
 (0)