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 | a35c22bbc33c2a0387a3ed61cc71869becb8d041 (patch) | |
| tree | 2d28c8e56037d486a73c1a045d6281b23c15c753 /modules/core | |
| parent | bf552344441d104cc2b366410ae42f93fe1cc782 (diff) | |
newOS4 v4.6.33: progress-based turn budget (D3)
Diffstat (limited to 'modules/core')
| -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 |
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) { |