diff options
Diffstat (limited to 'modules/core/module-aiassist.js')
| -rw-r--r-- | modules/core/module-aiassist.js | 17 |
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) {} |