🛤️ feat: Route Linked Worktree Requests into Per-Worktree Lanes - #16477
Conversation
Workers that advertise the git_linked_worktree workspace scope run each .worktrees/<name> of a registered checkout in its own scheduling lane. Accept the scope in worker status, map worktree-scoped paths and command working directories onto the worktree field, and restore the prefix on returned paths so tool output stays relative to the checkout.
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0914b6df9f
ℹ️ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c2d2c20d5
ℹ️ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 265cb5d6f5
ℹ️ 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. 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". |
…eChat-AI#16477) * feat: Route Linked Worktree Requests into Per-Worktree Lanes Workers that advertise the git_linked_worktree workspace scope run each .worktrees/<name> of a registered checkout in its own scheduling lane. Accept the scope in worker status, map worktree-scoped paths and command working directories onto the worktree field, and restore the prefix on returned paths so tool output stays relative to the checkout. * fix: Advertise Worktree cwd Routing in Model-Facing Bash Definitions * refactor: Normalize the Lane Flag in TypeScript, Pass It Through /api Unchanged * feat: Gate Linked Worktree Lanes Behind an Environment configSchema Toggle * test: Give the Lane Toggle Fixture a Default Environment
Summary
Agents that work in one registered checkout and give each task its own linked worktree (
.worktrees/<task>) currently run their workspace calls one at a time, even when the paired worker has several free lease slots. Code API schedules workspace tools per registered root, so every read, write, search and command anywhere under a repository's.worktrees/*shares a single lane, and parallel chats working on different branches of the same repository queue behind each other.LibreChat-AI/code-interpreter#270 adds linked-worktree lanes: a worker started with
--linked-worktree-lanesadvertises thegit_linked_worktreeworkspace scope and accepts aworktree: <name>field that runs the request confined to<root>/.worktrees/<name>, scheduled beside its sibling worktrees instead of behind them. This PR is the LibreChat side. When the selected workspace advertises that scope, requests whose target sits inside.worktrees/<name>/are sent to that worktree's lane, and every path in the result is returned with the.worktrees/<name>/prefix restored, so the model keeps seeing checkout-relative paths.Routing is opt-in per attached environment with
configSchema.workspaces.linkedWorktrees: trueinlibrechat.yaml; without it, requests stay scoped to the checkout even when the worker advertises lanes, so an administrator can turn it off without touching workers.LibreChat must ship this before any worker advertises the scope: the status parser rejects unknown workspace descriptor keys, so an older LibreChat would treat an upgraded worker as invalid.
Related to LibreChat-AI/code-interpreter#268 and LibreChat-AI/code-interpreter#270.
How it works
Only structural targets are routed; anything whose reach cannot be bounded stays root-scoped and runs exactly as before:
executeWorkspaceToolgains alinkedWorktreesoption. It validates the original request, maps it, computes budgets and validates the result against the mapped request, then restores the prefix onpath,matches[].path,pathsandnextAfterPath. Result validation therefore still rejects a lane result that escapes the requested worktree scope.resolveCodeExecutionWorkspaceContextsetscodeWorkspace.linkedWorktreeswhen the environment'sconfigSchema.workspaces.linkedWorktreesistrue, the workspace advertisesgit_linked_worktree, and no conversation workspace instance is active (the worker does not yet combine the two). The flag flows through the workspace file tools, the attached Bash tool and the model-facing tool definitions;/apipasses it through unchanged andpackages/apiaccepts onlytrue. When lanes are on, the Bashcwddescription tells the model to pass the worktree directory ascwdrather thancdinside the command, since only the former runs in parallel.Type of change
Testing
Tested environments/configuration:
--linked-worktree-lanes, which rolls out after this merges.Automated tests:
cd packages/api && npx jest src/code src/agents/handlers src/agents/execution: all pass.cd api && npx jest server/services/Files/Code server/services/ToolService: all pass.cd packages/api && npx tsc --noEmit: clean.workspace.lanes.spec.ts, covering each operation's mapping, every root-scoped case listed above, and prefix restoration.workspace.spec.ts: the wire body carriesworktreeand the stripped path; paths come back prefixed; the request is unchanged without the flag; a lane result outside the worktree scope is rejected.bridge.spec.ts: the scope is accepted, and malformed scope values are rejected.config.spec.ts: the toggle accepts only a boolean.tools.spec.tsandinitialize.test.ts: the model-facing Bash definition describes worktreecwdrouting only when lanes are on.capabilities.spec.ts: lanes are enabled only when configured, advertised, and no conversation instance is active.command.spec.ts: a worktreecwdis routed, and the schema describes it.process.spec.js: the flag is forwarded.Screenshots / recordings
No user-facing change.
Risk / compatibility
git_linked_worktree, and only Code API with code-interpreter#270 accepts theworktreefield.configSchema.workspaces.linkedWorktrees: trueon the environments that should route lanes.cds into a worktree from the root stays root-scoped. It is still correct, but it waits for every lane in that checkout.