{"record":{"id":"b0fc2ef7ed8e1db4","repo":"danny-avila/LibreChat","slug":"subagent-run-configuration-exceeds-the-maximum-of","errorCode":null,"errorMessage":"Subagent run configuration exceeds the maximum of ${MAX_SUBAGENT_RUN_CONFIGS} expanded entries.","messagePattern":"Subagent run configuration exceeds the maximum of (.+?) expanded entries\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"api/server/services/Endpoints/agents/initialize.js","lineNumber":703,"sourceCode":"      });\n      throw new Error(\n        `Subagent graph exceeds the maximum of ${MAX_SUBAGENT_GRAPH_NODES} unique agents.`,\n      );\n    }\n  };\n\n  const countExpandedSubagentDescriptor = (agentId) => {\n    expandedSubagentDescriptorState.configCount += 1;\n    if (expandedSubagentDescriptorState.configCount <= MAX_SUBAGENT_RUN_CONFIGS) {\n      return;\n    }\n    logger.warn('[initializeClient] Subagent run configuration limit exceeded', {\n      agentId,\n      expandedConfigCount: expandedSubagentDescriptorState.configCount,\n      maxSubagentRunConfigs: MAX_SUBAGENT_RUN_CONFIGS,\n      rootAgentIds: expandedSubagentDescriptorState.rootAgentIds,\n    });\n    throw new Error(\n      `Subagent run configuration exceeds the maximum of ${MAX_SUBAGENT_RUN_CONFIGS} expanded entries.`,\n    );\n  };\n\n  const userId = req.user?.id;\n  const userRole = req.user?.role;\n\n  const throwIfAborted = (abortSignal) => {\n    if (!abortSignal?.aborted) return;\n    throw abortSignal.reason instanceof Error\n      ? abortSignal.reason\n      : new Error('Subagent resolution was aborted.');\n  };\n\n  const waitForAbort = (promise, abortSignal) => {\n    throwIfAborted(abortSignal);\n    if (!abortSignal) return promise;\n    return new Promise((resolve, reject) => {","sourceCodeStart":685,"sourceCodeEnd":721,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Endpoints/agents/initialize.js#L685-L721","documentation":"Thrown by countExpandedSubagentDescriptor when the number of expanded run-config entries for subagents exceeds MAX_SUBAGENT_RUN_CONFIGS. This bounds the total number of per-run subagent configurations expanded during initialization.","triggerScenarios":"Subagents carry many distinct run configurations (overrides per agent) such that the expanded descriptor count surpasses the cap; a single agent referenced with many config variants.","commonSituations":"Complex agent definitions with per-subagent runtime overrides; config generation logic producing more variants than expected; copying a template agent many times into a graph.","solutions":["Reduce the number of distinct run configurations attached to subagents.","Share a single config across equivalent subagents instead of per-agent overrides.","Raise MAX_SUBAGENT_RUN_CONFIGS only if the expanded set is genuinely required.","Audit generated configs for accidental duplication."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertRunConfigs(state, max) {\n  if (state.configCount > max) throw new Error(`Run-config cap (${max}) exceeded`);\n}","typeGuard":null,"tryCatchPattern":"try { await initializeClient(req, res, endpointOption); }\ncatch (e) { if (/Subagent run configuration exceeds/.test(e.message)) return res.status(400).json({ error: 'Too many subagent run configs' }); throw e; }","preventionTips":["Share run configs across equivalent subagents.","Surface the cap in the agent authoring UI.","Detect accidental config duplication at authoring time."],"tags":["agents","subagents","limits","configuration"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}