{"record":{"id":"6cbb73f71e9ae6af","repo":"diegosouzapw/OmniRoute","slug":"hailuo-web-does-not-support-tool-result-messages","errorCode":null,"errorMessage":"Hailuo Web does not support tool result messages","messagePattern":"Hailuo Web does not support tool result messages","errorType":"validation","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"open-sse/executors/hailuo-web.ts","lineNumber":171,"sourceCode":"      }\n      const record = part as Record<string, unknown>;\n      if (\n        (record.type === \"text\" || record.type === \"input_text\") &&\n        typeof record.text === \"string\"\n      ) {\n        return record.text;\n      }\n      throw new Error(\"Hailuo Web does not support image, audio, file, or tool content\");\n    })\n    .join(\"\");\n}\n\n/** Fold text-only OpenAI history into the single msgContent field Hailuo accepts. */\nexport function foldHailuoMessages(messages: HailuoInputMessage[]): string {\n  const parts: string[] = [];\n  for (const message of messages) {\n    if (message.role === \"tool\" || message.role === \"function\") {\n      throw new Error(\"Hailuo Web does not support tool result messages\");\n    }\n    if (message.tool_calls !== undefined) {\n      throw new Error(\"Hailuo Web does not support assistant tool calls\");\n    }\n    const text = textFromContent(message.content);\n    if (!text) continue;\n    if (message.role === \"system\" || message.role === \"developer\") {\n      parts.push(`System: ${text}`);\n    } else if (message.role === \"user\") {\n      parts.push(parts.length > 0 ? `User: ${text}` : text);\n    } else if (message.role === \"assistant\") {\n      parts.push(`Assistant: ${text}`);\n    } else {\n      throw new Error(`Hailuo Web does not support message role ${message.role}`);\n    }\n  }\n  return parts.join(\"\\n\\n\").trim();\n}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/hailuo-web.ts#L153-L189","documentation":"Capability validation in foldHailuoMessages: a message with role 'tool' or 'function' (an OpenAI tool result) was encountered while folding history. Hailuo's single-prompt web API cannot represent tool result messages, so the fold aborts.","triggerScenarios":"Thrown at open-sse/executors/hailuo-web.ts:171 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return a 400: tool/function messages are not supported by Hailuo Web","Fall back to a tool-capable provider for this request"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}