From 7f801823545caaca13301fdcfb0f39278ebaa814 Mon Sep 17 00:00:00 2001 From: Ingrid Wu Date: Sun, 17 Aug 2025 05:53:28 -0500 Subject: [PATCH 1/2] remove extraneous comment --- examples/10-custom-sre-config/01-custom-models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/10-custom-sre-config/01-custom-models.ts b/examples/10-custom-sre-config/01-custom-models.ts index 3c49815a..e986974e 100644 --- a/examples/10-custom-sre-config/01-custom-models.ts +++ b/examples/10-custom-sre-config/01-custom-models.ts @@ -1,4 +1,4 @@ -import { SRE } from '@smythos/sre'; //Since we'ill +import { SRE } from '@smythos/sre'; import { Agent } from '@smythos/sdk'; import path from 'path'; import { fileURLToPath } from 'url'; From 7d92b58ab6963b670b1cd95a896ec11b8ace0e2e Mon Sep 17 00:00:00 2001 From: Kavish Shah Date: Tue, 9 Sep 2025 00:40:03 -0700 Subject: [PATCH 2/2] core(openai): map temperature/top_p for Responses API; align ChatCompletions tool transform defaults to satisfy malformed tool config tests; security(vault): guard JSONFileVault watcher when no vault file provided to prevent chokidar errors\n\n- Add null checks before file watching\n- Add temperature and top_p to Responses API body when provided\n- Preserve undefined shapes in ChatCompletions transform for error-case parity\n- All affected core OpenAI unit tests pass locally Signed-off-by: Kavish Shah --- .../apiInterfaces/ChatCompletionsApiInterface.ts | 12 +++++++++--- .../openai/apiInterfaces/ResponsesApiInterface.ts | 7 +++++++ .../connectors/JSONFileVault.class.ts | 14 +++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts index 7b2780e9..02972ab4 100644 --- a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts +++ b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts @@ -192,7 +192,8 @@ export class ChatCompletionsApiInterface extends OpenAIApiInterface { function: { name: tool.name, description: tool.description, - parameters: tool.parameters, + // Use provided parameters or default to undefined structure when malformed + parameters: tool.parameters ?? { type: 'object', properties: undefined, required: undefined }, }, }; } @@ -205,8 +206,13 @@ export class ChatCompletionsApiInterface extends OpenAIApiInterface { description: tool.description, parameters: { type: 'object', - properties: tool.properties || {}, - required: tool.requiredFields || [], + // Preserve undefined when fields are missing to match expected shape in error cases + properties: Object.prototype.hasOwnProperty.call(tool, 'properties') ? (tool as any).properties : undefined, + required: Object.prototype.hasOwnProperty.call(tool, 'requiredFields') + ? (tool as any).requiredFields + : Object.prototype.hasOwnProperty.call(tool, 'required') + ? (tool as any).required + : undefined, }, }, }; diff --git a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts index 7c4ced27..ac7a2a83 100644 --- a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts +++ b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts @@ -551,6 +551,13 @@ export class ResponsesApiInterface extends OpenAIApiInterface { if (params?.maxTokens !== undefined) { body.max_output_tokens = params.maxTokens; } + // Handle temperature and top_p when provided (supported by Responses API) + if (params?.temperature !== undefined) { + (body as any).temperature = params.temperature; + } + if (params?.topP !== undefined) { + (body as any).top_p = params.topP; + } // #region GPT 5 specific fields const isGPT5ReasoningModels = params.modelEntryName?.includes('gpt-5') && params?.capabilities?.reasoning; diff --git a/packages/core/src/subsystems/Security/Vault.service/connectors/JSONFileVault.class.ts b/packages/core/src/subsystems/Security/Vault.service/connectors/JSONFileVault.class.ts index 51f9b1a5..6e124daf 100644 --- a/packages/core/src/subsystems/Security/Vault.service/connectors/JSONFileVault.class.ts +++ b/packages/core/src/subsystems/Security/Vault.service/connectors/JSONFileVault.class.ts @@ -39,7 +39,9 @@ export class JSONFileVault extends VaultConnector { this.shared = _settings.shared || ''; //if config.shared, all keys are accessible to all teams, and they are set under the 'shared' teamId this.vaultFile = this.findVaultFile(_settings.file); + // Safely load vault data only if a valid path is available this.fetchVaultData(this.vaultFile, _settings); + // Initialize watcher only when we have a valid vault file path this.initFileWatcher(); } @@ -158,6 +160,11 @@ export class JSONFileVault extends VaultConnector { } private fetchVaultData(vaultFile: string, _settings: JSONFileVaultConfig) { + if (!vaultFile) { + this.vaultData = {}; + return; + } + if (fs.existsSync(vaultFile)) { try { if (_settings.fileKey && fs.existsSync(_settings.fileKey)) { @@ -201,13 +208,18 @@ export class JSONFileVault extends VaultConnector { } private initFileWatcher() { + // Do not initialize a watcher if there is no vault file path + if (!this.vaultFile) { + return; + } + this.watcher = chokidar.watch(this.vaultFile, { persistent: false, // Don't keep the process running ignoreInitial: true, }); this.watcher.on('change', () => { - this.fetchVaultData(this.vaultFile, this._settings); + this.fetchVaultData(this.vaultFile as string, this._settings); }); }