danny-avila/LibreChat · warning · Error

Subagent run configuration exceeds the maximum of ${MAX_SUBA

Error message

Subagent run configuration exceeds the maximum of ${MAX_SUBAGENT_RUN_CONFIGS} expanded entries.

What it means

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.

Source

Thrown at api/server/services/Endpoints/agents/initialize.js:703

      });
      throw new Error(
        `Subagent graph exceeds the maximum of ${MAX_SUBAGENT_GRAPH_NODES} unique agents.`,
      );
    }
  };

  const countExpandedSubagentDescriptor = (agentId) => {
    expandedSubagentDescriptorState.configCount += 1;
    if (expandedSubagentDescriptorState.configCount <= MAX_SUBAGENT_RUN_CONFIGS) {
      return;
    }
    logger.warn('[initializeClient] Subagent run configuration limit exceeded', {
      agentId,
      expandedConfigCount: expandedSubagentDescriptorState.configCount,
      maxSubagentRunConfigs: MAX_SUBAGENT_RUN_CONFIGS,
      rootAgentIds: expandedSubagentDescriptorState.rootAgentIds,
    });
    throw new Error(
      `Subagent run configuration exceeds the maximum of ${MAX_SUBAGENT_RUN_CONFIGS} expanded entries.`,
    );
  };

  const userId = req.user?.id;
  const userRole = req.user?.role;

  const throwIfAborted = (abortSignal) => {
    if (!abortSignal?.aborted) return;
    throw abortSignal.reason instanceof Error
      ? abortSignal.reason
      : new Error('Subagent resolution was aborted.');
  };

  const waitForAbort = (promise, abortSignal) => {
    throwIfAborted(abortSignal);
    if (!abortSignal) return promise;
    return new Promise((resolve, reject) => {

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Reduce the number of distinct run configurations attached to subagents.
  2. Share a single config across equivalent subagents instead of per-agent overrides.
  3. Raise MAX_SUBAGENT_RUN_CONFIGS only if the expanded set is genuinely required.
  4. Audit generated configs for accidental duplication.
Defensive patterns

Strategy: validation

Validate before calling

function assertRunConfigs(state, max) {
  if (state.configCount > max) throw new Error(`Run-config cap (${max}) exceeded`);
}

Try / catch

try { await initializeClient(req, res, endpointOption); }
catch (e) { if (/Subagent run configuration exceeds/.test(e.message)) return res.status(400).json({ error: 'Too many subagent run configs' }); throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/b0fc2ef7ed8e1db4. Report an issue: GitHub.