Repository navigation
Commit c07101c
fix(llm): normalize structured message content from OpenAI-compatible providers (#479)
* fix(openai): normalize array-shaped message.content before .trim()
GLM-5.3 hosted on Mistral's platform returns message.content as a
structured array of content parts (e.g. [{type:"text", text:"..."}])
instead of a plain string. fromResponse() assumed a string and passed
it straight to summarize.js's res.text.trim(), crashing with
"text.trim is not a function" on every deep-build call.
contentToText() now extracts text from array-of-parts content, and
throws explicitly (instead of silently coercing to "" or
"[object Object]") for any other unrecognized shape, so a future
provider format change surfaces loudly rather than corrupting the
graph silently.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* docs: soften comment wording per review feedback
Avoid asserting the array form is "outside the OpenAI spec" — the SDK's
own types allow array content for some message roles; this path just
didn't handle it for assistant responses.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test: cover contentToText array/null/unrecognized-shape handling
The graft-blast-radius bot flagged that neither contentToText nor
fromResponse was reached by any test. Adds four cases to the existing
OpenAI adapter suite: array-of-parts concatenation, non-text parts
dropped, null content, and the explicit throw on an unrecognized shape.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Code <noreply@anthropic.com>1 parent ff56c78 commit c07101c
2 files changed
Lines changed: 77 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
222 | 244 | | |
223 | 245 | | |
224 | 246 | | |
| |||
237 | 259 | | |
238 | 260 | | |
239 | 261 | | |
240 | | - | |
| 262 | + | |
241 | 263 | | |
242 | 264 | | |
243 | 265 | | |
| |||
258 | 280 | | |
259 | 281 | | |
260 | 282 | | |
261 | | - | |
| 283 | + | |
262 | 284 | | |
263 | 285 | | |
264 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
182 | 235 | | |
183 | 236 | | |
184 | 237 | | |
| |||
0 commit comments