Skip to content

Commit aa8d50e

Browse files
feat(pydantic-ai): trace step persistence lineage (#1194)
## Summary Pydantic AI Harness Step Persistence records `run_id` / `parent_run_id` for checkpoint, restore and fork, but Braintrust agent spans showed no lineage. When `pydantic_ai_harness` is importable, `setup_pydantic_ai()` now lazily patches the async `StepPersistence.for_run` hook (new `harness_patchers.py`) and records the resolved IDs on the Braintrust agent-run span: ```text metadata.step_persistence: {run_id: <this run>, parent_run_id: <source run, if Harness resolved one>} ``` - Continuations/forks stay separate traces (no forced parent/child tree). - No fork source is guessed: Harness's restore/fork helpers return plain message history, so `parent_run_id` is only set when Harness resolves it. - Works with native OTel/Logfire also enabled (our spans are always kept); older pydantic-ai (1.107.9) is untouched since the patch only applies when the hook exists. - Adds a dedicated Harness 0.75 / pydantic-ai 2.75 nox session with offline checkpoint/restore and fork tests; existing `latest` session and cassettes unchanged. Link to Devin session: https://braintrust.devinenterprise.com/sessions/b253a31c21104ab8baef1857d38a2cf0 Open in Devin Desktop: https://braintrust.devinenterprise.com/desktop/session/b253a31c21104ab8baef1857d38a2cf0?variant=devin --------- Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 416689a commit aa8d50e

8 files changed

Lines changed: 1111 additions & 7 deletions

‎py/src/braintrust/integrations/pydantic_ai/harness/cassettes/latest/test_step_persistence_lineage[continue_run-False].yaml‎

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

0 commit comments

Comments
 (0)