🎯 feat: Tolerant Workspace Edits with Host-Rendered Conflict Diagnostics - #16520
Conversation
|
@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: f9220dd621
ℹ️ 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".
…om Parsed Facts, Bound replace_all
|
@codex review the latest head |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6302f23157
ℹ️ 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 the latest head |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba17a0534c
ℹ️ 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".
…Both Matching Modes
|
@codex review the latest head |
There was a problem hiding this comment.
💡 Codex Review
LibreChat/packages/api/src/agents/tools.ts
Line 958 in a456ff0
When the selected attached worker does not advertise replace_all, this definition still exposes and recommends the option because the attached tool unconditionally reuses CODE_EDIT_FILE_PARAMETERS; any model call that follows that schema is then guaranteed to fail at the capability guard in handleAttachedWorkspaceEditFileCall. Build the attached definition from codeWorkspace.editFileFeatures (or explicitly describe the option as unavailable) so mixed-version deployments do not advertise an operation they reject.
AGENTS.md reference: AGENTS.md:L44-L47
ℹ️ 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 the latest head, final review. no further reviews will be requested, last chance |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
…ics (LibreChat-AI#16520) * 🎯 feat: Opt Into Tolerant Workspace Edits and Pass Worker Diagnostics Through * 🛡️ fix: Gate Tolerant Edits Behind Config, Render Worker Conflicts From Parsed Facts, Bound replace_all * ⚖️ fix: Default Workspace Edits to Tolerant Matching and Stream Exact replace_all * 🧱 fix: Build Exact replace_all Output in Bounded Chunks and Describe Both Matching Modes * 🧹 fix: Keep Worker Conflict Bodies Out of Logs and Edit Matching Out of CJS
Summary
edit_filein an attached (BYOM) workspace is the strictest of LibreChat's fouredit_filevariants, and the least informative when it fails. Over 10 days on one deployment, 125 of 2,935 calls (4.3%) failed withEDIT_CONFLICT, and 94 of those were multi-edit batches. Each failure reached the model the same way: the worker's JSON body with its newlines escaped, followed by a suffix saying "did not match exactly once… Re-read the file and retry". That suffix was appended to every 409, including a file that changed while the edit was in flight. The model could not tell which edit failed or why, so it retried blindly or re-read the whole file.LibreChat-AI/code-interpreter#271 gives the worker per-edit diagnostics and two negotiated edit features:
tolerant_match(whitespace-tolerant fallback) andreplace_all. This PR is the LibreChat side:editFileFeaturesfrom its status and carries them into the selected workspace.matching: 'tolerant'on edits and previews whenever the worker negotiatedtolerant_match. So attached edits now tolerate trailing whitespace, CRLF and indentation shifts, as skill and sandbox edits already do. Operators can require exact matching withconfigSchema.edits.tolerantMatching: false. A match must still be unique unlessreplace_allis set.replace_all: theedit_fileschema getsreplace_all, top level and per edit, for every variant.replace_all. Otherwise it is refused before dispatch with a clear message.parseEditConflictaccepts only the worker's fixed diagnostic grammar and keeps bounded facts: which edits failed, not-found or ambiguous, counts, up to five line numbers, the strategy, and known hint kinds. Quoted file excerpts are dropped.formatEditConflictrenders LibreChat's own sentences from those facts. A file that changed mid-edit gets its own message; anything outside the grammar gets generic retry guidance.replace_all: exact matches are counted without retaining positions and rebuilt with split/join after a projected-size check. The whitespace-tolerant fallback stops collecting at 10,000 ranges.replace_all, the whitespace-tolerant fallback on current workers, and the new failure reporting.With an older worker or Code API, none of these fields are sent, and requests, results and messages stay exactly as they are today.
Depends on LibreChat-AI/code-interpreter#271 for the new worker behavior. Merging this first is safe: without the worker change, no features are advertised and nothing changes.
How it works
code/workspace.ts) acceptsmatchingand per-editreplaceAllin requests.matchesexactly when the request opted in: exact strategies only for non-tolerant requests, and more than one occurrence only forreplaceAlledits. This mirrors the worker's own validation.WorkspaceToolHttpError.editConflictexposes the worker'sEDIT_CONFLICTtext.code/edits.ts, sobridge.tsandworkspace.tsshare them without an import cycle.Type of change
Testing
Tested environments/configuration:
Automated tests:
packages/api:npx jest src/agents/handlers.spec.ts src/code/workspace.spec.ts src/code/bridge.spec.ts src/code/capabilities.spec.ts src/agents/tools.spec.ts src/code/workspace.lanes.spec.ts, 489 passed. New coverage:replace_allonly when negotiated;replace_allbefore dispatch on a legacy worker;replace_all;matching,replaceAllandmatches;api:npx jest server/services/Files/Code/process.spec.js, 166 passed, including forwardingmatchingandreplaceAllon edits and previews.npx tsc --noEmitinpackages/api; eslint on the changed files; the pre-commit circular-dependency check.Screenshots / recordings
Not applicable. No UI change; the tool result text changes only when a worker reports non-exact matches.