Repository navigation
🧳 feat: Choose Agent-Allowed Machines For New Chats - #16651
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review Please review the current PR head 6b8baea. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. Both native machine-choice and saved-chat transition canaries now pass, and the generated OpenAPI contract matches the new agent field. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Graph selection, inaccessible-route handling and picker consistency still have unresolved functional issues.
Review effort: Balanced
Findings: 6
Open (6)
Editing child workspace removes the primary machine selection · New Strict resolution hides environments needed for draft recovery · New Unresolved attached defaults incorrectly pass completeness checks · New Workspace menu omits choices for child coding agents · New Missing-default detection exposes choices ignored by server routing · New Unauthorized selected machines are silently treated as missing · New
What changed in this PR
Adds opt-in, per-chat machine selection for coding agents, using authorized attached machines while preserving agent defaults and existing conversation decisions.
Changes:
- Persist and restore agent machine allowlists.
- Add builder checkboxes and lazy machine/workspace selection.
- Route execution through the selected machine and extend regression coverage and native acceptance checks.
| File | Description |
|---|---|
| packages/data-schemas/src/types/agent.ts | Adds persisted allowlist type. |
| packages/data-schemas/src/schema/agentWorkspace.spec.ts | Tests allowlist persistence. |
| packages/data-schemas/src/schema/agent.ts | Stores machine allowlists. |
| packages/data-schemas/src/methods/agent.ts | Projects and restores allowlists. |
| packages/data-schemas/src/methods/agent.spec.ts | Tests version restoration. |
| packages/data-provider/src/types/agents.ts | Extends shared agent contracts. |
| packages/data-provider/src/types.ts | Exposes deployment opt-in. |
| packages/data-provider/src/schemas.ts | Initializes builder allowlists. |
| packages/data-provider/src/config.ts | Defines configuration toggle. |
| packages/data-provider/src/code/workspace.ts | Resolves permitted machine choices. |
| packages/data-provider/src/code/selection.spec.ts | Tests selection validation. |
| packages/api/src/endpoints/config/endpoints.ts | Advertises enabled selection. |
| packages/api/src/endpoints/config/endpoints.spec.ts | Tests opt-in advertisement. |
| packages/api/src/code/errors.ts | Centralizes workspace selection errors. |
| packages/api/src/code/capabilities.ts | Preserves error exports after relocation. |
| packages/api/src/agents/validation.ts | Validates machine allowlists. |
| packages/api/src/agents/validation.spec.ts | Tests allowlist inputs. |
| packages/api/src/agents/management.ts | Returns allowlists in management responses. |
| packages/api/src/agents/management.spec.ts | Tests management round-trips. |
| packages/api/src/agents/lazySubagents.ts | Preserves lazy-subagent allowlists. |
| packages/api/src/agents/initialize.ts | Passes conversation machine choices. |
| packages/api/src/agents/execution.ts | Resolves selected execution routes. |
| packages/api/src/agents/execution.spec.ts | Tests routing, policy and isolation. |
| packages/api/src/agents/__tests__/initialize.test.ts | Tests restored-machine initialization. |
| librechat.example.yaml | Documents deployment opt-in. |
| e2e/byom/run.mjs | Enables disposable selection fixtures. |
| e2e/byom/README.md | Documents acceptance scope and rollout. |
| e2e/byom/native.spec.ts | Exercises independent machine choices. |
| client/src/locales/en/translation.json | Adds machine-selection labels. |
| client/src/hooks/Agents/useCodeWorkspace.ts | Discovers choices and validates submissions. |
| client/src/hooks/Agents/useCodeApprovalMode.ts | Uses selected-machine approval policy. |
| client/src/hooks/Agents/__tests__/useCodeWorkspace.test.tsx | Tests choices and restored selections. |
| client/src/hooks/Agents/__tests__/useCodeApprovalMode.test.ts | Tests machine-specific permissions. |
| client/src/components/SidePanel/Agents/Code/Settings.tsx | Adds allowed-machine checkboxes. |
| client/src/components/SidePanel/Agents/AgentSelect.tsx | Loads allowlists into the builder. |
| client/src/components/SidePanel/Agents/AgentPanel.tsx | Includes allowlists in updates. |
| client/src/components/SidePanel/Agents/__tests__/CodeSettings.spec.tsx | Tests builder selection controls. |
| client/src/components/Chat/Input/CodeWorkspaceMenu.tsx | Adds lazy machine/workspace picking. |
| client/src/components/Chat/Input/__tests__/CodeWorkspaceMenu.spec.tsx | Tests discovery, selection and retry. |
| client/src/common/agents-types.ts | Extends builder form types. |
| api/server/services/ToolService.js | Forwards selection context to routing. |
| api/server/services/Endpoints/agents/initialize.js | Forwards choices during initialization. |
| api/app/clients/tools/util/handleTools.js | Forwards choices during tool loading. |
| .github/workflows/workspace-acceptance.yml | Runs both native acceptance variants. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b8baeaecf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Please review the current PR head 9ff3580. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. Graph machine-choice composition, revoked-route recovery, fail-closed subagent loading and additional-machine reference lifecycle now have transition coverage. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ff35809e2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Please review the current PR head 6b99e96. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. I audited the shared routing, graph discovery versus admission, principal-scoped machine authorization, persisted/request precedence, lifecycle reference bounds and saved-chat recovery as a subsystem. The five previous findings are fixed together, with transition and controller-level coverage. The composer now visibly names which agent and machine still need a workspace. Both local native-worker browser canaries, focused tests, all four workspace typechecks, OpenAPI checks and Lighthouse passed. |
|
@codex review Please review the current PR head 7e5dd58. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. The only change since 6b99e96 is direct data-provider regression coverage: preserve a selected default alongside a graph-required alternative, but reject multiple non-default matches. All 61 provider suites (2510 tests) and its typecheck pass locally. The routing, authorization, recovery and visible graph-requirement changes remain as previously described. |
|
@codex review Please review the current PR head 094ad52. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. This final test-only change removes an unused queued action mock from the unauthorized-duplicate regression. The request correctly rejects before loading actions; the unused mock leaked into subsequent content-filter tests because clearAllMocks preserves queued responses. The complete controller suite now passes all 154 tests. Production code is unchanged from 6b99e96. All provider suites, native-worker canaries, workspace typechecks, static checks, OpenAPI and Lighthouse also pass locally. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 094ad52ab3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Please review the current PR head 9e2d746. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. I traced graph ownership across choice, authorization, execution, persisted decisions, retry equality, saved-chat transitions and serialization. Explicit agentIds now distinguish Lia on B from a fixed reviewer on A; canonical seals include ownership. Inaccessible saved allowlists can be removed or omitted on unrelated edits. The composer states that every coding agent, including subagents, needs a workspace and identifies the missing agent and machine. Provider, API, controller, client and real-Mongo tests, all four workspace typechecks, native two-worker graph canary, saved-chat transition canary, OpenAPI, lint and Lighthouse passed locally. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e2d746f2a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review Please review the current PR head 9b7ea9d. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. The only changes since the clean review at 0a3a5d2 are in the native acceptance harness and its workflow: wait for /readyz before browser startup, and retry only an explicit 503 SERVER_NOT_READY generation-status snapshot within the existing bounded poll. Authorization failures, unrelated 503s and non-JSON errors still fail. Nine harness unit tests and the real saved-chat transition canary pass locally. Application code is unchanged. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |

