aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-aiassist.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-10-27 15:33:33 +0100
committerAgando <roduccomm@gmail.com>2026-10-27 15:33:33 +0100
commit240cbf75c7c3cbf23fc95d6b4e0bf807dcd91360 (patch)
tree3da9a2684b80b3af99441e602b0195e39f4ab300 /modules/core/module-aiassist.js
parent6b4049d3ba27dd68935c0565cccfe44752175393 (diff)
fix(newos4): agent registration is absolute-path and honest about what it stored
Three of the four agent-cluster items, each with a test that is red on HEAD. - MAINT-008 (module-agent-registry.js + module-orchestrator.js): registerAgent took args[0] as the agent id and only args[1] as the capability list, while both orchestrator callers passed the command word first — so the boot log read "Agent 'register' registered with 1 capabilities" and four capabilities were stored as one. The command word is now stripped, args[1..] are joined and split on commas (both "a,b" and "a b c" work), and the callers pass [id, ...caps]. - MAINT-007 (registry + aiassist): mkdir/rm used relative paths, so a registration made from /docs created /docs/agents/<id> and an unregister from any other cwd removed nothing — the leaked directories the report suspected. Every path in the registry (and the four /_sessions writes in module-aiassist.js) is absolute now. - MAINT-009 (listAgents): a directory alone counted as a registered agent, so a hand-made /agents/foo appeared as "foo — unknown (0 capabilities)". Only a readable status.json with an id counts now; the rest are reported as unregistered directories. Verification: test-agent-registry.js (11 asserts). RED on HEAD: 9 of 11 fail, including the exact `✅ Agent 'register' registered with 1 capabilities` line and `hand-made — unknown (0 capabilities)`. Suite 15/15 files green; maintain --fix "node tests 15/15 pass". Live on v4.6.109: boot prints "✅ Agent 'orchestrator-0' registered with 4 capabilities"; `agent-list` warns "1 directory(ies) in /agents have no status.json (not registered): hand-made"; register from / with a comma list stores 3; unregister from /docs removes the directory and leaves no /docs/agents. MAINT-006 stays open with a narrower note: the hard stop was only reachable when every call in a batch was blocked, so a mixed batch (one repeated + one novel call) never ended. The same ceiling now applies on the mixed path, but that branch lives inside agenticLoop and is not covered by a unit test — it needs a live agent run that repeats a call.
Diffstat (limited to 'modules/core/module-aiassist.js')
-rw-r--r--modules/core/module-aiassist.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js
index be5ebce..2ee95e9 100644
--- a/modules/core/module-aiassist.js
+++ b/modules/core/module-aiassist.js
@@ -1679,6 +1679,15 @@ buildSystemPrompt() {
// assistant message is pushed below.
res.tool_calls = _remaining;
this._pendingBlockedReplays = blocked;
+ // MAINT-006: the hard stop was only reachable when EVERY call in the
+ // batch was blocked, so a turn that mixed one repeated call with one
+ // novel call never ended — the reported "agents loop on repetitive
+ // turns". Apply the same ceiling on the mixed path.
+ const _hsMixed = Math.min(_hardStopAt, maxTurns);
+ if (blocked.some(b => b.entry.count >= _hsMixed)) {
+ this.terminal.print(`⛔ ${_agentTag}: no progress after ${_hsMixed} identical calls — ending loop with partial result`, 'error');
+ return { finalAnswer: this._loopSummary(toolTurns), toolTurns };
+ }
}
this.terminal.print(`🔧 AI wants ${res.tool_calls.length} tool(s) — turn ${toolTurns}/${maxTurns} (${thinkTime}s)`, 'info');
messages.push(res.message);
@@ -2700,7 +2709,7 @@ buildSystemPrompt() {
case 'session_terminal': {
const tfs = this.terminal.fs;
try {
- const raw = tfs.readFile('_sessions/_auto.json');
+ const raw = tfs.readFile('/_sessions/_auto.json');
if (!raw) return JSON.stringify({ error: 'No auto-saved session found' });
const data = JSON.parse(raw);
const lines = (data.terminalLines || []).slice(-50);
@@ -3674,7 +3683,7 @@ buildSystemPrompt() {
const fs = this.terminal.fs;
if (fs) {
fs.mkdirRecursive('_sessions');
- fs.writeFile('_sessions/_auto-context.json', data);
+ fs.writeFile('/_sessions/_auto-context.json', data);
}
} catch (e) {}
} catch (e) {
@@ -3800,8 +3809,8 @@ buildSystemPrompt() {
try {
const fs = this.terminal.fs;
if (fs) {
- fs.deleteFile('_sessions/_auto-context.json');
- fs.deleteFile('_sessions/_auto.json');
+ fs.deleteFile('/_sessions/_auto-context.json');
+ fs.deleteFile('/_sessions/_auto.json');
}
} catch (e) {}