LibreChat/api/server/controllers/agents
Danny Avila 74fa60cee1
🔎 fix: Enforce WEB_SEARCH Role Permission on Agents (#15875)
* 🔎 fix: Enforce WEB_SEARCH Role Permission on Agents

Squash of #15822 onto dev, preserving authorship:

- 🔎 fix: Enforce WEB_SEARCH Role Permission on Agents
- 🧪 test: Cover the Runtime Tool Loader's Web Search Gate
- 🔒 fix: Gate Web Search on the OpenAI-Compatible Embedder Surface
- 🩹 fix: Authorize Web Search by the Execution Context's User
- 📝 docs: Note the Grant Memo's One-Subject-Per-Request Assumption
- 🧹 fix: Deny Web Search Before an Endpoint Default Can Grant It
- 🙈 fix: Withhold the Web Search Model Parameter From a Denied Role
- 🧱 fix: Strip Provider-Native Search an Endpoint Re-Enables After Denial
- 🔌 fix: Close the OpenRouter Plugin Path and Stop Pruning Hidden Parameters

* 🧭 fix: Gate Provider-Native Web Search on the Built Config

The web search role gate ran before the provider builder and only when the
agent's stored `web_search` was not `false`, so an endpoint's `addParams`
re-enabled native search for a denied role, and every OpenAI-compatible and
Responses request read the role whether or not search was in play.

The gate now reads the builder's output: when it carries a native search tool
or OpenRouter's `web` plugin, the `WEB_SEARCH` grant is resolved and the search
stripped on denial. The routes that reach `initializeAgent` with `runtime` and
no `req` pass a lazy `resolveWebSearchGrant` that joins their request-memoized
grants, forwarded through agent discovery to handoffs and subagents. The
embedder surface wires it whenever `getRoleByName` is supplied, independent of
`appConfig`.

---------

Co-authored-by: TomasPalsson <tomas2212042710@gmail.com>
2026-09-12 23:00:10 -04:00
..
__tests__ 🔎 fix: Enforce WEB_SEARCH Role Permission on Agents (#15875) 2026-09-12 23:00:10 -04:00
callbacks.background.spec.js 🛂 feat: Filter Model-Bound Content by Source (#14425) 2026-08-21 22:43:32 -04:00
callbacks.js 🦘 feat: Share Run-Scoped Files With Subagents (#15848) 2026-09-12 20:14:22 -04:00
client.imageDetail.spec.js 🖍️ fix: Honor Agent Image Detail Settings (#15407) 2026-08-31 08:34:05 -04:00
client.js 🔎 fix: Enforce WEB_SEARCH Role Permission on Agents (#15875) 2026-09-12 23:00:10 -04:00
client.test.js 🖋️ feat: Seal Code Environment Choices Per Conversation (#15868) 2026-09-12 20:45:00 -04:00
errors.js 🧾 fix: Honor Disabled Transactions on the Assistants Usage Path (#15100) 2026-08-25 08:30:12 -04:00
filterAuthorizedTools.spec.js 🔗 fix: Resolve MCP Tool-Key Boundary Against Configured Server Names (#14448) 2026-07-27 14:45:38 -04:00
openai.js 🔎 fix: Enforce WEB_SEARCH Role Permission on Agents (#15875) 2026-09-12 23:00:10 -04:00
protocol.js 🛫 refactor: Promote Generation Protocol V2 Automatically (#15324) 2026-08-28 17:17:09 -04:00
queuedTurns.js 📬 feat: Move Agent Queued Turns Server-Side (#15370) 2026-08-30 21:53:58 -04:00
recordCollectedUsage.spec.js
request.js 🖋️ feat: Seal Code Environment Choices Per Conversation (#15868) 2026-09-12 20:45:00 -04:00
responses.js 🔎 fix: Enforce WEB_SEARCH Role Permission on Agents (#15875) 2026-09-12 23:00:10 -04:00
resume.js 🖋️ feat: Seal Code Environment Choices Per Conversation (#15868) 2026-09-12 20:45:00 -04:00
steer.js 📬 feat: Move Agent Queued Turns Server-Side (#15370) 2026-08-30 21:53:58 -04:00
v1.js 🏡 feat: Remember Agent Workspace Defaults (#15843) 2026-09-12 05:45:16 -04:00
v1.spec.js 🏡 feat: Remember Agent Workspace Defaults (#15843) 2026-09-12 05:45:16 -04:00