From 0da85a5dcd306088ebf147cbf077727d7b9c90e7 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Tue, 20 Jan 2026 03:38:07 +0000 Subject: [PATCH] fix(driveragent): include full message history for tool results and use a continuation prompt when invoking provider.collectStreamResponse --- changelog.md | 7 +++++++ ts/00_commitinfo_data.ts | 2 +- ts/smartagent.classes.driveragent.ts | 13 +++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index b511ab4..cc1e5b6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2026-01-20 - 1.6.1 - fix(driveragent) +include full message history for tool results and use a continuation prompt when invoking provider.collectStreamResponse + +- When toolName is provided, include the full messageHistory (do not slice off the last message) so tool result messages are preserved. +- Set userMessage to a continuation prompt ('Continue with the task. The tool result has been provided above.') when handling tool results to avoid repeating the tool output. +- Keeps existing maxHistoryMessages trimming and validates provider.collectStreamResponse is available before streaming. + ## 2026-01-20 - 1.6.0 - feat(smartagent) record native tool results in message history by adding optional toolName to continueWithNativeTools and passing tool identifier from DualAgent diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index c36230d..f8c88d6 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartagent', - version: '1.6.0', + version: '1.6.1', description: 'an agentic framework built on top of @push.rocks/smartai' } diff --git a/ts/smartagent.classes.driveragent.ts b/ts/smartagent.classes.driveragent.ts index 75d4bac..f5168ea 100644 --- a/ts/smartagent.classes.driveragent.ts +++ b/ts/smartagent.classes.driveragent.ts @@ -579,8 +579,12 @@ Your complete output here const tools = this.getToolsAsJsonSchema(); // Get response from provider with history windowing + // For tool results, include the full history (with tool message) + // For regular user messages, exclude the last message (it becomes userMessage) let historyForChat: plugins.smartai.ChatMessage[]; - const fullHistory = this.messageHistory.slice(0, -1); + const fullHistory = toolName + ? this.messageHistory // Include tool result in history + : this.messageHistory.slice(0, -1); // Exclude last user message if (this.maxHistoryMessages > 0 && fullHistory.length > this.maxHistoryMessages) { historyForChat = [ @@ -597,11 +601,16 @@ Your complete output here throw new Error('Provider does not support native tool calling. Use continueWithMessage() instead.'); } + // For tool results, use a continuation prompt instead of repeating the result + const userMessage = toolName + ? 'Continue with the task. The tool result has been provided above.' + : message; + // Use collectStreamResponse for streaming support with tools const response = await provider.collectStreamResponse( { systemMessage: fullSystemMessage, - userMessage: message, + userMessage: userMessage, messageHistory: historyForChat, tools: tools.length > 0 ? tools : undefined, },