From 469874ecb64728b26dafd2259a35f42e075987dd Mon Sep 17 00:00:00 2001 From: engineer Date: Sun, 15 Feb 2026 00:30:54 -0800 Subject: [PATCH] fix: guard detectPlanningLoop against non-array messages input The OpenCode plugin framework can pass {} instead of an array to detectPlanningLoop via the session event handler, causing TypeError: '{} is not iterable'. This made every HTTP request to the server return 500, blocking E2E test suites. Add Array.isArray guard at the top of detectPlanningLoop itself, matching the existing pattern in buildTaskContext. --- reflection-3.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reflection-3.ts b/reflection-3.ts index f8e1f71..fde467f 100644 --- a/reflection-3.ts +++ b/reflection-3.ts @@ -221,6 +221,9 @@ export function detectPlanningLoop(messages: any[]): { writeCount: number totalTools: number } { + if (!Array.isArray(messages)) { + return { detected: false, readCount: 0, writeCount: 0, totalTools: 0 } + } let readCount = 0 let writeCount = 0 let totalTools = 0