* 🪵 fix: Explain Failed Attachment Copies and Subagent Start-Up Failures
The attachments .gitignore and import failure warnings logged only a bare
error type: getSafeErrorMetadata reads `status`, which a workspace tool error
does not carry. They now log the request outcome, upstream status and the
worker's error code, never a body or host path. A worker that reports the
folder missing (one that predates LibreChat-AI/code-interpreter#360 on a
root registered by path alone) is reported to the user as needing an update.
A subagent that could not start was logged only as the SDK's `unknown`
resolution cause. The run now passes onSubagentResolutionFailure, which logs
the underlying cause chain (name, code, status, redacted message) and names
an MCP server that needs re-authentication. A detached child thread shows the
SDK's model-facing start-up message instead of a generic failure, and its
failure log carries the task id, resolution cause and a redacted error in
place of the raw stack.
* 🪵 fix: Log Only Trusted Error Text and Recognize the Legacy Missing-Path Reply
- Cause chains keep a message only for errors whose text LibreChat or the SDK
composes (MCP authentication errors, SubagentResolutionError,
CodeWorkspaceSelectionError); every other link logs name, code and status.
Child-thread failures log stack frames without the message line instead of
redacted error text.
- A retryable MCP refresh or rejection is logged as a sign-in failure a retry
may clear, not as one that needs re-authentication.
- A worker's missing attachments folder relayed by an older Code API as
INVALID_PATH "Workspace path does not exist" is also reported as
unsupported, through the shared isWorkspacePathMissing check.
* 🪵 fix: Log Frames Only From a Verified Stack and Keep OpenID Out of MCP
- Stack frames are read only after the stack's own name: message header, and
only when that header still matches the error, so a message line shaped
like a frame is never logged.
- OpenIDReauthRequiredError alone is no longer reported as an MCP sign-in
failure: model and endpoint headers raise it too.
* 📎 feat: Copy Chat Attachments into Attached Workspaces
A chat on an attached workspace now copies the user's own attachments into
.librechat/attachments/ before the model runs, through the worker's
import_file operation, and tells the model where they are. A worker without
the operation, a deny file-write policy, or a copy that fails or runs past
its bound leaves a plain note saying the file is not on this machine and why.
* 🧭 fix: Scope Attachment Records by Tenant and Prime Late Subagents
Match the tenant when recording a workspace copy, require write_file so the
folder can always ignore itself, key copies by the live Code API route and
worker, keep a digest when a copy fails so it is not hashed again, stop
waiting on bookkeeping at the deadline, refuse to start on a cancelled turn,
prime lazily initialized subagents through one per-turn primer, and make the
budget configurable as endpoints.agents.workspaceAttachments.timeoutMs.
* 🙈 fix: Copy Attachments Only Where the Folder Ignores Itself
Gate every copy on .librechat/attachments/.gitignore ignoring the whole
folder: create it with *, and accept an existing one only when it already
ignores everything, otherwise report the file as unavailable with how to fix
it. Prime a lazily routed subagent against its own tool context with a
provisioning callback bound to it, and check for a cancelled turn before
arming the deadline timer.
* 🪢 fix: Recheck the Attachment Ignore Rule Each Turn and Share One Request Cap
Drop the process-wide ignore cache and check the folder once per turn, shared
by every agent, rejecting a truncated read. Cap workspace requests per turn
across agents (workspaceAttachments.concurrency, default 3), name converted
images for their stored type, log only safe error metadata, and keep the
bookkeeping write from advancing updatedAt.
* 🔀 chore: Take dev's File Methods Ahead of Merging dev
dev and this branch both add to the same lines of the file methods module.
Take dev's version here so the merge of dev that follows is clean; the next
commit adds recordFileWorkspaceImport back beside dev's new methods.
* 🧩 fix: Ignore Workspace Operations a Newer Worker Advertises
Bring recordFileWorkspaceImport back beside dev's new file methods after the
merge. Drop well-formed operation names this build does not know from a
worker's capabilities, globally and per workspace, instead of rejecting the
whole status, so workers can turn on new operations such as import_file by
default. Known names keep their strict checks, malformed lists are still
refused, and a worker offering only unknown operations offers no workspace
tools rather than failing.
* feat: Look Up Bitbucket Cloud Pull Requests
* fix: Keep the Pull Request Host Out of Overrides and Per-Host Keys
A role, group, user or tenant override can no longer change or remove pullRequests.host, so feature gating and link recording see the operator's host. Links are recorded only from the configured host, and the batch share key and the rate limit cooldown are scoped by host.
* fix: Compare Pull Request Link Hosts Through the Host Resolver
* test: Add Pull Request Scenarios Against a Fake GitHub Enterprise Host
* fix: Keep the Pull Request Provider Out of Overrides and the Batch Share Key
A role, group, user or tenant override can no longer change pullRequests.provider, so feature gating and link recording agree with the lookup, and a batch lookup for one provider is never joined by a request for another.
* fix: Read GitLab History Apart From Open Merge Requests
Merged and closed merge requests are listed on their own, so open fork merge requests on the branch name cannot crowd them out. Rate limit cooldowns are scoped by provider, and a workspace repository with a dot segment is rejected.
* fix: Revalidate Bitbucket Pull Requests and Skip Ones Without a Source Commit
Read a full closed page so a newer closed fork cannot hide an older pull request from the repository, recheck the source branch and fork status on the detail, and treat a pull request without a source commit as unmatchable instead of failing the lookup.
* fix: Follow Bitbucket's Next Link When Listing Pull Requests
* fix: Record the Lane Pull Request Without an Aggregation Pipeline Update
* fix: Match an Empty Lane Repository as Unknown
* fix: List Locked GitLab Merge Requests With the Open Ones
* fix: Replace an Expiring Fake Git Host Certificate
A conversation's pull request was found only by searching its branch for a PR whose head
contains the recorded commit, so a single unpushed local commit hid an existing PR.
The attached bash tool now hands its output to the lane recorder, which records a
github.com pull request link to the lane's repository with the lane state. The link is kept
across later reports on the same branch and repository and dropped when either changes. The
GitHub source reads a linked PR directly and accepts it when its head is the lane branch in
the lane repository; a fork's PR must carry the recorded commit. The single and batch routes
both pass the link, and the batch route keys lanes by it.
* feat: Show the Conversation Pull Request in the Sidebar List
Add a batch lookup route and a sidebar row mark: the state icon with the CI dot, opening the same card beside the row on hover. The row keeps the conversation's own title.
* fix: Address Review Findings on the Sidebar Pull Request Batch and Row Mark
Cap the whole batch with a configurable deadline, make the row mark a keyboard-reachable button that opens the card on focus, refresh rows when the window regains focus through the shared batch, and show a retryable failure state instead of treating a failed first lookup as no pull request.
* fix: Send Sidebar Pull Request Batches One at a Time
Queue every batch request behind the one before it, so an oversized list or an overlapping flush cannot multiply the server's configured lookup concurrency, and bound how long one request may hold the queue so a request that never answers cannot stop the rest.
* fix: Keep the Batch Request Timeout Above the Server Deadline
Default the client's request timeout to just past the longest batchTimeoutSeconds a deployment may configure, so a queued request never starts while the previous request's server-side lookups are still running.
* fix: Keep Batch Lookups Inside the Concurrency Limit and Per-Entry Failures Per Entry
Share one lookup limiter across every batch request so lookups that outlive a request's deadline keep their slot, answer a missing token only for the conversations that needed it, and point the row at its pull request description only while that text is in the page.
* fix: Bound Batch Reads, Scope Concurrency Per Credential, and Gate the Sidebar on the Batch Version
Start the batch deadline when the request arrives and bound the config and lane reads, count lookup slots per credential, advertise a batch route version and ask only a server that has it, take no row space for an absent mark, show a failed refresh over a cached empty answer, keep a malformed response from stalling the request queue, and repair the lane recording tests that still used a mock removed on dev.
* fix: Move Capability Resolution Into the Package and Harden the Batch Route and Queue
Resolve the pull request startup capabilities in packages/api so the route stays wiring only, bound the config and lane reads by the configured deadline, merge identical lanes before taking limiter slots, fall back to the single route when a replica has no batch route, and dispose the batch queue when the signed-in user changes.
* fix: Abort the Batch Fallback With Its Request So the Queue Never Overlaps It
Give the batch fetcher the request's abort signal and pass it to every single-route call, abort a request that times out or is disposed, and stop the fallback workers from starting more calls once it has.
* fix: Forward the Abort Signal to the Batch POST
Pass the request's abort signal through the batch fetcher, the data-provider call and Axios, so a batch request that times out or is disposed is cancelled instead of continuing beside the next one, and settle a request promptly when it is aborted.
* fix: Close the Pull Request Lookup Follow-Ups and Cancel Abandoned Sidebar Rows
* 🏝️ fix: Apply the No-Workspace Decision Wherever an Agent's Code Route Resolves
A conversation set to run without attached workspaces failed mid-turn with
"Choose an attached workspace before using this agent." when its agent's
default machine was attached and the turn loaded a skill or another tool at
execution time. Request-start initialization honoured the decision, but the
execution-time tool loader re-resolved the agent's attached default and then
demanded a workspace selection the conversation intentionally never made.
The per-agent code rule now lives in one typed function,
resolveAgentCodeExecution (packages/api/src/code/agent.ts): it applies the
conversation's no-workspace opt-out, the run-code grant, the stateful
capability and the stateful environment policy, then resolves the base route.
Request-start initialization, lazy subagent metadata and graph members, the
execution-time and definition tool loaders, and the legacy execute_code
loader all go through it, so an opted-out agent lands on the managed default
route with no code tools at every site. Per-call subagent machine choices
offer and accept no attached machine in such a conversation, and a source
invariant test keeps new resolver call sites on the shared rule.
* fix: Pass the Implicit Stateful Route Rollout Into the Shared Code Rule
The per-agent code rule read the implicit stateful route rollout from the environment itself. It now takes it as a parameter, and the request boundaries (initializeAgent and withRequestCodeInputs) resolve it from the deployment configuration, so the rule stays a pure function of its inputs.
* fix: Carry the Initializer's Code Opt-Out Into Tool Definition Loading
initializeAgent hands the tool loaders a partial agent record (id, tools, provider, model) together with the code route it already resolved. Without the agent's route fields the definition loaders could not see a no-workspace opt-out and recomputed code execution as enabled, so tool classification could advertise the programmatic bash tool that execution then refuses. initializeAgent now passes attachedEnvironmentOptOut through every tool loader, and the shared rule keeps an opt-out its caller already decided.
* feat: Record Lane Git State and Serve Conversation Pull Requests
A conversation now stores the branch, head and repository its code lane last reported, written only by the server after a finished bash command and excluded from ordinary reads, generic saves, unset fields and imports. GET /api/convos/:conversationId/pull-request finds the pull request for that branch through an injected GitHub source with a bounded cache, answers null for an absence, and maps failures to stable codes without upstream text. The feature is off unless endpoints.agents.pullRequests is enabled with a token reference.
* fix: Address Review Findings on Pull Request Lookup and Lane Writes
Scope the lookup cache, shared in-flight request and rate limit cooldown to the credential, so one tenant's token never serves another. Ask for open pull requests on their own before falling back to the newest closed one, read every page of check runs up to a bound and never report an incomplete rollup as passing, order lane writes per conversation so an older write cannot land last, and name both required token permissions in the example config.
* fix: Address Second Round Review Findings on Pull Request Lookup
Clear the stored lane when the conversation moves to another workspace or leaves attached execution, so the previous workspace's pull request is never served. Fence the lane write on the time it was reported, so an older report from another replica cannot replace a newer one. Honor GitHub's reset window up to an hour instead of ten minutes, and expose the request timeout, whole lookup timeout and check run page limit as endpoints.agents.pullRequests settings with the previous values as defaults.
* fix: Authorize Pull Request Repositories and Fence Lane Writes
Require an administrator allowlist of repositories before the server token is used, since a worker reports its own repository. Match a pull request to the commit the conversation last ran at, so a reused branch name does not return another pull request. Fence the lane write on the workspace the command ran in, so a write queued before a move cannot bring the old lane back, and record a subagent thread's lane on the visible root conversation. Key the lookup cache and shared request by the recorded commit and the lookup policy, and document the worker flag in the example config.
* fix: Order Lane Reports by a Database Sequence and Tighten Head Matching
Replace wall clock ordering of lane reports with a per conversation counter reserved in the database when the command settles, so replica clock skew cannot reject a newer report. Treat a pull request whose head is behind the recorded commit as no match, and expose the candidate and comparison bounds of the history search as settings. Read the app config and the owner scoped lane together, inject the HTTP transport from the route instead of falling back to a global, skip a report identical to the last one written, and name the Contents permission that commit comparison needs.
* fix: Queue Lane Reports by the Visible Conversation and Read Checks for the Current Head
Order lane report reservations by the conversation the write lands on, so two subagent threads of one conversation share a chain, and write every report instead of skipping a repeat, since another recorder may have changed the lane in between. Read a pull request's detail before its check runs and use the head it reports, so line counts, mergeability and checks describe one commit. Treat an expired temporary chat as gone when reserving, writing and reading the lane, and make the shared cache capacity a setting.
* fix: Fence Lane Reports by Attachment Epoch and Place Recorders Before Reporting
Strip dotted descendants of lane fields from saves and imports, partition the pull request cache per credential, resolve the lane write target when the tool is created, and fence reports with a codeAttachmentEpoch that advances only on an owner move or detach.
* fix: Fence Subagent Lane Reports by the Root Epoch and Cover Forks and Moved Heads
Read the visible root's attachment epoch for a subagent report, gate lane recording on pullRequests.enabled, make the credential partition bound a config field, revalidate the detail head against the recorded commit, and find fork pull requests through the recorded commit.
* fix: Keep the Credential Cache Bound Deployment Wide and Budget Head Revalidation
Apply the largest configured credential bound to the shared cache, count cache hits as use, spend the comparison budget on a moved head, and fix the data-provider config default test.
* fix: Cool Down Headerless Secondary Rate Limits
A 403 whose message names a secondary rate limit now starts the credential cooldown for at least a minute instead of being cached as a ten second failure.
Code workers can report the branch and head commit of the lane a command ran in. LibreChat now accepts an optional laneGit key on execute_command results, bounded to a 256 character branch without control characters and a 40 or 64 character lowercase hex head, and rejects anything else. The data-provider gains the pull request types, endpoint, query key and service method, and an endpoints.agents.pullRequests config block that is off by default and takes the token only as an environment variable reference.
* 🧭 feat: Let a Parent Choose Its Subagent's Code Machine Per Call
A parent agent can now pass optional `machine` / `workspace` arguments on a
subagent call to pick where the child runs, using the host-argument
extension point added to @librechat/agents.
- Each lazy child declares enums built only from machines it may reach:
admitted in the conversation's sealed codeWorkspaces, on its default or
allowlist, in the requesting principal's tenant-scoped list, and served by
a ready worker. A child the conversation pinned to a machine offers only
that machine; a child with no reachable machine declares nothing.
- On use, a request-scoped routing session in packages/api re-validates the
choice against the current request and live worker status and refuses an
invalid one with a typed, model-visible error instead of falling back. A
routed child is pinned to the chosen machine at every routing site,
overriding parent inheritance.
- Omitted arguments keep inherit-by-default routing, extended so a child
follows the machine a per-call-routed parent runs on (passing through
agents without code). A subagent keeps one machine for the whole request.
- A child whose default workspace is unavailable stays guarded unless it has
per-call choices; then it stays callable and its description asks the
parent to pick a listed machine.
- Routed children keep their tool context per execution for tool loading,
provisioning and artifact handling.
- Paused-approval bindings, the attached-machine policy hook, skill-file
priming and tool-output references account for per-call choices.
The declarations are gated on the installed SDK exporting
SubagentHostArgumentError, so this change is inert until LibreChat depends on
an @librechat/agents release that includes it.
* 🧭 fix: Reserve Default Routes Early and Route a Routed Subagent's Graph Members
- Reserve a subagent's default machine when it is placed, as
initializeAgent will resolve it (including parent inheritance), so a
concurrent call cannot claim another machine during initialization.
- Graph members spawned by a per-call-routed subagent follow its machine
when they may, unless they already initialized on their own route this
request.
* 🧭 fix: Settle Concurrent Inherited Routes and Register Routed Graph Members
- Re-read a subagent's inherited route after resolving targets, so two
concurrent calls from differently routed parents settle on one machine.
- Attribute a workspace-only conflict to the workspace argument.
- Register graph members a routed subagent initialized, so each gets the
attached-machine policy of the machine it actually runs on.
* 🧭 fix: Re-read Inherited Routes After Resolving Subagent Targets
- Re-read a subagent's inherited route after the target resolution await,
so two concurrent omitted-machine calls from differently routed parents
settle on one machine.
- Attribute a workspace-only conflict to the workspace argument.
* 🧪 test: Prove a Routed Graph Member Takes Its Machine's Policy Through createRun
- Register a resolved child's graph members inline in the lazy resolver
instead of through an exported generic helper whose test did not
typecheck.
- Drive the check through createRun's real PreToolUse hook: a member
routed to a deny machine flips from its metadata machine's allow to deny
once its parent resolves.
* 🧭 fix: Hold a Lazily Loaded Graph Member's Default Machine While It Initializes
- Pass a graph member's code flags when it initializes on its default
route, so the routing session reserves that machine before the
asynchronous initialization instead of only after it, and a concurrent
call cannot place the same agent on another machine meanwhile.
* 🧭 fix: Validate the Approval Mode Against Every Machine a Subagent May Use
- Collect each agent's default attached route and each attached machine a
parent may route it to per call, and validate the requested approval
mode against that set in createRun and both client checks.
- A child whose default is unavailable but whose per-call machine permits
accept edits no longer fails run creation; full access still requires
every such machine to permit it.
* 🧭 fix: Admit, Prime, and Cancel Per-Call Subagent Routes Conservatively
- Build scheduled pause admission from every attached machine a parent
may route an agent to, so a permissive default does not hide a
per-call machine that asks.
- Walk lazy graph-member metadata when collecting execution routes, so
historical skill files are primed for every machine such a member may
run on.
- Stop placing a canceled call after its target resolution resolves, so
it never claims a machine for an execution that will not initialize.
* 🧭 fix: Release Unused Route Claims and Scope Per-Call Machines to Their Run
- Hold a subagent's route claim per placement: a failed or canceled
initialization gives the machine back unless another execution still
holds it, and a claim is permanent once a child on it attaches.
- Fold an agent's default route into its per-call choice digest, so each
agent contributes at most one paused-approval binding target.
- Use only an agent's route policies for pause admission when it has
them, so a missing default does not make a decided route look asking.
- Drop a routable child's provisional attached-machine membership when it
resolves off attached machines.
- Offer and accept no attached machine per call while run files are
shared, since shared children must run on managed code.
* 🧭 fix: Give Back a Route When Its Placement Verification Fails
- Release a placement's hold when attach finds the child initialized on a
different machine than the one it was routed to, so a retry that
follows the unavailable-machine guidance may name another machine.
* 🧭 fix: Commit a Lazy Child's Routes Only When Its Whole Resolution Succeeds
- Keep the routes a lazy child and its routed graph members hold pending
through the child's entire resolution (settleExecution), committing them
on success and giving them back on failure or cancellation unless
another execution still holds them.
- Placements outside any call (shared graph members) still commit when
they attach.
* 🧭 fix: Drop a Failed Lazy Resolution's Config from the Graph Cache
- When a lazy child's graph resolution fails or is canceled after its
config was cached for graph reuse, remove that entry with its route, so
a later graph never reuses a config for a machine the child gave back.
* 🧭 fix: Follow a Routed Agent Through Self-Spawned Runs and Scope Routed Member Configs
- A call whose parent run was never placed (an allowSelf spawn reuses its
routed inputs) inherits the routed claim of its parent agent, which keeps
one machine per request.
- Never share a graph member initialized for a routed parent's execution
through the graph-member cache, so a failed resolution leaves no config
behind for a route it gave back.
- Race lazy target discovery with the request signal.
* 🧭 fix: Pass a Machine On Through Self-Spawned Runs of Agents Without Code
- Record the machine each agent without stateful code passes on, and let a
call from that agent's unplaced run (an allowSelf spawn) follow it when
the agent passed on exactly one machine this request.
* 🧭 fix: Keep a Pass-Through Route Only When Its Resolution Succeeds
- Record the machine an agent without code passes on with the rest of its
call's routing state: kept when the resolution deciding it succeeds,
dropped when it fails, so a self-spawn never follows a failed attempt.
* 🧭 fix: Settle a Lazy Child's Routing State at the SDK Handoff
- Wrap the run's whole lazy resolution, through the inputs handed to the
SDK, in the descriptor's settle hook, so a cancel after the host
resolver returns still gives the call's routes back.
- Roll back the per-agent tool context a pending placement set (restoring
the entry it replaced) when its resolution fails, so a retry on another
machine seeds its own context.
- Drop a failed call's shared config from the graph cache through the
same settle hook.
* 🧭 fix: Keep Per-Agent Tool Contexts on Live Placements and Queue Target Probes
- Track every pending placement that uses an agent's per-agent tool
context: a committed one sets it, a failed one hands it to a surviving
placement, and only the last failure restores the earlier entry.
- Let an unplaced run of an agent (an allowSelf spawn) defer to the routed
run of the same agent that encloses it when looking up tool contexts.
- Queue live target probes at eight in flight, below the shared status
poller's ceiling, so concurrent descriptors never misreport a healthy
machine as unavailable.
* 🧭 refactor: Load Routed Graph Members Through a packages/api Service
- Move the routed graph-member load (shared reuse, skip list, view check,
execution identity, failure policy) into createRoutedGraphMemberLoader;
the initializer only injects its dependencies.
- Thread the request and call signals into target resolution so queued
probes are skipped once canceled.
- Probe nothing in shared-file runs, where every per-call target is
attached and unusable.
- Retire pending tool-context ownership when a committed placement
installs the per-agent entry.
* 🧭 fix: Share a Lazy Child's Config with Later Graphs Only After It Commits
- Publish a default-placed lazy child's config to the shared graph cache
from the settle hook's commit, so no concurrent graph can borrow a config
whose route may still be given back.
- Resolve a child's own appearance in its graph to the child config itself.
* 🧬 fix: Default Subagents to Their Parent's Code Machine and Workspace
A subagent resolved its code machine from its own saved fields only, so
when a chat routed the parent to an allowlisted machine the subagent fell
back to its own default and whatever workspace the conversation had
selected there, or failed the parent's whole turn when none existed.
Subagents now inherit the parent's resolved attached machine when it is
their own default or on their allowlist where per-chat choice applies,
the principal can use it, the sealed decision already selected it, and no
selection names the subagent as an explicit owner. Inheritance is derived
per request from the sealed decision and current agent configuration and
fed to every routing site; it is never persisted, so existing chats and
older clients get it without a decision change. The composer mirrors it.
A subagent whose machine has no usable workspace is advertised to the
parent as unavailable instead of failing the turn; a locked decision
stays fatal.
* fix: Inherit Across Every Spawning Path, Graph Members and Deferred Code Tools
A subagent now inherits only when every agent that can spawn it, at any
depth, runs on the same machine; spawn cycles keep their own routes.
Subagent graph members inherit like explicit subagents. The deferred
execute_code loader passes inheritance to its fallback resolver. Subagent
reads and VIEW checks move to a packages/api loader shared by inheritance,
lazy descriptors and graph members. The composer lets a draft's subagent
follow its parent's machine before a workspace is picked, and keeps an
inheriting subagent's former selection without asking for a move.
* fix: Prune Spawn Back-Edges, Gate the Composer on an Inheritance Capability
Spawning parents follow the run's path semantics, so a back-edge the
descriptor tree prunes no longer blocks inheritance, and agents that spawn
each other follow their single outside parent machine when it routes them
all there. Only admitted subagents count toward the walk's node limit.
Graph members re-read and re-check VIEW when they initialize. The composer
echoes an inheriting subagent's former selection without gating on that
machine, and mirrors inheritance only when the API advertises
codeWorkspaceInheritanceVersion; approval modes keep intersecting every
machine an agent could use.
* fix: Settle Each Mutually Spawning Group on Its Own
Independent spawn cycles no longer merge into one group, so a pair under
one parent follows that parent even when another pair follows a different
machine. Also types the data-provider spec for its ES5 target.
* fix: Bound the Inheritance Walk, Normalize Parallel Roots, Move Subagent Availability to TS
The walk reads in batches no larger than the remaining node budget, stops
once the limit is reached, and runs through the run's subagent load limiter.
Roots are keyed by saved agent ID, so a parallel root such as id____1 can
never receive an inheritance entry. Resolving a lazy subagent's code route,
reporting it unavailable, and guarding its descriptor now live in
packages/api (resolveSubagentCodeAvailability, guardUnavailableSubagent).
* fix: Keep Missing Subagent Loads Parallel Near the Node Limit
Batches never shrink below eight IDs, so missing or unviewable subagents
near the limit still load in parallel under the injected limiter, and at
most a handful of reads land past the limit.
* fix: Separate workspace admission and transport budgets
* fix: Validate workspace run reserves and retry test types
---------
Co-authored-by: Lia <lia@librechat.ai>
* 📍 feat: Show the Current Text Where a Missing Workspace Edit Belongs
Render the current-text excerpt that LibreChat-AI/code-interpreter#300 workers append to a missing edit's EDIT_CONFLICT diagnosis: a strict parse keeps it only when every row is well formed (contiguous numbers matching the stated range, a known mark, a bounded single line), and LibreChat renders it as a numbered block under its edit with a summary of which lines differ. The excerpt passes the file-content policy like a read_file result and reaches only the model; logs keep the excerpt-free message.
Also stop rendering every 409 as a text mismatch: a Code API rejection such as WORKSPACE_QUARANTINED now passes through with its own reason, and the worker's repetitive-candidate refusal is recognized.
* 🔒 fix: Name Other Attached Edit 409s by Code Instead of Forwarding Their Body
A 409 whose code is not EDIT_CONFLICT (a quarantined workspace) now gets a host-worded message naming only its validated code, with recovery guidance for WORKSPACE_QUARANTINED, and logs keep a body of just that code.
* 🧾 fix: Present Quoted Edit Excerpts as Partial Context, Not Text to Copy
A worker excerpt can window a long region and shorten wide lines with an ellipsis, so the guidance now asks the model to correct old_text against it and use read_file for lines it leaves out or shortens, here and in the attached edit_file descriptions.
* 🔐 fix: Quote Edit Excerpts Only Where the Workspace Allows read_file
A workspace that offers edit_file without read_file now never receives the worker's current-text excerpt, so a failing edit cannot read file content the operation policy withholds.
---------
Co-authored-by: Lia <lia@librechat.ai>
* 📝 docs: Describe Attached-Workspace Lanes, Sandbox Scratch, and Skill Files in Tool Descriptions
- Lane-mode `cwd` now states that any call outside `.worktrees/<name>` (with or
without cwd, and file tools on such paths) is checkout-wide: it waits for
running worktree calls and blocks new ones until it finishes, so checkout-wide
calls are reserved for creating, pruning or removing worktrees.
- `command`/`cwd` state that the command starts in cwd, so the model does not
also cd into it; the lane-mode cd hint says the call ran checkout-wide.
- Workers advertising the native SRT sandbox profile (`anthropic-srt`,
`anthropic-srt:<preset>`) get a bash bullet that / and /tmp are read-only and
scratch files belong in $TMPDIR or the workspace. Carried as
`codeWorkspace.nativeSandbox` into tool definitions and the bash tool.
- The attached skill-aware `read_file` description says skill files are not on
the attached machine and must be written into the workspace to run there.
- Tightened the attached bash description so the native variant stays within
the 1024-character tool description limit.
* 📝 fix: Keep the Skill-Copy Warning on the Command-Only Workspace's Skill read_file
A workspace that offers execute_command but not read_file falls back to the
skill-only read_file definition. It now carries the same sentence as the
attached skill-aware definition, so the model knows bash_tool cannot reach
skill files by path there.
* 📝 fix: Name bash_tool in the Skill-File Warning Only When It Is Registered
The skill-copy sentence on attached read_file definitions now depends on the
attached bash_tool being registered beside it (includeBash and an advertised
execute_command), for the attached skill-aware definition, its custom
line-limit variant, and the skill-only fallback. Workspaces without commands
keep the plain skill description.
Attached workspace file tools now append a short, specific explanation when
the worker rejects a path with 422:
- NOT_FOUND from a current worker, or INVALID_PATH carrying its
"Workspace path does not exist" message through an older Code API, says
the path does not exist: wait for a command still writing it, or list the
directory to find the right path. For create_file it names the missing
parent directory.
- An older worker's bare INVALID_PATH on read_file, create_file or
edit_file, which it also returns for a missing file, lists the possible
causes: not written yet, a directory or symlink, or a missing parent
directory for create_file.
Other rejections are unchanged.
* ✅ feat: Default Machine Selection and Linked-Worktree Lanes On
Per-chat machine choice from an agent's saved allowlist and linked-worktree
lane routing were both opt-in, so neither worked until a deployment found and
set its flag. Both are now on unless set to false: machine choice still only
applies to agents with a saved allowlist, and lanes still require a worker
that advertises git_linked_worktree. One helper per flag in data-provider
decides the default for every server reader and the advertised client config.
* feat: Advertise the Code Environment Decision Protocol by Default
Per-chat machine choice needs the conversation decision protocol, which the
client requires before offering allowlisted machines, but the protocol was
only advertised when CODE_ENVIRONMENT_DECISION_VERSION=1. With selection on
by default, authors could save an allowlist the composer never offered.
An unset or blank value now advertises protocol v1; any other value, such as
0, keeps the legacy-safe path.
* fix: Turn Machine Choice Off With the Decision Protocol Opt-Out
CODE_ENVIRONMENT_DECISION_VERSION=0 stopped advertising the protocol but
routing still accepted a non-default machine, so a cached tab or a direct
client could persist a choice during a mixed-version rollout. Machine choice
is recorded through that protocol, so isCodeEnvironmentSelectionEnabled now
requires both, for routing and for the advertised endpoints config. The
protocol resolver moves to code/protocol.ts (re-exported from code/config)
so execution and endpoints can use it without an import cycle.
* style: Format checkout routing regression cases
---------
Co-authored-by: Lia <lia@librechat.ai>
* feat: Show Exit Status for Attached Workspace Commands
Parse the exit trailer the attached-workspace bash_tool writes so the card
fails a non-zero exit, a signal or a timeout, names the reason beside the
failure suffix, and renders stderr distinctly. The group outcome reads the
same parser so its failed count matches the card. Sandbox output without the
trailer keeps the existing heuristics.
* fix: Parse Exit Status Only for Attached Workspace Calls
The sandbox and attached-workspace tools are both named bash_tool, and the
sandbox output is trimmed, so a sandbox command that printed
"[exit code: 1]" last was read as a failed attached-workspace run by the
card and the group outcome.
The execute handler now records a run step when the resolved tool instance
is the one createAttachedWorkspaceBashTool built (tracked by object
identity), and the step-completed handler stamps executor:
'attached_workspace' on the streamed tool call and the aggregated part.
Redis replay and the client SSE merge carry the field through. BashCall
and outcome.ts parse the trailer only when the marker is set.
* fix: Count Styled Terminal Lines Like Plain Ones When Output Ends in a Newline
(cherry picked from commit abc9285523)
Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16556
* 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
* feat: Attach or leave a workspace on a saved chat
A saved chat that recorded running without an attached environment could
never take one: `without_attached` is sealed for the life of the chat, and
the only transition was a move between attached environments. Switching an
existing chat to a coding agent therefore ended in a composer that could
send but never reach files or commands. A chat sealed to a machine that went
offline had the opposite dead end: Send stayed disabled with nothing on
offer but a reconnect hint, and the "Move the chat to continue without it"
copy promised a request the server rejected as `invalid`.
One transition mechanism now covers all three directions. `from` still
repeats the persisted decision, so a stale view cannot replace a decision it
has not seen, and only a decision the chat actually recorded can move:
- attach, from a recorded `without_attached` onto the environments its
agents use, with each target workspace revalidated on its worker;
- detach, an empty `to`, which clears the selections without polling the
machine the chat is leaving;
- move, unchanged, including its refusal to switch the workspace of an
environment the decision already covers.
The composer keeps the control visible while a chat runs without a
workspace, so that state is named and reversible, and offers "Continue
without workspace" whenever a sealed machine stops being usable. History is
untouched and no file is copied.
A send now also records the decision it was submitted under on its own
conversation. The server seals that pair for the rest of the chat, so a chat
that became saved mid-run held none while the stored one was already sealed:
the composer re-derived an agent default the seal refuses and reported
"Choose workspace" with Send disabled until the page was reloaded.
* 🎨 style: Format the Workspace Transition Hook Tests
* fix: Never seal a partial workspace decision, and gate the new directions
Two review findings on the transition mechanism.
A transition replaces the sealed decision whole, and the next turn resolves
every environment or none. The move path could not truncate before, because it
was offered only in `choose` state, which `aggregateState` reaches only when no
environment is unavailable, unsupported or missing: every environment was then
either carried over or selectable. Widening the gate to `!canSubmit` so an
unreachable machine could be left behind broke that invariant, and an
environment nothing can cover would have been dropped from a decision the
composer then sealed, blocking the next send and needing a second transition to
escape. A nonempty transition now requires every environment to be retained or
selectable; when one cannot be, only leaving attached execution is offered,
which is the escape.
The move protocol version becomes 2. Attach and detach travel on the same
owner-authorized endpoint as the move, so a client built against this change
would otherwise offer both to a deployment that only implements moves, where an
attach comes back `locked` and an empty target set `invalid`. The client already
compares the advertised number against the constant, so the bump is the gate.
`conversationMoves.enabled` still decides whether an owner may replace a sealed
decision at all.
* fix: Keep v1 moves working, and take the conversation updater from its owner
Two review findings on the previous head.
Bumping the move protocol wholesale made the client's exact-version check treat
a replica still advertising 1 as supporting nothing, so an attached chat whose
agent moved to another machine lost the relocation that replica already served
-- the previous head's own compatibility test pinned that regression. The
protocol is now two constants: version 1 is the move between attached
environments, version 2 adds attaching an environment to a chat that recorded
running without one and leaving attached execution behind. The server
advertises the highest it implements and the client keeps every lower
capability, so a v1 replica keeps its move while attach and detach wait for the
version that serves them. Where an environment cannot be covered and leaving is
not served either, no transition is offered and the composer reports the state.
Recording the submitted decision had made this hook a second Recoil writer of
the conversation atom, widening the surface that migration has to convert. The
host that owns the atom already holds its setter, so the hook receives it
instead of reaching through `~/store`.
* fix: Advertise attach and detach beside the move instead of above it
Raising the move protocol to 2 kept a client and server of the same build in
agreement, but not the two builds a rollout actually runs at once. The deployed
client compares the advertised number for equality against its own constant of
1, so a server advertising 2 tells every client already loaded in a browser that
moves are unsupported, and an attached chat whose agent changed machines loses
its relocation until that tab reloads.
The move version therefore stays 1, exactly as before this branch, and the two
new directions are advertised on their own field:
codeEnvironmentMoveVersion: 1 // move between attached environments
codeEnvironmentTransitionVersion: 2 // attach an environment, or leave one
Both come from `conversationMoves.enabled`, since all three are one owner
replacing one sealed decision. A client that predates this capability reads only
the move version and keeps working; a client that has it offers attach and
detach only where the second field appears, so it never sends a replica an
attach it refuses as `locked` or an empty target set it calls `invalid`.
* fix: Hold a send while a workspace decision is being replaced
Confirming an attach left Send enabled. The composer disables only the
workspace menu while the request is in flight, so a turn submitted right after
the confirmation started under the decision being replaced: it ran without the
workspace its owner had just chosen, and the replacement still landed, because
the stored decision the compare-and-swap expects was unchanged. The chat then
reported an environment its last turn never used, and nothing said so.
The server's own check has the same shape. It reads the conversation's
generation state, then revalidates each target workspace over the network, then
swaps; a turn that starts during that round trip is invisible to the check that
already ran. It now re-reads the generation state immediately before the swap,
leaving only the instant the compare-and-swap itself covers, which closes the
window for every client rather than just this one.
On the client the submission resolver refuses while a replacement is pending,
so the same signal disables the Send button and makes a programmatic send
return false. The workspace control stays reachable, so the state a chat is in
remains visible while it settles.
* fix: Fence Workspace Transitions and Reconcile Rejected Choices
Advance a private conversation revision after publishing an active generation and before reading its authoritative workspace decision. Transition CAS writes compare that revision, covering admission during the final idle-check window without expiring locks. Preserve tenant middleware and exclude private counter writes from chat activity and indexing.
Default existing undecided chats to no workspace, reconcile failed submissions from the server, scope pending guards to the affected chat, compare selection tuples without delimiter collisions, and opt attach/detach into deployment policy independently of existing moves. Retain legacy selection-only choices through first-send events.
* fix: Retain Failed Workspace Recovery and Skip Disabled Fences
Keep unconfirmed code-environment decisions in conversation-scoped Jotai state after authoritative reads fail, mutation observers reset, or navigation unmounts them. Expose a retry action and release submission only after a matching successful read. Ignore stale completions and reject mismatched conversation responses.
Reuse the owner-scoped conversation already loaded by each ingress when effective conversation moves are disabled. Retain the admitted revision fence for enabled moves, including move-only deployments. Cover failure/retry lifecycle and both policy branches at the helper and ingress levels.
* fix: Reuse the Atomic Admitted Snapshot Through Recovery
Return the admission revision and persisted decision from one Mongo findOneAndUpdate. Skip content indexing per internal query while retaining tenant middleware, private projection, and timestamps. Carry the returned snapshot through web and API initialization instead of validating against a stale pre-admission selection.
Keep first-send workspace choices in both the recovery preset and conversation template, and reconcile using the generated conversation ID from error or message data rather than requiring a saved submission snapshot. Cover single-query storage, indexing isolation, moved-machine validation, and first-send error recovery.
* fix: Reconcile Cancelled Turns and Keep Detach Reachable
Reconcile the submitted code decision before the local cancellation path finalizes streamed content or recovers a minimal submission. A cancel that beats the server rejection must not leave the attempted choice sealed locally; navigation must not update a different conversation.
Offer the authorized detach-only transition when a sealed conversation no longer has any attached agents, while ordinary chat stays sendable. Keep the selector visible for that transition and retain existing policy gates. Cover cancellation branches, no-attached-agent states, managed-only agents and the detach action.
* fix: Recover Workspace Transitions Across Navigation
* test: Verify Saved Workspace Transitions Against Current Dev
* test: Assert Explicit No-Workspace State in Native Journey
* test: Await Browser Settlement Before Switching Native Agents
* test: Settle URL Agent Selection Before Native Chat
* test: Wait for Worker Lease Expiry Before Offline Detach
---------
Co-authored-by: Lia <lia@librechat.ai>
Co-authored-by: Danny Avila <danny@librechat.ai>
* fix: Stop Sealing a Code Environment Decision a Chat Never Made
Switching an existing chat to a coding agent left the composer unable to
send. The chat had no workspace to select, Send stayed disabled, and the
workspace chip was a read-only status with a recovery hint.
Both layers treated "no decision recorded" as "decided to run without an
attached environment". `readPersistedDecision` documented that a stored
conversation always carries a decision and inferred `without_attached`
whenever `codeEnvironmentMode` and `codeWorkspaces` were both absent,
which is the ordinary state of a chat whose turns never involved a
code-capable agent. `resolveConversationCodeEnvironmentDecision` then
sealed that inference, so the first workspace its owner picked came back
as `locked`. The client mirrored the same premise: `locked` was any saved
chat, so `useCodeWorkspace` withheld agent defaults, a remembered
selection, and a sole workspace, and `CodeWorkspaceMenu` rendered its
non-interactive locked branch.
Only a recorded decision is sealed now. A conversation holding neither
field is undecided, so its first coding turn establishes the decision,
and `resolvePersistableCodeEnvironmentDecision` records that decision
with its selections; writing the mode alone would leave `attached`
without the selections the next turn validates. On the client the same
predicate drives `locked`, and the selection defaults that already
applied to a new chat now apply to any chat that has not decided.
An explicit `without_attached` stays sealed, a legacy row still infers
`attached` from the selections it stores, and a sealed decision is still
replaced only by its owner's move.
* fix: Record the first code environment decision on an existing chat
A saved chat that holds no decision may record the one a run establishes,
but every caller persists through `saveConvo`, which carries those fields
only in `$setOnInsert`. On a row that already exists the write was dropped,
so the choice never survived a reload and a later turn could resolve a
different workspace.
`saveConvo` now fills a whole decision onto a row that holds none, by
compare-and-set on that absence: a writer that decided first keeps its
decision, a chat that already holds one is untouched, and bare selections
never seed a row.
* fix: Record the decision a failed turn of a saved chat ran under
`saveErrorTurn` built its conversation fields only when it was seeding a new
row, so an existing chat kept the stored error turn without the decision that
turn ran under: a retry could then pick a different workspace than the failure
already recorded. The validated decision now travels on both branches, where
the conditional write in `saveConvo` keeps it from replacing a stored one.
* refactor: Resolve the error turn's decision fields in `packages/api`
The error-turn save derived its own decision fields, putting persistence
policy in a CJS controller where `/api` is meant to hold wiring only. It now
calls `resolvePersistableCodeEnvironmentDecision`, the resolver the streaming
saves already use, so one rule decides what a turn may record: a chat that
holds a decision keeps it and receives no decision fields at all.
* fix: Keep the legacy code environment lock until the protocol is advertised
The composer unlocked a saved chat that holds no decision without consulting
`codeEnvironmentDecisionVersion`, so during the rollout window it could attach
an agent default and submit it to a replica that still reads a field-less row
as a sealed `without_attached` and rejects the turn as `locked`.
The unlock now waits for the deployment to advertise the protocol, which makes
the hook identical to its previous behavior while the flag is unset. Nothing is
lost by waiting: the unmade decision is only reported once that flag is on.
---------
Co-authored-by: Lia <lia@librechat.ai>
* ⏳ fix: Keep BYOM tools queued across capacity windows
* ⏳ fix: Configure the admission budget and refresh queued credentials
Addresses the Codex review on #16060:
- Add `limits.maxQueueWaitMs` to the code environment config schema so a
deployment can shorten or disable the five-minute admission budget from
`librechat.yaml`; omission keeps the merged behavior, `0` surfaces the
first capacity expiry to the model. Resolved through
`resolveAttachedWorkspaceQueueWaitMs` and passed by ToolService, matching
how `maxCommandTimeoutMs` already flows.
- Accept an auth-header supplier in `executeWorkspaceTool` and mint it per
admission attempt, so a call queued past the Code API token TTL presents
fresh credentials instead of failing permanently with 401. The attached
Bash tool and the workspace file operations now pass suppliers.
- Recheck the deadline after a clamped wait and throw the saved rejection
rather than opening an admission window that could still be admitted
once the budget is spent.
* fix: Complete workspace admission wiring and caller regressions
* fix: Share protected edit retry budgets and schema limits
---------
Co-authored-by: Lia <lia@librechat.ai>
* fix: Enable programmatic Bash in selected attached workspaces
* Centralize project PTC construction and preserve recognized capabilities
* Prevent stale list refreshes from restoring removed pins
* 🧭 fix: Let a Sealed Chat Follow Its Agent to a New Machine
A conversation's code-environment decision is sealed on its first turn, but the
environment an agent uses stays editable. Pointing an agent at a different
attached machine left every chat sealed to the old one with no valid move: the
client showed an unusable workspace chooser, and any other selection was
rejected by the server as locked. Forking copied the stale seal.
The owner can now move such a chat explicitly. The composer names the machine
the chat used and the one its agent uses now, and moving it goes through an
owner-scoped endpoint that compare-and-swaps the persisted decision after
validating the new workspace against the live worker. A move never switches the
workspace of an environment the decision already covers, never upgrades a chat
that continues without an attached environment, and is refused while a
generation is in flight.
A saved chat also no longer auto-selects a sole workspace for an environment its
decision never covered, which submitted a selection the server always rejected.
* fix: Hold Moves Through Terminal Saves and Move Every Target at Once
A terminal claim marks a generation complete before its response save lands,
and that save still writes the decision the run started with, so a move is now
refused until terminalPersistencePending clears.
The API advertises codeEnvironmentMoveVersion, and the client offers a move only
when it is present, so a new client never exposes an endpoint an older API lacks.
The move menu picks one workspace per new environment, with a sole workspace
preselected, and a single confirm sends the complete target set in one request,
so a partial move can no longer leave a half-migrated decision. A new machine
that advertises no workspace shows its unavailable state instead of an empty
section, and the confirm stays disabled.
* fix: Keep Runs From Rewriting Moved Decisions and Gate Moves by Policy
Every agent turn used to persist the decision it started with, so a run from any
ingress that settled after a move could write the old decision back: the chat
controller reads the conversation before its generation job exists, and
Responses API runs never enroll one. Runs now persist a decision only for a
conversation that does not store one yet, and a legacy row records only the mode
it inferred, so no admission or persistence order can revert a move.
Moves are now an operator setting, statefulCodeSessions.conversationMoves.enabled,
off by default. The API advertises codeEnvironmentMoveVersion and accepts moves
only where the effective policy enables them.
A saved chat carrying attached selections no longer auto-selects a sole workspace
even when selection-less decisions are not advertised, because the server seals
those selections either way.
* fix: Fence Moves Across Remote Runs and Let Moves Drop Unused Machines
A Responses API run is keyed by its response id, so the conversation stream
alone could not show it still working on a chat. A move is now refused while any
generation that can still act for the conversation exists, using the same
conversation-scoped enumeration conversation deletion drains.
A move now validates every workspace it persists, not only the added ones, so a
successful move never hands back a decision whose kept workspace is gone.
A chat sealed to machines its agents no longer all use could not be sent or
moved: the client trimmed the unused selection and the server rejected the
trimmed set as locked. A saved chat now treats that seal as unresolvable, offers
a move that drops the unused machine, and the server accepts drop-only moves.
* fix: Own the Decision Fallback in TypeScript and Settle Move Caches
The fields a run may persist when it never resolved a decision were chosen by a
branch in AgentClient; resolvePersistableCodeEnvironmentDecision now owns that
fallback too, under the same never-overwrite rule, and the CJS method only wires
the request into it.
Workspace choices made in the move menu belong to the chat they were made in, so
another relocatable chat targeting the same machine starts undecided.
A successful move cancels conversation, pinned, and list reads already in flight
before writing the moved decision, so a response from before the move cannot
restore the replaced decision in the cache.
* Trace BYOM command cancellation at the HTTP boundary
* 🧹 chore: Sort Command Module Imports
The Static Checks job fails on this branch at the "Import sorting" step:
`node scripts/sort-imports.mts --check` reports
`packages/api/src/code/command.ts` as out of order.
The `logger` import added for the BYOM command diagnostics was placed after
`import { tool } from '@librechat/agents/langchain/tools'`, but package
imports sort shortest to longest line, and the data-schemas import is the
shorter of the two. Reordered by running the repo's own sorter, which is
also what the pre-commit lint-staged hook applies.