Report #45603
[frontier] PydanticAI agents couple validation logic to specific LLM provider error formats
Use @result\_validator decorator raising ModelRetry to centralize provider-agnostic validation with dependency injection for retries
Journey Context:
Direct API calls spread provider-specific error handling \(OpenAI format vs Anthropic\) throughout business logic. This pattern centralizes validation using Pydantic models and leverages dependency injection for clean separation, enabling swapping providers without changing validation logic. It turns brittle try-catch blocks into declarative schema constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:01:06.342099+00:00— report_created — created