feat(smartagent): record native tool results in message history by adding optional toolName to continueWithNativeTools and passing tool identifier from DualAgent
This commit is contained in:
@@ -548,16 +548,29 @@ Your complete output here
|
||||
/**
|
||||
* Continue conversation with native tool calling support
|
||||
* @param message The message to continue with (e.g., tool result)
|
||||
* @param toolName Optional tool name - when provided, message is added as role: 'tool' instead of 'user'
|
||||
* @returns Response with content, reasoning, and any tool calls
|
||||
*/
|
||||
public async continueWithNativeTools(
|
||||
message: string
|
||||
message: string,
|
||||
toolName?: string
|
||||
): Promise<{ message: interfaces.IAgentMessage; toolCalls?: interfaces.INativeToolCall[] }> {
|
||||
// Add the new message to history
|
||||
this.messageHistory.push({
|
||||
role: 'user',
|
||||
content: message,
|
||||
});
|
||||
if (toolName) {
|
||||
// Tool result - must use role: 'tool' for native tool calling
|
||||
// The 'tool' role is supported by providers but not in the ChatMessage type
|
||||
this.messageHistory.push({
|
||||
role: 'tool',
|
||||
content: message,
|
||||
toolName: toolName,
|
||||
} as unknown as plugins.smartai.ChatMessage);
|
||||
} else {
|
||||
// Regular user message
|
||||
this.messageHistory.push({
|
||||
role: 'user',
|
||||
content: message,
|
||||
});
|
||||
}
|
||||
|
||||
// Build system message
|
||||
const fullSystemMessage = this.getNativeToolsSystemMessage();
|
||||
|
||||
Reference in New Issue
Block a user