Skip to content

[Capability] Preserve optional content fields in PromptResultFormatter - #406

Open
chr-hertel wants to merge 2 commits into
mainfrom
prompt-formatter-optional-fields
Open

[Capability] Preserve optional content fields in PromptResultFormatter#406
chr-hertel wants to merge 2 commits into
mainfrom
prompt-formatter-optional-fields

Conversation

@chr-hertel

@chr-hertel chr-hertel commented Jul 27, 2026

Copy link
Copy Markdown
Member

PromptResultFormatter rebuilt typed content arrays from only their required fields, silently dropping annotations (all types) and _meta/explicit mimeType (embedded resources). It now delegates to the schema classes' fromArray(), keeping the historical mimeType defaulting and error contract. Also adds annotations support to ImageContent for parity with the other content types.

Noticed while reviewing #400

🤖 Generated with Claude Code

The formatter's typed-content path rebuilt each Content object from only
its required fields, silently dropping everything else a prompt returned
(annotations on every type, _meta and explicit mimeType on embedded
resource contents). Delegate to the schema classes' fromArray() instead,
keeping the historical mimeType defaulting and RuntimeException-with-
index error contract.

ImageContent was the only content class without annotations support, so
it gains the same constructor/fromArray()/jsonSerialize() handling as
TextContent and AudioContent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@chr-hertel chr-hertel added this to the 0.8.0 milestone Jul 27, 2026
@chr-hertel chr-hertel added bug Something isn't working enhancement Request for a new feature that's not currently supported labels Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement Request for a new feature that's not currently supported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant