We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 827b3e1 commit c524511Copy full SHA for c524511
packages/agent-runtime/src/run-agent-step.ts
@@ -288,7 +288,18 @@ export const runAgentStep = async (
288
onCostCalculated,
289
n: params.n,
290
})
291
- const nResponses = JSON.parse(responsesString) as string[]
+
292
+ let nResponses: string[]
293
+ try {
294
+ nResponses = JSON.parse(responsesString) as string[]
295
+ if (!Array.isArray(nResponses)) {
296
+ // If it parsed but isn't an array, treat as single response
297
+ nResponses = [responsesString]
298
+ }
299
+ } catch (e) {
300
+ // If parsing fails, treat as single raw response (common for n=1)
301
302
303
304
// Update agent state with the message history including the generations
305
agentState = {
0 commit comments