Summary
I added an explicit per-agent list of attached machines that new chats may choose from. Today a coding agent is fixed to one machine, so using the same agent on an application VM and a runtime VM requires changing its default or creating a duplicate agent. With this opt-in, each new chat chooses its own allowed machine and workspace without modifying the agent's default or moving an existing chat.
code_environment_ids, with the existingcode_environment_idimplicitly allowed and retained as the default.maxEnvironmentChoiceswith a default of 32 and a ceiling of 128.How it works
The deployment gate is
endpoints.agents.statefulCodeSessions.allowEnvironmentSelection: true. Enable it only after all API replicas support this change and advertise environment-decision protocol 1 (CODE_ENVIRONMENT_DECISION_VERSION=1), then refresh clients. In the agent builder, retain the original default machine and check the additional machine(s) this agent may use. No Code API or worker update is required specifically for this feature.The allowlist is not an access grant. An explicit choice includes
agentIds, so Lia can select B while a fixed reviewer stays on A. Ownership is bounded, included in the decision seal and preserved through reload, retry and workspace recovery; one agent cannot own two machine choices. Legacy selections without ownership prefer the selected default, then require exactly one allowed target. Fixed-machine graph requirements survive alternative picks. Update every API replica before enabling the gate and refresh clients, because older strict validators reject ownership-bearing selections rather than silently rerouting them. This PR does not add arbitrary machine switching to sealed chats or change their existing transition policy.Type of change
Testing
Tested environments/configuration: macOS, Node 24.16.0, Chrome, isolated memory MongoDB and Redis, a real local Code API and two paired native SRT workers. Only model inference is deterministic; the browser, authorization, approval and worker execution paths are real. No production workers, credentials or databases were used.
Automated tests:
npx tsc --noEmitin data-provider, data-schemas, API and client./readyz, and transient terminal-settlement snapshots retry without hiding authorization or gateway failures.Not certified by the local canary: fleet load limits, Linux/WSL native execution, live-provider inference or production deployment behavior. Remote CI status is tracked separately from these local results.
Screenshots / recordings
Actual isolated running apps, same 1280 × 900 viewport. The agent named Lia is a disposable test fixture. Before is the base client; after expands an explicitly permitted second machine in a new chat. Screenshots are uploaded as attachments, not committed.
Machine-selection recording: https://github.com/user-attachments/assets/c94bdd18-9e7a-4dcb-9385-4f4bfcd54554
Checklist