aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/core/core-bundle.js22
-rw-r--r--modules/core/module-aiassist.js22
-rw-r--r--modules/core/module-loader.js2
3 files changed, 45 insertions, 1 deletions
diff --git a/modules/core/core-bundle.js b/modules/core/core-bundle.js
index 5bbc840..c4cbd8e 100644
--- a/modules/core/core-bundle.js
+++ b/modules/core/core-bundle.js
@@ -9388,6 +9388,27 @@ buildSystemPrompt() {
var profile = this._activeLoopProfile || {};
var loopCfg = profile.loop || {};
var maxTurns = loopCfg.maxTurns || this.MAX_TOOL_TURNS;
+ var baseTurns = maxTurns;
+ let _lastTurnSig = null, _progressStreak = 0, _stallStreak = 0;
+ const _logStart = (this._toolCallLog || []).length;
+ // D3: extend the budget only while turns keep producing NEW output.
+ const _noteProgress = (results) => {
+ try {
+ const arr = (results || []).map(r => (r && typeof r === 'object' && 'toolResult' in r) ? r.toolResult : r);
+ if (!arr.length) return;
+ const h = _sigHash(JSON.stringify(arr));
+ if (_lastTurnSig !== null && h !== _lastTurnSig) { _progressStreak++; _stallStreak = 0; }
+ else if (_lastTurnSig !== null) { _stallStreak++; _progressStreak = 0; }
+ _lastTurnSig = h;
+ if (_progressStreak >= 2 && maxTurns < baseTurns + 4) {
+ maxTurns += 2;
+ this.terminal.print(`📈 Progress detected — extending turn budget to ${maxTurns}`, 'info');
+ }
+ if (_stallStreak === 3) {
+ messages.push({ role: 'system', content: 'No new information in the last turns — stop calling tools and give your final answer now.' });
+ }
+ } catch (_e) {}
+ };
var loopDetect = loopCfg.loopDetection || { enabled: true, threshold: 6, windowMs: 30000 };
var confEsc = loopCfg.confidenceEscalation || { enabled: true, threshold: 90 };
var finalPrompt = loopCfg.finalTurnPrompt || 'This is your last tool turn. You MUST provide a final answer after this tool call. Synthesize what you know.';
@@ -9689,6 +9710,7 @@ buildSystemPrompt() {
}
}
}
+ _noteProgress(safeResults);
if (pendingText) {
messages.push({ role: 'assistant', content: pendingText });
}
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js
index a5c5022..5f20fbc 100644
--- a/modules/core/module-aiassist.js
+++ b/modules/core/module-aiassist.js
@@ -1365,6 +1365,27 @@ buildSystemPrompt() {
var profile = this._activeLoopProfile || {};
var loopCfg = profile.loop || {};
var maxTurns = loopCfg.maxTurns || this.MAX_TOOL_TURNS;
+ var baseTurns = maxTurns;
+ let _lastTurnSig = null, _progressStreak = 0, _stallStreak = 0;
+ const _logStart = (this._toolCallLog || []).length;
+ // D3: extend the budget only while turns keep producing NEW output.
+ const _noteProgress = (results) => {
+ try {
+ const arr = (results || []).map(r => (r && typeof r === 'object' && 'toolResult' in r) ? r.toolResult : r);
+ if (!arr.length) return;
+ const h = _sigHash(JSON.stringify(arr));
+ if (_lastTurnSig !== null && h !== _lastTurnSig) { _progressStreak++; _stallStreak = 0; }
+ else if (_lastTurnSig !== null) { _stallStreak++; _progressStreak = 0; }
+ _lastTurnSig = h;
+ if (_progressStreak >= 2 && maxTurns < baseTurns + 4) {
+ maxTurns += 2;
+ this.terminal.print(`📈 Progress detected — extending turn budget to ${maxTurns}`, 'info');
+ }
+ if (_stallStreak === 3) {
+ messages.push({ role: 'system', content: 'No new information in the last turns — stop calling tools and give your final answer now.' });
+ }
+ } catch (_e) {}
+ };
var loopDetect = loopCfg.loopDetection || { enabled: true, threshold: 6, windowMs: 30000 };
var confEsc = loopCfg.confidenceEscalation || { enabled: true, threshold: 90 };
var finalPrompt = loopCfg.finalTurnPrompt || 'This is your last tool turn. You MUST provide a final answer after this tool call. Synthesize what you know.';
@@ -1666,6 +1687,7 @@ buildSystemPrompt() {
}
}
}
+ _noteProgress(safeResults);
if (pendingText) {
messages.push({ role: 'assistant', content: pendingText });
}
diff --git a/modules/core/module-loader.js b/modules/core/module-loader.js
index c1571fc..fdfd393 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.31';
+ const LATEST_VER = 'v4.6.33';
const CACHE = '?v=' + LATEST_VER;
const stored = localStorage.getItem('webx11_cache_ver');
if (stored !== LATEST_VER) {