diegosouzapw/OmniRoute · error · Error
Hailuo Web does not support message role
Error message
Hailuo Web does not support message role ${message.role} What it means
Role validation in foldHailuoMessages: a message role outside the accepted set (system/developer/user/assistant) reached the fold — the interpolated name identifies it. Hailuo's prompt folding only understands these standard roles, so unknown roles are rejected rather than silently dropped.
Solutions
- Return a 400 naming the unsupported role
- Map the unknown role to user or system before folding if a sensible mapping exists
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at open-sse/executors/hailuo-web.ts:185 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/3f401a97c2cce164.
Report an issue: GitHub.
Appendix: source
Thrown at open-sse/executors/hailuo-web.ts:185
export function foldHailuoMessages(messages: HailuoInputMessage[]): string {
const parts: string[] = [];
for (const message of messages) {
if (message.role === "tool" || message.role === "function") {
throw new Error("Hailuo Web does not support tool result messages");
}
if (message.tool_calls !== undefined) {
throw new Error("Hailuo Web does not support assistant tool calls");
}
const text = textFromContent(message.content);
if (!text) continue;
if (message.role === "system" || message.role === "developer") {
parts.push(`System: ${text}`);
} else if (message.role === "user") {
parts.push(parts.length > 0 ? `User: ${text}` : text);
} else if (message.role === "assistant") {
parts.push(`Assistant: ${text}`);
} else {
throw new Error(`Hailuo Web does not support message role ${message.role}`);
}
}
return parts.join("\n\n").trim();
}
export interface HailuoStreamState {
emittedLen: number;
}
/** `message_result.content` is a cumulative snapshot, not a delta — diff it. */
export function extractHailuoMessageDelta(content: string, state: HailuoStreamState): string {
if (typeof content !== "string" || content.length <= state.emittedLen) return "";
const delta = content.slice(state.emittedLen);
state.emittedLen = content.length;
return delta;
}
export type HailuoSseLine =View on GitHub (pinned to a179ffed5b)