fix: check for error before early return in extractContentFromMessage

Addresses Codex review feedback - ensures error messages are surfaced
even when content is missing/undefined
This commit is contained in:
Aaron authored and Peter Steinberger committed 2026-01-20 08:36:36 +00:00
1 parent 476087f879
commit 9609a3af40
1 file changed
+10 -1
+10 -1
View File
@@ -44,7 +44,16 @@ export function extractContentFromMessage(message: unknown): string {
const content = record.content;
if (typeof content === "string") return content.trim();
if (!Array.isArray(content)) return "";
// Check for error BEFORE returning empty for non-array content
if (!Array.isArray(content)) {
const stopReason = typeof record.stopReason === "string" ? record.stopReason : "";
if (stopReason === "error") {
const errorMessage = typeof record.errorMessage === "string" ? record.errorMessage : "";
return formatRawAssistantErrorForUi(errorMessage);
}
return "";
}
const parts: string[] = [];
for (const block of content) {