Add truncation for content array messages i.e. messages that have a content key, where content is an array of objects e.g. {"type": "text", "text": "some string"}. Previously these were returned as is bypassing the truncation logic. This PR makes sure these messages get truncated as well.
We already handled parts array messages, which have essentially the same format but use a parts key. So I basically just generalized the truncatePartsMessage to also handle the content array format.
Note: After switching to the Span V2 protocol we will get rid of truncation in the SDK altogether, but for now we should make sure to properly truncate.
Note
The pull request "fix(core): Truncate content array format in Vercel" was created by @nicohrubec but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.
Add truncation for content array messages i.e. messages that have a
contentkey, wherecontentis an array of objects e.g.{"type": "text", "text": "some string"}. Previously these were returned as is bypassing the truncation logic. This PR makes sure these messages get truncated as well.We already handled parts array messages, which have essentially the same format but use a
partskey. So I basically just generalized thetruncatePartsMessageto also handle the content array format.Note: After switching to the Span V2 protocol we will get rid of truncation in the SDK altogether, but for now we should make sure to properly truncate.