diff options
| author | Agando <roduccomm@gmail.com> | 2026-10-18 16:35:56 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-10-18 16:35:56 +0200 |
| commit | 1c5fbbb787fb20e24694a80e019c119a7e956bda (patch) | |
| tree | e4dc8f68871b509bf143e70883fb614d190011a4 | |
| parent | 3d66fbe2dde898f57cd368bc37257b63ef4752f1 (diff) | |
newOS4 v4.6.33: progress-based turn budget (D3)
| -rw-r--r-- | main.html | 6 | ||||
| -rw-r--r-- | modules/core/core-bundle.js | 22 | ||||
| -rw-r--r-- | modules/core/module-aiassist.js | 22 | ||||
| -rw-r--r-- | modules/core/module-loader.js | 2 |
4 files changed, 48 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.31"></script> +<script src="modules/core/core-bundle.js?v=v4.6.33"></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.31"></script> +<script src="modules/core/module-loader.js?v=v4.6.33"></script> <!-- Critical ext bundle loads AFTER webx11 exists so registerModule calls work --> -<script src="modules/ext/critical-ext-bundle.js?v=v4.6.31"></script> +<script src="modules/ext/critical-ext-bundle.js?v=v4.6.33"></script> <script> // ═══ ONE TRUE VERSION SOURCE ═══ 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) { |