feat: enhance error handling for socket connection errors

- Added `isError` property to `EmbeddedPiRunResult` and reply items to indicate error states.
- Updated error handling in `runReplyAgent` to provide more informative messages for specific socket connection errors.
This commit is contained in:
Emanuel Stadler
2026-01-06 21:17:55 +01:00
committed by Peter Steinberger
parent de454fc385
commit fb17a32283
2 changed files with 28 additions and 4 deletions

View File

@@ -99,6 +99,7 @@ export type EmbeddedPiRunResult = {
mediaUrl?: string;
mediaUrls?: string[];
replyToId?: string;
isError?: boolean;
}>;
meta: EmbeddedPiRunMeta;
};
@@ -1009,12 +1010,17 @@ export async function runEmbeddedPiAgent(params: {
usage,
};
const replyItems: Array<{ text: string; media?: string[] }> = [];
const replyItems: Array<{
text: string;
media?: string[];
isError?: boolean;
}> = [];
const errorText = lastAssistant
? formatAssistantErrorText(lastAssistant)
: undefined;
if (errorText) replyItems.push({ text: errorText });
if (errorText) replyItems.push({ text: errorText, isError: true });
const inlineToolResults =
params.verboseLevel === "on" &&
@@ -1047,6 +1053,7 @@ export async function runEmbeddedPiAgent(params: {
text: item.text?.trim() ? item.text.trim() : undefined,
mediaUrls: item.media?.length ? item.media : undefined,
mediaUrl: item.media?.[0],
isError: item.isError,
}))
.filter(
(p) =>