LibreChat/api/server/controllers/agents
Danny Avila fb3b299de6
🪪 feat: Add Agent Identity to Provider and MCP Header Templates (#18113)
* feat: resolve executing agent ids in MCP header templates

* test: preserve MCP config source literal types

* 🪪 feat: Forward the Active Agent Id in Request Header Placeholders

A gateway in front of LibreChat sees the user, the conversation and the
message, but not which agent is running — so it cannot attribute spend per
agent, apply per-agent limits, or tell agent traffic from plain chat. Adds
`{{LIBRECHAT_AGENT_ID}}` as its own namespace beside the user / body / OpenID
ones, resolving wherever the existing request placeholders already work.

The value is the primary agent's, derived once per run, so subagent steps and
auxiliary calls (summarization, titles, activity labels, memory extraction)
forward the id of the turn they belong to rather than their own. Only
persisted agents resolve: ephemeral ids embed user-authored preset text that
is unsafe in a header value, so ephemeral runs and non-agent requests resolve
to an empty value rather than forwarding literal template text.

No behaviour change unless the placeholder is configured. The MCP surface
(#14303) is not covered — its connection classification derives from
`ALLOWED_BODY_FIELDS`, so a new namespace needs a follow-up.

(cherry picked from commit 8a3f1016f0)

* test: cover shared provider and MCP agent header resolution

* docs: clarify absent agent placeholder resolution

* fix: preserve agent header boundaries across transport lifecycles

* fix: retain Google header provenance during agent resolution

---------

Co-authored-by: Jiří Krejčí <51734696+krejcji@users.noreply.github.com>
2026-11-13 13:02:39 -05:00
..
__tests__ 🌄 fix: Show Skill Pills When a Turn Starts (#18036) 2026-11-11 12:49:50 -05:00
callbacks.background.spec.js 🛂 feat: Filter Model-Bound Content by Source (#14425) 2026-08-21 22:43:32 -04:00
callbacks.js 🦂 feat: Add GPT-6 Cyber Support (#18023) 2026-11-11 16:50:26 -05:00
client.codeDecision.spec.js 🍯 fix: Stop Approval Pauses From Unsealing Code Environments (#15963) 2026-09-15 12:30:37 -04:00
client.imageDetail.spec.js 🖍️ fix: Honor Agent Image Detail Settings (#15407) 2026-08-31 08:34:05 -04:00
client.js 🪪 feat: Add Agent Identity to Provider and MCP Header Templates (#18113) 2026-11-13 13:02:39 -05:00
client.test.js 🦣 fix: Honor Trace Policy in Memory Runs (#18006) 2026-11-10 10:35:59 -05:00
filterAuthorizedTools.spec.js fix: Guard Mongo Cleanup In Controller And Migration Tests (#17989) 2026-11-11 10:30:38 +01:00
openai.js 🚪 fix: Refuse Interactive MCP Sign-in on Remote Agent API Runs (#18058) 2026-11-11 20:56:17 -05:00
promotion.js 🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End (#18028) 2026-11-10 22:43:32 -05:00
protocol.js 🛫 refactor: Promote Generation Protocol V2 Automatically (#15324) 2026-08-28 17:17:09 -04:00
queuedTurns.js 🍱 fix: Carry Coding Approval Mode With Queued Turns (#16326) 2026-09-25 07:28:43 -04:00
recordCollectedUsage.spec.js 📬 feat: Persist Channel Events and Delivery Receipts (#17595) 2026-11-10 21:03:57 -08:00
request.js 🌄 fix: Show Skill Pills When a Turn Starts (#18036) 2026-11-11 12:49:50 -05:00
responses.js 🚪 fix: Refuse Interactive MCP Sign-in on Remote Agent API Runs (#18058) 2026-11-11 20:56:17 -05:00
resume.js 🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End (#18028) 2026-11-10 22:43:32 -05:00
steer.js 📬 feat: Move Agent Queued Turns Server-Side (#15370) 2026-08-30 21:53:58 -04:00
v1.js 🔐 fix: Authorize Restored MCP Tools Before Agent Revert Writes Them (#17843) 2026-11-09 07:20:31 -05:00
v1.spec.js fix: Guard Mongo Cleanup In Controller And Migration Tests (#17989) 2026-11-11 10:30:38 +01:00