Skip to content

Fix streamed citation annotation conversion - #129

Open
nathancooperjones wants to merge 1 commit into
openai:mainfrom
nathancooperjones:codex/normalize-stream-annotation-models
Open

Fix streamed citation annotation conversion#129
nathancooperjones wants to merge 1 commit into
openai:mainfrom
nathancooperjones:codex/normalize-stream-annotation-models

Conversation

@nathancooperjones

Copy link
Copy Markdown

Summary

  • Normalize Pydantic annotation models before response annotation validation.
  • Cover event-specific URL citation models used by newer OpenAI clients.

Problem

OpenAI 3.x can deserialize a streamed annotation into an event-specific Pydantic model. ChatKit validates that object against a structurally identical union from another module. Pydantic rejects the different model class before ChatKit can convert the citation.

Test plan

  • Full locked test suite: 130 passed.
  • Ruff checks passed.
  • Pyright passed.
  • Manual reproduction passed with the OpenAI 3.3.0 URL citation event class.

The repository-wide format check also reports four existing failures in unchanged files.

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalizing Pydantic event-specific annotation models to plain data before validating against ChatKit's structurally equivalent response union is the right compatibility boundary. It avoids coupling conversion to the exact generated model class while still letting the existing TypeAdapter enforce the annotation schema. The regression reproduces the cross-module URL-citation case rather than weakening validation globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants