mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-05 15:50:19 +01:00
🧩 fix: Expand Toolkit Definitions to Include Child Tools in Event-Driven Mode (#12066)
* chore: Update logging format for tool execution handler to improve clarity * fix: Expand toolkit tools in loadToolDefinitions for event-driven mode The image_gen_oai toolkit contains both image_gen_oai and image_edit_oai tools, but the definitions-only path only returned image_gen_oai. This adds toolkit expansion so child tools are included in definitions, and resolves child tool names to their parent toolkit constructor at runtime. * chore: Remove toolkit flag from gemini_image_gen gemini_image_gen only has a single tool, so it is not a true toolkit. * refactor: Address review findings for toolkit expansion - Guard against duplicate constructor calls when parent and child tools are both in the tools array (Finding 2) - Consolidate image tool descriptions/schemas — registry now derives from toolkit objects (oaiToolkit, geminiToolkit) instead of duplicating them, so env var overrides are respected everywhere (Finding 5) - Move toolkitExpansion/toolkitParent to toolkits/mapping.ts with immutable types (Findings 6, 9) - Add tests for toolkit expansion, deduplication, and mapping invariants (Finding 1) - Fix log format to quote each tool individually (Finding 8) * fix: Correct toolkit constructor lookup to store under requested tool name The previous dedup guard stored the factory under toolKey (parent name) instead of tool (requested name), causing the promise loop to miss child tools like image_edit_oai. Now stores under both the parent key (for dedup) and the requested name (for lookup), with a memoized factory to ensure the constructor runs only once.
This commit is contained in:
parent
a0bcb44b8f
commit
490ad30427
8 changed files with 126 additions and 169 deletions
|
|
@ -7,6 +7,7 @@ const {
|
|||
} = require('@librechat/agents');
|
||||
const {
|
||||
checkAccess,
|
||||
toolkitParent,
|
||||
createSafeUser,
|
||||
mcpToolPattern,
|
||||
loadWebSearchAuth,
|
||||
|
|
@ -369,8 +370,16 @@ const loadTools = async ({
|
|||
continue;
|
||||
}
|
||||
|
||||
if (customConstructors[tool]) {
|
||||
requestedTools[tool] = async () => customConstructors[tool](toolContextMap);
|
||||
const toolKey = customConstructors[tool] ? tool : toolkitParent[tool];
|
||||
if (toolKey && customConstructors[toolKey]) {
|
||||
if (!requestedTools[toolKey]) {
|
||||
let cached;
|
||||
requestedTools[toolKey] = async () => {
|
||||
cached ??= customConstructors[toolKey](toolContextMap);
|
||||
return cached;
|
||||
};
|
||||
}
|
||||
requestedTools[tool] = requestedTools[toolKey];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue