SIGN IN SIGN UP

fix: accept array-based chat content with thinking and text parts (#17782)

## Background

OpenAI-compatible backends returning array-based chat content caused
published generate and stream APIs to reject otherwise valid responses
instead of returning reasoning and text.

## Root Cause

The non-stream and stream response schemas only accepted string content,
and both processing paths assumed strings. Reproduction tests confirmed
Zod rejected arrays at choices[].message.content and
choices[].delta.content.

## Summary

Added tolerant string-or-array content parsing, normalized text and
thinking parts while preserving order, ignored unknown part types,
maintained streaming block transitions, and added a patch changeset.

## Testing

Added four regression cases covering generate and stream normalization
plus unknown-part handling in Node and Edge runtimes.

## End-to-end Validation

- `pnpm -C examples/ai-functions exec tsx -e '<live Mistral
generate/stream probe>'` — live `mistral-small-latest` calls returned
reasoning and text for both generate and stream without validation
errors.

## Related Issues

Fixes #13703

Closes #17779

Co-authored-by: tobwen <1864057+tobwen@users.noreply.github.com>
L
Lars Grammel committed
23eb659f2c48dfff40336ec6c88356e4f40a0995
Parent: e79bc7a
Committed by GitHub <noreply@github.com> on 8/28/2026, 5:36:39 PM