Skip to content

Commit 46f463e

Browse files
deepracticexsclaude
andcommitted
fix: tool-error result serialized as {} due to non-enumerable Error properties
Two fixes: 1. MonoDriver: tool-error event now sends error.message instead of raw Error object. Error properties are non-enumerable, so JSON.stringify produced "{}". 2. Presentation reducer: handleToolResult adds instanceof Error check as defense-in-depth, extracting .message before serialization. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c24428e commit 46f463e

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

packages/agentx/src/presentation/reducer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,12 @@ function handleToolResult(
381381
data: { toolCallId: string; result: unknown; isError: boolean }
382382
): PresentationState {
383383
const { toolCallId, result, isError } = data;
384-
const resultStr = typeof result === "string" ? result : JSON.stringify(result);
384+
const resultStr =
385+
typeof result === "string"
386+
? result
387+
: result instanceof Error
388+
? result.message
389+
: JSON.stringify(result);
385390

386391
const conversations = state.conversations.map((conv): Conversation => {
387392
if (conv.role !== "assistant") return conv;

packages/mono-driver/src/MonoDriver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export class MonoDriver implements Driver {
299299
}
300300
yield createEvent("tool_result", {
301301
toolCallId: part.toolCallId,
302-
result: part.error,
302+
result: part.error instanceof Error ? part.error.message : String(part.error),
303303
isError: true,
304304
});
305305
break;

0 commit comments

Comments
 (0)