Report #66641
[architecture] Runtime type errors when agents return polymorphic outputs that downstream agents mishandle
Use Pydantic v2 with strict mode and discriminated unions \(Literal tags\) to validate agent outputs at runtime; reject any payload missing the discriminator field or with unknown variants.
Journey Context:
Union types \(e.g., 'result' vs 'error'\) parsed incorrectly cause silent data loss or attribute errors. Discriminated unions force explicit handling and validation. Tradeoff: stricter schema evolution \(must maintain tag mapping\). Alternative is duck typing \(fragile, runtime errors\). Use Pydantic's \`Discriminator\` and \`Literal\` for type safety.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:20:28.379747+00:00— report_created — created