From 90246108646583fa2d40d7ec6165c72020ef55fb Mon Sep 17 00:00:00 2001 From: alaa-eddine Date: Thu, 18 Sep 2025 21:26:59 +0200 Subject: [PATCH] Hotfix : Agent Tools --- packages/core/package.json | 2 +- .../core/src/helpers/Conversation.helper.ts | 23 +++++++++++++------ packages/sdk/package.json | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 384de7c3..3ebaa115 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@smythos/sre", - "version": "1.5.68", + "version": "1.5.70", "description": "Smyth Runtime Environment", "author": "Alaa-eddine KADDOURI", "license": "MIT", diff --git a/packages/core/src/helpers/Conversation.helper.ts b/packages/core/src/helpers/Conversation.helper.ts index 308fc4d7..30d050da 100644 --- a/packages/core/src/helpers/Conversation.helper.ts +++ b/packages/core/src/helpers/Conversation.helper.ts @@ -281,8 +281,6 @@ export class Conversation extends EventEmitter { let _content = ''; const reqMethods = this._reqMethods; const toolsConfig = this._toolsConfig; - //deduplicate tools - toolsConfig.tools = toolsConfig.tools.filter((tool, index, self) => self.findIndex((t) => t.function.name === tool.function.name) === index); const endpoints = this._endpoints; const baseUrl = this._baseUrl; const message_id = 'msg_' + randomUUID(); @@ -832,15 +830,22 @@ export class Conversation extends EventEmitter { this._customToolsDeclarations.push(toolDefinition); this._customToolsHandlers[tool.name] = tool.handler; + //deduplicate tools + const llmInference: LLMInference = await LLMInference.getInstance(this.model, AccessCandidate.team(this._teamId)); + this._customToolsDeclarations = this._customToolsDeclarations.filter( + (tool, index, self) => self.findIndex((t) => t.name === tool.name) === index + ); const toolsConfig: any = llmInference.connector.formatToolsConfig({ type: 'function', - toolDefinitions: [toolDefinition], + toolDefinitions: this._customToolsDeclarations, toolChoice: this.toolChoice, }); - if (this._toolsConfig) this._toolsConfig.tools.push(...toolsConfig?.tools); - else this._toolsConfig = toolsConfig; + //if (this._toolsConfig) this._toolsConfig.tools.push(...toolsConfig?.tools); + //else this._toolsConfig = toolsConfig; + + this._toolsConfig = toolsConfig; } /** * updates LLM model, if spec is available, it will update the tools config @@ -857,15 +862,19 @@ export class Conversation extends EventEmitter { this._baseUrl = this._spec?.servers?.[0].url; const functionDeclarations = this.getFunctionDeclarations(this._spec); - functionDeclarations.push(...this._customToolsDeclarations); + //functionDeclarations.push(...this._customToolsDeclarations); + this._customToolsDeclarations.push(...functionDeclarations); const llmInference: LLMInference = await LLMInference.getInstance(this._model, AccessCandidate.team(this._teamId)); if (!llmInference.connector) { this.emit('error', 'No connector found for model: ' + this._model); return; } + this._customToolsDeclarations = this._customToolsDeclarations.filter( + (tool, index, self) => self.findIndex((t) => t.name === tool.name) === index + ); this._toolsConfig = llmInference.connector.formatToolsConfig({ type: 'function', - toolDefinitions: functionDeclarations, + toolDefinitions: this._customToolsDeclarations, toolChoice: this.toolChoice, }); diff --git a/packages/sdk/package.json b/packages/sdk/package.json index c78225a2..e2d37c24 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@smythos/sdk", - "version": "1.1.10", + "version": "1.1.11", "description": "SRE SDK", "keywords": [ "smythos",