From d6eee520bc26631455135d1f2229d4013721e5b9 Mon Sep 17 00:00:00 2001 From: Agando Date: Mon, 2 Nov 2026 20:50:25 +0100 Subject: fix(newos4): chat() threw on every tool-using turn and never returned its answer Regression from 32608bc, caught by the .chat() caller sweep before it aged: - `recent` was referenced in chat()'s finally block but never declared, so any turn with toolTurns > 0 threw ReferenceError there and chat() REJECTED. delegateTask's catch turned that into "agent failed"; the 'completed' fallback was only ever reachable on tool-free turns. - chat() still had no return at all, so a tool-free turn resolved undefined and module-orchestrator.js:1250 fell through to `|| 'completed'`. Both fixed: `const recent` is now built from _toolCallLog, and chat() returns { content: finalAnswer, toolTurns } before the archive block (a return at the end of the method would let _archiveSession swallow the answer). Verified with /tmp/probe-chat-hotfix.js, 6/6: tool-using turn resolves {content:'WORKER ANSWER', toolTurns:2}, tool-free turn resolves the answer, the orchestrator's own projection returns the answer instead of 'completed', and _chatLock is released. Run against 32608bc the same probe says "recent is not defined" - i.e. it reproduces the shipped defect. Not included: the _chatLock serialisation (orchestrate-parallel still runs sub-tasks one at a time and the 10s force-release can clear the main turn's lock). That stays open in STEER-20261102-201045-ab08. --- main.html | 6 +++--- modules/core/core-bundle.js | 9 ++++++++- modules/core/module-aiassist.js | 9 ++++++++- modules/core/module-loader.js | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/main.html b/main.html index 5681c10..858a43f 100644 --- a/main.html +++ b/main.html @@ -1349,13 +1349,13 @@ - + - + - +