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 | 3e1a1d27a15fbf0673ef327f39595339737848c1 (patch) | |
| tree | 559a4f909868707abf2316d06566cb6cbeb4c7b2 | |
| parent | 1c5fbbb787fb20e24694a80e019c119a7e956bda (diff) | |
newOS4 v4.6.34: running tool ledger in the prompt (D4)
| -rw-r--r-- | main.html | 6 | ||||
| -rw-r--r-- | modules/core/core-bundle.js | 16 | ||||
| -rw-r--r-- | modules/core/module-aiassist.js | 16 | ||||
| -rw-r--r-- | modules/core/module-loader.js | 2 |
4 files changed, 36 insertions, 4 deletions
@@ -1349,13 +1349,13 @@ </script> <!-- v4.5.63: A2A scratchpad fixes + agent-register arg fix --> -<script src="modules/core/core-bundle.js?v=v4.6.33"></script> +<script src="modules/core/core-bundle.js?v=v4.6.34"></script> <!-- Async dependency-ordered module loader now only initializes terminal and loads optional ext modules --> -<script src="modules/core/module-loader.js?v=v4.6.33"></script> +<script src="modules/core/module-loader.js?v=v4.6.34"></script> <!-- Critical ext bundle loads AFTER webx11 exists so registerModule calls work --> -<script src="modules/ext/critical-ext-bundle.js?v=v4.6.33"></script> +<script src="modules/ext/critical-ext-bundle.js?v=v4.6.34"></script> <script> // ═══ ONE TRUE VERSION SOURCE ═══ diff --git a/modules/core/core-bundle.js b/modules/core/core-bundle.js index c4cbd8e..d1793b2 100644 --- a/modules/core/core-bundle.js +++ b/modules/core/core-bundle.js @@ -9451,6 +9451,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'); 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'); diff --git a/modules/core/module-loader.js b/modules/core/module-loader.js index fdfd393..2bfc0ec 100644 --- a/modules/core/module-loader.js +++ b/modules/core/module-loader.js @@ -4,7 +4,7 @@ // Core module bundle loaded synchronously in main.html. // This loader only handles version cache-busting, splash, terminal init, and optional ext modules. - const LATEST_VER = 'v4.6.33'; + const LATEST_VER = 'v4.6.34'; const CACHE = '?v=' + LATEST_VER; const stored = localStorage.getItem('webx11_cache_ver'); if (stored !== LATEST_VER) { |