🔌 fix: Treat a Locked Empty MCP List as Governing an Added Pane's Tools

This commit is contained in:
Danny Avila 2026-11-09 08:46:13 -05:00
parent 951d1e7b76
commit debbe28fe7
2 changed files with 18 additions and 2 deletions

View file

@ -1602,6 +1602,20 @@ describe('loadAgent', () => {
},
);
test("an added spec that locks MCP to none drops the primary pane's servers", async () => {
const { EPHEMERAL_AGENT_ID: EID } = Constants;
const result = await loadAddedAgent(
{
req: addedReq({ mcp: ['crm'] }, { lockTools: true, mcpServers: [] }),
conversation: addedConversation,
primaryAgent: { id: EID as string, tools: ['lookup_mcp_crm'] } as LibreChatAgent,
},
deps,
);
expect(result?.tools).not.toContain('lookup_mcp_crm');
});
test('an added spec that locks its tools but configures none still mirrors', async () => {
const { EPHEMERAL_AGENT_ID: EID } = Constants;
const result = await loadAddedAgent(

View file

@ -168,8 +168,9 @@ export async function loadAddedAgent(
/** The primary's resolved tools stand in for this pane's, since one badge row
* drives both — unless this pane's own spec differs and governs tools the
* primary's resolution never saw: tool toggles it withholds, MCP servers it
* pins, or `askUserQuestion`, which has no badge to carry it. Withheld
* primary's resolution never saw: tool toggles it withholds (an empty locked
* MCP list included), MCP servers it pins, or `askUserQuestion`, which has no
* badge to carry it. Withheld
* non-tool settings (artifacts, skills, background, intent) are resolved by
* the mirrored branch itself. Only the full resolution below applies those. */
const primaryIsEphemeral = primaryAgent && isEphemeralAgentId(primaryAgent.id);
@ -177,6 +178,7 @@ export async function loadAddedAgent(
const governsOwnTools =
(spec || '') !== (req.body?.spec || '') &&
((modelSpec?.mcpServers?.length ?? 0) > 0 ||
withheldToggles.has('mcp') ||
modelSpec?.askUserQuestion != null ||
SPEC_TOOL_TOGGLES.some(([toggleField]) => withheldToggles.has(toggleField)));
if (primaryIsEphemeral && !governsOwnTools && Array.isArray(primaryAgent.tools)) {