mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
4917c67c99
PydanticAI v2's AGUIAdapter.load_messages converts AG-UI attachments to native content types before the model boundary; v1 delivered the raw AG-UI part dicts. _NATIVE_CONTENT listed BinaryContent as a flatten fixpoint, so under v2 inline attachments were waved straight through and the whole provider gate was skipped: - inline PDFs were no longer text-extracted, so raw bytes went to OpenAI - unsupported image subtypes (HEIC/SVG/TIFF) were no longer degraded and reached the provider as images, which fails the turn - missing-mime magic-byte sniffing never ran - AudioUrl/VideoUrl were neither fixpoints nor classifiable, so they hit the fail-loud raise BinaryContent is no longer treated as a fixpoint. _classify_native_content maps native content onto the same (kind, scheme, mime, value) tuple the AG-UI classifier produces, so every existing gate — PDF extraction, image sniffing, the supported-subtype allow list, the binary choke point — applies unchanged. audio/* and video/* mimes are named explicitly because _kind_for routes them to "other", and a missing mime defaults to "image" so the sniffer runs. Five test assertions checked that state-backing content was still AG-UI InputContent, which encoded v1's bridging. They now assert the flatten's output (ImageUrl) never appears in state, which is the guarantee they were written to protect. Behaviour is otherwise unchanged: a supported inline image still flattens to an ImageUrl data URI exactly as on v1. 52/52 python tests pass, up from 42/52. Verified against pydantic-ai 2.22.0.