Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🧬 fix: Subagent MCP requestBody Propagation (bump `@librechat/agents to 3.1.78` + cleanup) (#12959)
Danny Avilaf839a447e136
diff --git a/api/package.json b/api/package.jsonindex fb1ef00966..3abdbc83e6 100644--- a/api/package.json+++ b/api/package.json@@ -45,7 +45,7 @@"@azure/storage-blob": "^12.30.0","@google/genai": "^1.19.0","@keyv/redis": "^4.3.3",- "@librechat/agents": "^3.1.78-dev.0",+ "@librechat/agents": "^3.1.78","@librechat/api": "*","@librechat/data-schemas": "*","@microsoft/microsoft-graph-client": "^3.0.7",diff --git a/api/server/services/ToolService.js b/api/server/services/ToolService.jsindex 747e2401bb..e15d802973 100644--- a/api/server/services/ToolService.js+++ b/api/server/services/ToolService.js@@ -12,7 +12,6 @@ const {const {sendEvent,getToolkitKey,- createSafeUser,getUserMCPAuthMap,loadToolDefinitions,GenerationJobManager,@@ -1253,35 +1252,7 @@ async function loadToolsForExecution({}) {const appConfig = req.config;const allLoadedTools = [];- /**- * Re-inject user identity into the configurable returned to the- * `ON_TOOL_EXECUTE` handler. The handler merges this onto whatever- * configurable arrived with the dispatched event:- * `{ ...configurable, ...toolConfigurable }`- * For the parent agent the outer stream config (set in AgentClient /- * Responses / OpenAI controllers) already carries `user` and `user_id`;- * re-injecting the same values from `req.user` is a no-op there.- *- * For SUBAGENT tool calls the SDK's `SubagentExecutor` invokes the child- * workflow with a fresh configurable of `{ thread_id }` only — the- * parent's `user`, `user_id`, and `userMCPAuthMap` are dropped on the way- * into the child graph. Without this re-injection, downstream MCP tools- * read `config.configurable.user?.id || user_id === undefined` and- * `MCPManager.getConnection` throws "No connection found for server X"- * (it can't fall through to the user-connection path without a userId).- *- * Only set the keys when `req.user.id` is present. Because- * `toolConfigurable` wins the merge, writing `user_id: undefined`- * unconditionally would clobber the outer config's `'api-user'`- * fallback (set by Responses/OpenAI controllers when `req.user` is- * absent). Omitting the keys lets the merge preserve whatever the- * outer configurable already had.- */const configurable = { userMCPAuthMap };- if (req.user?.id) {- configurable.user = createSafeUser(req.user);- configurable.user_id = req.user.id;- }if (actionsEnabled === undefined) {const enabledCapabilities = await resolveAgentCapabilities(req, appConfig, agent?.id);diff --git a/api/server/services/__tests__/ToolService.spec.js b/api/server/services/__tests__/ToolService.spec.jsindex 86f00f7562..63b2287684 100644--- a/api/server/services/__tests__/ToolService.spec.js+++ b/api/server/services/__tests__/ToolService.spec.js@@ -363,88 +363,6 @@ describe('ToolService - Action Capability Gating', () => {});});- describe('loadToolsForExecution — configurable user injection', () => {- /**- * Subagents invoked via `@librechat/agents`' SubagentExecutor receive- * a fresh `configurable` of `{ thread_id }` only — the parent's- * `user`/`user_id` are dropped on the way into the child workflow.- * The handler in `packages/api/src/agents/handlers.ts` merges- * `{ ...configurable, ...toolConfigurable }`, so the configurable- * returned here MUST carry the user identity for MCP connection- * lookup to succeed in subagent tool calls.- *- * Conversely, when `req.user` is absent (API-key path) we must NOT- * write `user`/`user_id` keys, otherwise the merge would clobber the- * outer config's `'api-user'` fallback set by Responses/OpenAI- * controllers.- */- it('returns configurable with user and user_id from req.user', async () => {- const req = createMockReq([]);- req.config = {};- req.user = { id: 'user_abc', email: '[email protected]', role: 'USER' };-- const result = await loadToolsForExecution({- req,- res: {},- agent: { id: 'agent_123' },- toolNames: [],- });-- expect(result.configurable.user_id).toBe('user_abc');- expect(result.configurable.user).toEqual(- expect.objectContaining({ id: 'user_abc', email: '[email protected]', role: 'USER' }),- );- });-- it('omits user keys when req.user is undefined so outer config fallback is preserved', async () => {- const req = createMockReq([]);- req.config = {};- req.user = undefined;-- const result = await loadToolsForExecution({- req,- res: {},- agent: { id: 'agent_123' },- toolNames: [],- });-- expect('user_id' in result.configurable).toBe(false);- expect('user' in result.configurable).toBe(false);- });-- it('omits user keys when req.user is null so outer config fallback is preserved', async () => {- const req = createMockReq([]);- req.config = {};- req.user = null;-- const result = await loadToolsForExecution({- req,- res: {},- agent: { id: 'agent_123' },- toolNames: [],- });-- expect('user_id' in result.configurable).toBe(false);- expect('user' in result.configurable).toBe(false);- });-- it('omits user keys when req.user is present but has no id', async () => {- const req = createMockReq([]);- req.config = {};- req.user = { email: '[email protected]' };-- const result = await loadToolsForExecution({- req,- res: {},- agent: { id: 'agent_123' },- toolNames: [],- });-- expect('user_id' in result.configurable).toBe(false);- expect('user' in result.configurable).toBe(false);- });- });-describe('checkCapability logic', () => {const createCheckCapability = (enabledCapabilities, logger = { warn: jest.fn() }) => {return (capability) => {diff --git a/package-lock.json b/package-lock.jsonindex 9280ec1208..2a0f598ada 100644--- a/package-lock.json+++ b/package-lock.json@@ -60,7 +60,7 @@"@azure/storage-blob": "^12.30.0","@google/genai": "^1.19.0","@keyv/redis": "^4.3.3",- "@librechat/agents": "^3.1.78-dev.0",+ "@librechat/agents": "^3.1.78","@librechat/api": "*","@librechat/data-schemas": "*","@microsoft/microsoft-graph-client": "^3.0.7",@@ -11988,9 +11988,9 @@}},"node_modules/@librechat/agents": {- "version": "3.1.78-dev.0",- "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.1.78-dev.0.tgz",- "integrity": "sha512-XOVS1pyBEV/HaBfmOasuT8wXceBhGzvk3gM5ba1iY+u4RS6HM53lRCvn1FX7vCBWv9anc/eV+m9G60tJbnZ/Sg==",+ "version": "3.1.78",+ "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.1.78.tgz",+ "integrity": "sha512-yrcWKYEU/UkZfueRbesYWjv5wqUUVxspAcwxOT/k8rWOCd9VrgXym2qnx3nQTGnwO67Uy5osvErjRXPMbqDEdg==","license": "MIT","dependencies": {"@anthropic-ai/sdk": "^0.92.0",@@ -44446,7 +44446,7 @@"@azure/storage-blob": "^12.30.0","@google/genai": "^1.19.0","@keyv/redis": "^4.3.3",- "@librechat/agents": "^3.1.78-dev.0",+ "@librechat/agents": "^3.1.78","@librechat/data-schemas": "*","@modelcontextprotocol/sdk": "^1.29.0","@smithy/node-http-handler": "^4.4.5",diff --git a/packages/api/package.json b/packages/api/package.jsonindex fe836a9862..fffc3e5d4f 100644--- a/packages/api/package.json+++ b/packages/api/package.json@@ -98,7 +98,7 @@"@azure/storage-blob": "^12.30.0","@google/genai": "^1.19.0","@keyv/redis": "^4.3.3",- "@librechat/agents": "^3.1.78-dev.0",+ "@librechat/agents": "^3.1.78","@librechat/data-schemas": "*","@modelcontextprotocol/sdk": "^1.29.0","@smithy/node-http-handler": "^4.4.5",