Fix messageTransformer to normalize HookMessage string content to array

HookMessage.content can be string or array, but LLM Message.content
must be an array. This was causing 'messages: at least one message
is required' errors when hooks sent string content.
This commit is contained in:
Mario Zechner 2025-12-27 20:53:46 +01:00
parent 204d27581b
commit 574f1cba3d

View file

@ -116,9 +116,11 @@ export function messageTransformer(messages: AppMessage[]): Message[] {
}
if (isHookMessage(m)) {
// Convert hook message to user message for LLM
// Normalize string content to array format
const content = typeof m.content === "string" ? [{ type: "text" as const, text: m.content }] : m.content;
return {
role: "user",
content: m.content,
content,
timestamp: m.timestamp,
};
}