danny-avila/LibreChat · error · Error
You no longer have access to subagent ${agentId}.
Error message
You no longer have access to subagent ${agentId}. What it means
Thrown during lazy subagent initialization when hasSubagentViewAccess returns false. The user had access when the graph was planned but lost it before the subagent was initialized (permission/role/ACL change mid-request).
Source
Thrown at api/server/services/Endpoints/agents/initialize.js:839
return null;
}
};
/**
* Resolves the selected descriptor inside the foreground request. The
* legacy initializer requires request/response objects for tool and MCP
* setup, so this intentionally remains request-scoped until AI-1597 gives
* 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,View on GitHub (pinned to 5ff282f900)
Solutions
- Verify the user still has view access to the subagent and re-initiate if restored.
- Avoid revoking access to agents that have in-flight requests.
- Adjust the subagent graph to only reference agents the user durably can access.
- Surface the access loss to the end user with a re-auth/re-request prompt.
Defensive patterns
Strategy: try-catch
Validate before calling
if (!(await hasSubagentViewAccess(agent, agentId, signal))) {
throw new Error(`Access to subagent ${agentId} revoked`);
} Try / catch
try { await initializeLazySubagent({ agentId, configId, context }); }
catch (e) { if (/no longer have access/.test(e.message)) return res.status(403).json({ error: 'Access revoked' }); throw e; } Prevention
- Avoid revoking access to agents with in-flight requests.
- Restrict graphs to agents the user durably owns/can view.
- Re-check access early and surface revocation clearly to the user.
When it happens
Trigger: A permission or role change revokes the user's access to the subagent between graph planning and lazy initialization; the subagent was moved to a scope the user cannot view.
Common situations: An admin revoked a role or project membership during an in-flight request; the agent's access scope was tightened; sharing revoked concurrently.
Related errors
- Subagent ${agentId} changed before it could be initialized.
- Subagent graph exceeds the maximum of ${MAX_SUBAGENT_GRAPH_N
- Subagent run configuration exceeds the maximum of ${MAX_SUBA
- Subagent ${agentId} failed model validation.
- Subagent graph exceeds the maximum depth of ${MAX_SUBAGENT_D
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/a6ef248287d784fc.
Report an issue: GitHub.