🛠️ fix: Missing Tool Definitions on Redis Cache Clear (#9681)

This commit is contained in:
Danny Avila 2025-09-17 23:19:28 -04:00 committed by GitHub
parent 4499494aba
commit 02bfe32905
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 125 additions and 2 deletions

View file

@ -99,6 +99,12 @@ const getAvailableTools = async (req, res) => {
let toolDefinitions = await getCachedTools({ includeGlobal: true });
let prelimCachedTools;
if (toolDefinitions == null && appConfig?.availableTools != null) {
logger.warn('[getAvailableTools] Tool cache was empty, re-initializing from app config');
await setCachedTools(appConfig.availableTools, { isGlobal: true });
toolDefinitions = appConfig.availableTools;
}
/** @type {import('@librechat/api').LCManifestTool[]} */
let pluginManifest = availableTools;
@ -142,10 +148,10 @@ const getAvailableTools = async (req, res) => {
/** Filter plugins based on availability and add MCP-specific auth config */
const toolsOutput = [];
for (const plugin of authenticatedPlugins) {
const isToolDefined = toolDefinitions[plugin.pluginKey] !== undefined;
const isToolDefined = toolDefinitions?.[plugin.pluginKey] !== undefined;
const isToolkit =
plugin.toolkit === true &&
Object.keys(toolDefinitions).some(
Object.keys(toolDefinitions ?? {}).some(
(key) => getToolkitKey({ toolkits, toolName: key }) === plugin.pluginKey,
);