From 5427042d86f8e6a08a684a0315932c306472e7f8 Mon Sep 17 00:00:00 2001 From: Agando Date: Mon, 2 Nov 2026 20:55:56 +0100 Subject: perf(newos4): delegated agent runs no longer serialise; a waiter can't steal a lock Closes the second half of STEER-20261102-201045-ab08. - chat() gated the main-turn lock on nothing, so orchestrate-parallel's fan-out (each sub-task calling chat() on the same instance with its own agentTag) ran strictly one at a time. Measured 2x300ms delegated runs: 617ms before, 306ms now; the two 200ms user turns still take 400ms (main path stays serialised). - the 10s lock timeout called this._chatLock = false and printed "force released", which cleared a lock the waiter did not own - that released the main turn's lock while it was still running. A waiter now throws and the owner is the only writer. - delegated runs no longer clear the user's cancel flag on entry (an agent start used to reset this._cancelled, disarming a Stop the user had pressed). - tool-log entries carry the run they belong to and _recentToolLog(tag, n) is what feeds the run log line and _postRunReview, so concurrent runs no longer consume each other's entries. Known limit, unchanged: _currentTag is a single field, so under true concurrency an entry can be attributed to the wrong run (telemetry only - the answers are per-session). Namespacing it properly needs per-call state threading. Test: modules/test/test-chat-concurrency.js, 7 assertions, RED before (H1 617ms, H3 force-released, H5 no tags) and GREEN now; maintain 24/24. --- main.html | 6 +-- modules/core/core-bundle.js | 41 ++++++++++++----- modules/core/module-aiassist.js | 41 ++++++++++++----- modules/core/module-loader.js | 2 +- modules/test/test-chat-concurrency.js | 85 +++++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 24 deletions(-) create mode 100644 modules/test/test-chat-concurrency.js diff --git a/main.html b/main.html index 858a43f..743d261 100644 --- a/main.html +++ b/main.html @@ -1349,13 +1349,13 @@ - + - + - +