fix(driveragent): include full message history for tool results and use a continuation prompt when invoking provider.collectStreamResponse
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user