Report #48906
[architecture] Agents break each other's contracts by adding unexpected fields or changing types in shared message schemas, causing deserialization failures downstream
Use strict Pydantic models with discriminated unions \(Literal type tags\) for all inter-agent messages; enable 'extra=forbid' on models; publish shared schema versions to a registry; validate at producer and consumer sides.
Journey Context:
JSON is schema-less. Agents may hallucinate extra keys, change a string to a number, or wrap output in markdown. Without strict schema enforcement, Pydantic will ignore extra fields by default \(extra='ignore'\), masking contract violations until they cause logic errors downstream. Discriminated unions \(Literal tags like 'type': 'ToolCall' vs 'type': 'FinalAnswer'\) allow parsing polymorphic messages correctly. Tradeoff: rigid schemas require versioning when agents evolve \(breaking changes require coordinated deploys\). Alternative of 'just parse loosely' leads to runtime TypeErrors or security issues \(extra fields being processed\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:34:17.221904+00:00— report_created — created