diff --git a/changelog.md b/changelog.md index e96c502..b511ab4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 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 + +- continueWithNativeTools(message, toolName?) now accepts an optional toolName; when provided the message is stored with role 'tool' and includes a toolName property (cast to ChatMessage) +- DualAgent constructs a toolNameForHistory as `${proposal.toolName}_${proposal.action}` and forwards it to continueWithNativeTools in both normal and error flows +- Preserves tool-origin information in the conversation history to support native tool calling and tracking + ## 2026-01-20 - 1.5.4 - fix(driveragent) prevent duplicate thinking/output markers during token streaming and mark transitions diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 5adf1a9..c36230d 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.5.4', + version: '1.6.0', 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 08e48b9..75d4bac 100644 --- a/ts/smartagent.classes.driveragent.ts +++ b/ts/smartagent.classes.driveragent.ts @@ -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(); diff --git a/ts/smartagent.classes.dualagent.ts b/ts/smartagent.classes.dualagent.ts index 7a19020..65321f5 100644 --- a/ts/smartagent.classes.dualagent.ts +++ b/ts/smartagent.classes.dualagent.ts @@ -495,7 +495,8 @@ Please output the exact XML format above.` // Continue with appropriate method based on mode if (useNativeTools) { - const continueResult = await this.driver.continueWithNativeTools(resultMessage); + const toolNameForHistory = `${proposal.toolName}_${proposal.action}`; + const continueResult = await this.driver.continueWithNativeTools(resultMessage, toolNameForHistory); driverResponse = continueResult.message; pendingNativeToolCalls = continueResult.toolCalls; } else { @@ -505,8 +506,10 @@ Please output the exact XML format above.` } catch (error) { const errorMessage = `Tool execution failed: ${error instanceof Error ? error.message : String(error)}`; if (useNativeTools) { + const toolNameForHistory = `${proposal.toolName}_${proposal.action}`; const continueResult = await this.driver.continueWithNativeTools( - `TOOL ERROR: ${errorMessage}\n\nPlease try a different approach.` + `TOOL ERROR: ${errorMessage}\n\nPlease try a different approach.`, + toolNameForHistory ); driverResponse = continueResult.message; pendingNativeToolCalls = continueResult.toolCalls;