Repository navigation
refactor(a2ui)!: carry A2UI messages under the spec's messages key - #150
Merged
Merged
Conversation
chrisraygill
approved these changes
Nov 18, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moved from genkit-ai/genkit#7118 following the Python SDK repository split (includes the review test additions from @chrisraygill).
What's new
The Python
genkit-a2uipart now carries its A2UI messages under the spec'smessageskey instead ofenvelopes, matching the Dart, JS, and Go plugins:{ "data": { "messages": [ { "version": "v0.9", "createSurface": { "surfaceId": "tokyo-weather", "catalogId": "..." } } ] }, "metadata": { "mimeType": "application/a2ui+json" } }a2ui_partwrites{"messages": [...]}.is_a2ui_partandenvelopes_from_partsread either key, so parts written before this change (persisted sessions, older clients) still work.messageswins when both are present (including{"messages": []}), and amessagesthat is present butNonefalls back toenvelopes. Calling code is unchanged:Why
The A2UI extension spec puts the message list in a data part's
data. Genkit needsdatato be an object, so we wrapped the list, previously under a customenvelopeskey. The spec's own{messages: [...]}wrapper does the same job and is what renderers read.This keeps the plugins aligned across languages:
messagesmessagesorenvelopesmessagesmessagesorenvelopesmessagesmessagesorenvelopesmessagesmessagesorenvelopesIt also means user actions from a client on the new key (for example a Dart client using the
genkit_a2uiREADME helpers sending{messages: [{version, action}]}) reach the model as[UI action ...]lines instead of a bare[UI].Breaking Changes
The package is experimental, but code that reads
part.data['envelopes']directly must switch toenvelopes_from_parts(...)(or readmessages). Code that usesenvelopes_from_partsneeds no change.Not in this PR
envelopesfallback. Reading it is free and keeps old sessions replaying.envelopes_from_partsor other identifiers. Only the wire key changes.Testing
tests/part_test.pycovers the written key, legacyenvelopesreads, precedence when both keys are present (including emptymessages: []),Nonefallback, non-list values under either key, and wrong/missingmimeType/ text-part negative cases. The inbound click test runs with both keys. Test helpers readmessages, so every existing output test checks the written key. 68 pass;ruffandtyclean.