danny-avila/LibreChat · error · Error

Subagent ${agentId} failed model validation.

Error message

Subagent ${agentId} failed model validation.

What it means

Thrown during lazy subagent initialization when validateAgentModel returns invalid and provides no specific error message. It indicates the subagent's configured model is unavailable, disallowed, or otherwise rejected by model validation.

Source

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

   * child execution a durable runtime context.
   */
  const initializeLazySubagent = async ({ agentId, configId, context, lazyChildren }) => {
    throwIfAborted(context.signal);
    const agent = await waitForAbort(db.getAgentWithVersionCount({ id: agentId }), context.signal);
    throwIfAborted(context.signal);
    if (!agent || getLazySubagentConfigId(agent) !== configId) {
      throw new Error(`Subagent ${agentId} changed before it could be initialized.`);
    }
    if (!(await hasSubagentViewAccess(agent, agentId, context.signal))) {
      throw new Error(`You no longer have access to subagent ${agentId}.`);
    }
    const validation = await waitForAbort(
      validateAgentModel({ req, res, agent, modelsConfig, logViolation }),
      context.signal,
    );
    throwIfAborted(context.signal);
    if (!validation.isValid) {
      throw new Error(validation.error?.message ?? `Subagent ${agentId} failed model validation.`);
    }
    const scopedSkillIds = resolveAgentScopedSkillIds({
      agent,
      accessibleSkillIds,
      skillsCapabilityEnabled,
      ephemeralSkillsToggle,
    });
    const scopedEditableSkillIds = resolveAgentScopedSkillIds({
      agent,
      accessibleSkillIds: editableSkillIds,
      skillsCapabilityEnabled,
      ephemeralSkillsToggle,
    });
    const config = await waitForAbort(
      initializeAgent(
        {
          req,
          res,

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Update the subagent to use an allowed, currently-available model.
  2. Grant the user's role access to the required model.
  3. Restore/reenable the model in the models config if it was removed in error.
  4. Inspect validationResult.error.message when present for the precise reason.
Defensive patterns

Strategy: validation

Validate before calling

const result = await validateAgentModel({ req, res, agent, modelsConfig, logViolation });
if (!result.isValid) {
  throw new Error(result.error?.message ?? `Subagent ${agent.id} model not allowed`);
}

Type guard

function isModelAllowed(modelId, modelsConfig) {
  return Array.isArray(modelsConfig) ? modelsConfig.includes(modelId) : Boolean(modelsConfig?.[modelId]);
}

Try / catch

try { await initializeLazySubagent({ agentId, configId, context }); }
catch (e) { if (/failed model validation/.test(e.message)) return res.status(400).json({ error: 'Subagent model unavailable' }); throw e; }

Prevention

When it happens

Trigger: The subagent's model is not in the allowed models config, exceeds role limits, is deprecated, or fails the model Violation/logViolation check during initialization.

Common situations: A model was disabled or removed after the agent was configured; role-based model restrictions block the subagent's model; the model id is misspelled or from a different provider.

Related errors


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