Skip to content

🧭 fix: Explain Missing Workspace Paths to the Model - #16700

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/workspace-path-not-found
Oct 3, 2026
Merged

danny-avila merged 1 commit into
devfrom
danny-avila/workspace-path-not-found

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

When an attached worker rejects a workspace path, the model gets the raw worker error, Workspace tool request rejected (upstreamStatus: 422); upstreamBody: "{"error":"Invalid workspace path","code":"INVALID_PATH"}". Current workers return that same response for a file that does not exist yet. The message suggests the path format is wrong, but workspace/{relativePath} is the form the tools ask for.

Over 7 days on demo.librechat.ai, 57 workspace file-tool calls failed with 422 INVALID_PATH. 54 of them used a correctly prefixed workspace/ path to a file that was simply not there. About 30 were read_file calls on log files a background command had not written yet, for example workspace/.worktrees/<lane>/.checks/tests.log. Several of those succeeded when the agent read the same path again later. Most of the rest were guessed paths, and 5 were create_file calls into a directory that did not exist yet.

The worker side is fixed in LibreChat-AI/code-interpreter#301. Workers built from it return NOT_FOUND ("Workspace path does not exist") for an absent path, keep INVALID_PATH for real path-safety rejections, and create missing parent directories for create_file on held roots. That PR also covers a Code API that predates the new code. There, the worker sends INVALID_PATH instead but keeps the "Workspace path does not exist" message.

This PR makes LibreChat append a short, specific explanation to these rejections in the attached read_file, create_file, edit_file, list_workspace_files and search_workspace tools. It handles both worker generations:

  • A path the worker reports missing returns NOT_FOUND, or INVALID_PATH with the "Workspace path does not exist" message through an older Code API. The model is told the path does not exist, and that it should wait for a command still writing the file or list the directory to find the right path. For create_file, it is told which parent directory is missing and to create it first.
  • An older worker's bare INVALID_PATH on read_file, create_file or edit_file is ambiguous, because it also covers a missing file. The model gets the possible causes: the file is not written yet, the path is a directory or symlink, or (for create_file) the parent directory is missing. The same bare rejection on list_workspace_files and search_workspace is left unchanged, so a real path-safety error is never presented as a missing file.

Every other rejection is unchanged. The raw upstream status and body remain in the message and in the logs.

Related to LibreChat-AI/code-interpreter#301. No dependency in either direction: this PR handles both old and new workers, and #301 works with current LibreChat.

How it works

packages/api/src/code/paths.ts classifies the rejection from the upstream status and body, then appends static text. No worker-supplied text is echoed. Each attached tool's error path calls it once:

handleWorkspaceFileRead / handleWorkspaceSearchCall / handleWorkspaceListCall
handleAttachedWorkspaceCreateFileCall / handleAttachedWorkspaceEditFileCall
  catch WorkspaceToolHttpError
    explainWorkspacePathRejection(error, operation, "workspace/<path>")
      422 NOT_FOUND                                  -> missing
      422 INVALID_PATH "Workspace path does not exist" -> missing
      422 INVALID_PATH (other), read/write/edit only -> unusable (legacy)
      anything else                                  -> unchanged

Example of what the model now sees for a log a background command has not written yet, from a current worker:

Workspace tool request rejected (upstreamStatus: 422); upstreamBody: "{\"error\":\"Workspace path does not exist\",\"code\":\"NOT_FOUND\"}". "workspace/.checks/tests.log" does not exist. If a command is still writing it, wait for that command to finish before reading it again; otherwise list its directory to find the right path.

Type of change

  • Bug fix

Testing

Tested environments/configuration:

  • Windows 11, Node 24, packages/api Jest.

Automated tests:

  • Added attached path rejections cases to packages/api/src/agents/handlers.spec.ts. They run through createToolExecuteHandler with the worker call rejecting the way each worker generation does:
    • create_file and edit_file, for three cases: a current worker (NOT_FOUND), a current worker behind an older Code API (INVALID_PATH + the "does not exist" message), and an older worker (bare INVALID_PATH). Other 422 rejections (INVALID_REQUEST) stay unexplained.
    • read_file for the same three cases.
    • list_workspace_files and search_workspace for NOT_FOUND, the mapped message and the bare legacy rejection. The bare rejection is left unexplained.
  • npx jest src/agents/handlers.spec.ts -t "path rejection": 17 pass.
  • npx jest src/agents/handlers.spec.ts src/code: the new tests pass. handlers.spec.ts has 54 failures in skill and sandbox edit tests that fail identically on unmodified dev on this Windows machine. They are unrelated to these code paths.
  • npx tsc --noEmit in packages/api: clean. npm run build:api: succeeds. ESLint and the pre-commit static checks: clean.

Screenshots / recordings

No user-facing change.

Risk / compatibility

Text is only appended to existing tool error messages; no tool result shapes or request payloads change. Detection of a mapped NOT_FOUND depends on the worker's exact "Workspace path does not exist" message from LibreChat-AI/code-interpreter#301. If that message changes, those responses fall back to the legacy explanation, which still covers a missing file.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • User-facing or complex behavior is documented where necessary
  • Required dependency changes have been merged/published
  • Required documentation PR: N/A

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.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 01:58
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Pass 1 of 4 on head 5f37677.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T02:13:26.692328Z 5f37677 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Some generated guidance is inaccurate for edit operations and genuine legacy path-safety rejections.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Improves model guidance for attached-workspace path failures across worker versions.

Changes:

  • Classifies missing and legacy ambiguous path rejections.
  • Adds contextual guidance to five workspace tools.
  • Tests current, mapped, legacy, and unrelated rejections.
File Description
packages/​api/​src/​code/​paths.ts Classifies and explains path failures.
packages/​api/​src/​agents/​handlers.ts Applies explanations to workspace tools.
packages/​api/​src/​agents/​handlers.spec.ts Covers worker-version rejection behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if (operation === 'search' || operation === 'list') {
return `${quoted} does not exist. List a parent directory to find the right path.`;
}
return `${quoted} does not exist. If a command is still writing it, wait for that command to finish before reading it again; otherwise list its directory to find the right path.`;
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 5f37677a5c

ℹ️ 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".

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Pass 2 of 4 on head 5f37677.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 5f37677a5c

ℹ️ 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".

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

This is the final review for this PR (pass 3 of 3) of head 5f37677. Please flag only blocking issues: correctness, security, or data loss.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 5f37677a5c

ℹ️ 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".

@danny-avila
danny-avila merged commit ab086a6 into dev Oct 3, 2026
59 of 63 checks passed
@danny-avila
danny-avila deleted the danny-avila/workspace-path-not-found branch October 3, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants