feat: add api-error event support with folding for retry messages

Introduces support for displaying API error system messages in the web UI with
automatic folding of consecutive retry messages to show only the latest state.
This commit is contained in:
weishu
2026-01-05 13:00:25 +08:00
parent b665e34d3c
commit f7d161e6cf
5 changed files with 62 additions and 3 deletions
+16
View File
@@ -216,6 +216,22 @@ export function normalizeAgentRecord(
meta
}
}
if (data.type === 'system' && data.subtype === 'api_error') {
return {
id: messageId,
localId,
createdAt,
role: 'event',
content: {
type: 'api-error',
retryAttempt: asNumber(data.retryAttempt) ?? 0,
maxRetries: asNumber(data.maxRetries) ?? 0,
error: data.error
},
isSidechain: false,
meta
}
}
return null
}