diff options
| author | Agando <roduccomm@gmail.com> | 2026-10-18 16:39:58 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-10-18 16:39:58 +0200 |
| commit | 0c418485783eefc4c77dee985a5458b53b5b09d1 (patch) | |
| tree | 27e5b7fe01ed2f7d64c8d874d9b37d141ab66452 /modules/core/module-aiassist.js | |
| parent | a35c22bbc33c2a0387a3ed61cc71869becb8d041 (diff) | |
newOS4 v4.6.34: running tool ledger in the prompt (D4)
Diffstat (limited to 'modules/core/module-aiassist.js')
| -rw-r--r-- | modules/core/module-aiassist.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js index 5f20fbc..95a29a7 100644 --- a/modules/core/module-aiassist.js +++ b/modules/core/module-aiassist.js @@ -1428,6 +1428,22 @@ buildSystemPrompt() { while (toolTurns < maxTurns) { if (this._cancelled) { this.terminal.print('AI loop cancelled', 'warning'); return { finalAnswer: null, toolTurns }; } toolTurns++; + // D4: refresh the running tool ledger so the model never re-reads what it already has + if (toolTurns > 1) { + try { + for (let mi = messages.length - 1; mi >= 0; mi--) { + if (messages[mi] && messages[mi]._ledger) messages.splice(mi, 1); + } + const _led = (this._toolCallLog || []).slice(_logStart).slice(-8).map(e => + '- ' + e.name + '(' + String(typeof e.args === 'string' ? e.args : JSON.stringify(e.args || {})).slice(0, 60) + ') → ' + + (e.error ? 'ERROR' : this._summarizeObservation(e.result, 80)) + ).join('\n'); + if (_led) { + messages.push({ role: 'system', _ledger: true, + content: 'Tool ledger so far (do NOT repeat a call whose result you already have):\n' + _led }); + } + } catch (_e) {} + } // On last turn, inject wrap-up prompt if (toolTurns === maxTurns) { this.terminal.print(`⏱ Final turn (${toolTurns}/${maxTurns}) — AI must provide final answer`, 'warning'); |