Conversation
Ports OAI-010 to Pydantic AI. The loss is larger in this SDK than in the OpenAI pack, and the rule text says so: Pydantic AI emits OpenTelemetry spans for each run and tool call, so everything around a print is already correlated to a trace and the print is the one diagnostic landing outside it, unattached to the run that produced it. The fix names attaching the detail to the current span (Logfire or the OTel API) alongside the module logger.
|
Thanks @bradAGI, this is a well-built rule and exactly how I want ports across SDK packs done. The framing is genuinely Pydantic AI's own (the OpenTelemetry span argument, and the Logfire/OTel span attachment in the |
Engine half of a coordinated pair with trustabl/agent-reliability-rules#71, on a branch of the same name so the rules-sync job resolves the matching pack rather than main. Neither half should merge alone — check-rules-sync.sh fails if they do. Mirrors pydantic_ai/observability.yaml into testdata/rules-fixture and adds cases to policyRuleCases, as TestPolicyRules_AllRulesCovered requires. Three cases: the print, the module-logger remediation the fix text prescribes, and a pprint call that must stay silent. The third pins has_print_call's bare-callee behavior, so the rule cannot regress into substring matching that sweeps in pprint and every other callee whose name contains "print".
Ports OAI-010 to Pydantic AI — the observability dimension isn't covered in any of the five newer packs.
The loss is larger in this SDK than in the OpenAI pack, which is what the rule text leads with. Pydantic AI emits OpenTelemetry spans for each run and tool call, so everything around this
printis already correlated to a trace — the bare print is the one diagnostic that lands outside it, unattached to the run that produced it. That's a sharper argument than "it disappears from logs," and it points at a better fix: attach the detail to the current span via Logfire or the OTel API, rather than only swapping in a module logger.The stdio-transport corruption note from OAI-010 carries over, since a Pydantic AI tool served over an MCP stdio transport has the same JSON-RPC interleaving problem.
Verification — engine built at
main:Fire (
print(f"looking up {order_id}")in the tool body):PYD-012, PYD-101, PYD-201Silent (
logger.info("looking up %s", order_id)):PYD-101, PYD-201has_print_callmatches a bareprintcallee, sopprintand other attribute calls don't false-positive.No new predicates, so no
schema_versionbump.