Repository navigation
feat(pydantic-ai): trace harness capability decisions - #1193
Abhijeet Prasad (AbhiPrasad) merged 5 commits into
Conversation
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e026f1250a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".
e026f12 to
0bdb8a0
Compare
edfc201 to
3baceb0
Compare
> 🤖 **This text was AI-generated.**
Braintrust traces show the agent and model calls but leave out what
Pydantic AI Harness did between them. Patch the optional Harness hooks
to record history compaction, memory injection, guardrail blocks, and
the model route without depending on native instrumentation.
```text
agent_run
model_router.select
agent_run [model_router]
memory.inject
compact_messages
guardrail blocked output
```
Older Pydantic AI versions and installs without Harness continue to
use the existing agent and model patches.
Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
> 🤖 **This text was AI-generated.** Run the Harness decision tests alongside the existing offline smoke test. Reuse its agent factory, in-memory span fixture, and nox session rather than maintaining a second Harness dependency pin or test setup. Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
> 🤖 **This text was AI-generated.** Record real OpenAI calls for compaction, memory injection, guardrail blocks, and model routing. The tests replay those calls without credentials and still assert the Braintrust spans and their parentage. Routing reuses the same recording with native instrumentation on and off. Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
> 🤖 **This text was AI-generated.** A guardrail reason can quote content the policy blocked. Keep the direction and outcome on the span, but leave the reason in the application exception. Allowlist the router's mode, step, probability, and error type so new upstream attributes are not captured implicitly. Skip compaction decision spans when the result was retrieved from detached background work. Foreground compaction still reports the message counts. Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
3baceb0 to
15b40d7
Compare
> 🤖 **This text was AI-generated.** Use a consistent harness_* operation name for decision spans, following the snake_case convention of Pydantic AI task spans such as agent_run. Put the guardrail direction in metadata so every guardrail block has the same span name, regardless of which part of the run it blocked. Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
Summary
Braintrust now traces four Pydantic AI Harness decisions as child
taskspans of the current agent run. Braintrust patches the optional Harness
package directly and keeps its spans even when native OTel/Logfire is on.
The fixed
harness_*operation names follow the integration's snake_casetask names, such as
agent_run.harness_message_compactionharness_memory_injectionharness_guardrail_blockharness_model_selectionharness/test_decisions.pyruns in the shared Harness nox session from#1191. It replays real OpenAI VCR cassettes, including model selection with
native instrumentation off and on. Older Pydantic AI versions and
installations without Harness remain supported.