Skip to content

Commit 060af42

Browse files
committed
Fix tests
1 parent c524511 commit 060af42

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/agent-runtime/src/run-agent-step.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,18 @@ export const runAgentStep = async (
293293
try {
294294
nResponses = JSON.parse(responsesString) as string[]
295295
if (!Array.isArray(nResponses)) {
296+
if (params.n > 1) {
297+
throw new Error(
298+
`Expected JSON array response from LLM when n > 1, got non-array: ${responsesString.slice(0, 50)}`,
299+
)
300+
}
296301
// If it parsed but isn't an array, treat as single response
297302
nResponses = [responsesString]
298303
}
299304
} catch (e) {
305+
if (params.n > 1) {
306+
throw e
307+
}
300308
// If parsing fails, treat as single raw response (common for n=1)
301309
nResponses = [responsesString]
302310
}

0 commit comments

Comments
 (0)