aboutsummaryrefslogtreecommitdiff
path: root/modules/core
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-10-18 16:39:58 +0200
committerAgando <roduccomm@gmail.com>2026-10-18 16:39:58 +0200
commit0c418485783eefc4c77dee985a5458b53b5b09d1 (patch)
tree27e5b7fe01ed2f7d64c8d874d9b37d141ab66452 /modules/core
parenta35c22bbc33c2a0387a3ed61cc71869becb8d041 (diff)
newOS4 v4.6.34: running tool ledger in the prompt (D4)
Diffstat (limited to 'modules/core')
-rw-r--r--modules/core/core-bundle.js16
-rw-r--r--modules/core/module-aiassist.js16
-rw-r--r--modules/core/module-loader.js2
3 files changed, 33 insertions, 1 deletions
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) {