Skip to content

Commit a69a3fa

Browse files
committed
debugging semantics when parts is not an array
1 parent 972e7b7 commit a69a3fa

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

agents/opencode.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,18 @@ function logPromptResult(
102102
options: AgentRunOptions | undefined,
103103
): void {
104104
logJson({ info: result.info }, options);
105-
result.parts.forEach((part) => logJson(part, options));
105+
if (Array.isArray(result.parts)) {
106+
result.parts.forEach((part) => logJson(part, options));
107+
} else {
108+
logError(
109+
{
110+
error: "invalid_parts_array",
111+
message: `Expected 'parts' to be an array, but got ${typeof result.parts}`,
112+
receivedResponse: result,
113+
},
114+
options,
115+
);
116+
}
106117
}
107118

108119
function serializeError(error: unknown): Record<string, unknown> {

0 commit comments

Comments
 (0)