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 /modules/core/module-aiassist.js | |
| parent | 3d66fbe2dde898f57cd368bc37257b63ef4752f1 (diff) | |
newOS4 v4.6.33: progress-based turn budget (D3)
Diffstat (limited to 'modules/core/module-aiassist.js')
| -rw-r--r-- | modules/core/module-aiassist.js | 22 |
1 files changed, 22 insertions, 0 deletions
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 }); } |