aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-aiassist.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/module-aiassist.js')
-rw-r--r--modules/core/module-aiassist.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js
index 365bf94..417e1b6 100644
--- a/modules/core/module-aiassist.js
+++ b/modules/core/module-aiassist.js
@@ -1016,13 +1016,20 @@ max_chars: { type: 'integer', description: 'Max characters of page content to re
// Log the AI interaction
this.terminal.log('INFO', 'AI', 'Query: ' + userMessage.substring(0, 100));
if (loopResult && loopResult.toolTurns) {
- const toolNames = this._toolCallLog.slice(-(loopResult.toolTurns || 0)).map(function(e) { return e.name; }).join(', ');
+ // `recent` was referenced but never declared: the bare identifier threw
+ // ReferenceError inside this finally block, rejecting chat() on every
+ // tool-using turn (shipped in 32608bc, caught by the caller sweep).
+ const recent = this._toolCallLog.slice(-(loopResult.toolTurns || 0));
+ const toolNames = recent.map(function(e) { return e.name; }).join(', ');
this.terminal.log('INFO', 'AI', 'Used ' + loopResult.toolTurns + ' tool(s): ' + toolNames
+ ' · returned ' + Math.round(recent.reduce((a, e) => a + e.returnedBytes, 0) / 1024) + 'KB'
+ ' · clipped ' + Math.round(recent.reduce((a, e) => a + e.clippedBytes, 0) / 1024) + 'KB'
+ ' · ' + recent.filter(e => e.truncated).length + ' truncated');
}
}
+ // Callers (orchestrator delegateTask) need the answer itself, not just the
+ // side effects it left in the session context.
+ return { content: loopResult && loopResult.finalAnswer, toolTurns: (loopResult && loopResult.toolTurns) || 0 };
// Auto-archive every 10 messages
if (this._messageCount > 0 && this._messageCount % 10 === 0) {
this._archiveSession('Auto-archive at message ' + this._messageCount);