fix: normalize unknown prompt errors
This commit is contained in:
@@ -156,6 +156,17 @@ function formatUserTime(date: Date, timeZone: string): string | undefined {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function describeUnknownError(error: unknown): string {
|
||||||
|
if (error instanceof Error) return error.message;
|
||||||
|
if (typeof error === "string") return error;
|
||||||
|
try {
|
||||||
|
const serialized = JSON.stringify(error);
|
||||||
|
return serialized ?? "Unknown error";
|
||||||
|
} catch {
|
||||||
|
return "Unknown error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function buildEmbeddedSandboxInfo(
|
export function buildEmbeddedSandboxInfo(
|
||||||
sandbox?: Awaited<ReturnType<typeof resolveSandboxContext>>,
|
sandbox?: Awaited<ReturnType<typeof resolveSandboxContext>>,
|
||||||
): EmbeddedSandboxInfo | undefined {
|
): EmbeddedSandboxInfo | undefined {
|
||||||
@@ -601,10 +612,7 @@ export async function runEmbeddedPiAgent(params: {
|
|||||||
}
|
}
|
||||||
if (promptError && !aborted) {
|
if (promptError && !aborted) {
|
||||||
const fallbackThinking = pickFallbackThinkingLevel({
|
const fallbackThinking = pickFallbackThinkingLevel({
|
||||||
message:
|
message: describeUnknownError(promptError),
|
||||||
promptError instanceof Error
|
|
||||||
? promptError.message
|
|
||||||
: String(promptError),
|
|
||||||
attempted: attemptedThinking,
|
attempted: attemptedThinking,
|
||||||
});
|
});
|
||||||
if (fallbackThinking) {
|
if (fallbackThinking) {
|
||||||
|
|||||||
Reference in New Issue
Block a user