{"record":{"id":"6813b5d23f637c81","repo":"danny-avila/LibreChat","slug":"subagent-agentid-failed-model-validation","errorCode":null,"errorMessage":"Subagent ${agentId} failed model validation.","messagePattern":"Subagent (.+?) failed model validation\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"api/server/services/Endpoints/agents/initialize.js","lineNumber":847,"sourceCode":"   * child execution a durable runtime context.\n   */\n  const initializeLazySubagent = async ({ agentId, configId, context, lazyChildren }) => {\n    throwIfAborted(context.signal);\n    const agent = await waitForAbort(db.getAgentWithVersionCount({ id: agentId }), context.signal);\n    throwIfAborted(context.signal);\n    if (!agent || getLazySubagentConfigId(agent) !== configId) {\n      throw new Error(`Subagent ${agentId} changed before it could be initialized.`);\n    }\n    if (!(await hasSubagentViewAccess(agent, agentId, context.signal))) {\n      throw new Error(`You no longer have access to subagent ${agentId}.`);\n    }\n    const validation = await waitForAbort(\n      validateAgentModel({ req, res, agent, modelsConfig, logViolation }),\n      context.signal,\n    );\n    throwIfAborted(context.signal);\n    if (!validation.isValid) {\n      throw new Error(validation.error?.message ?? `Subagent ${agentId} failed model validation.`);\n    }\n    const scopedSkillIds = resolveAgentScopedSkillIds({\n      agent,\n      accessibleSkillIds,\n      skillsCapabilityEnabled,\n      ephemeralSkillsToggle,\n    });\n    const scopedEditableSkillIds = resolveAgentScopedSkillIds({\n      agent,\n      accessibleSkillIds: editableSkillIds,\n      skillsCapabilityEnabled,\n      ephemeralSkillsToggle,\n    });\n    const config = await waitForAbort(\n      initializeAgent(\n        {\n          req,\n          res,","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Endpoints/agents/initialize.js#L829-L865","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Update the subagent to use an allowed, currently-available model.","Grant the user's role access to the required model.","Restore/reenable the model in the models config if it was removed in error.","Inspect validationResult.error.message when present for the precise reason."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const result = await validateAgentModel({ req, res, agent, modelsConfig, logViolation });\nif (!result.isValid) {\n  throw new Error(result.error?.message ?? `Subagent ${agent.id} model not allowed`);\n}","typeGuard":"function isModelAllowed(modelId, modelsConfig) {\n  return Array.isArray(modelsConfig) ? modelsConfig.includes(modelId) : Boolean(modelsConfig?.[modelId]);\n}","tryCatchPattern":"try { await initializeLazySubagent({ agentId, configId, context }); }\ncatch (e) { if (/failed model validation/.test(e.message)) return res.status(400).json({ error: 'Subagent model unavailable' }); throw e; }","preventionTips":["Keep agent models within the role's allowed set.","Re-validate models when removing/disabling a model.","Default new subagents to a stable, widely-available model."],"tags":["agents","subagents","model-validation","configuration"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}