Skip to content

👓 feat: Read Attached Workspace Files - #15524

Merged
danny-avila merged 13 commits into
devfrom
danny-avila/code-workspace-tool-adapter
Sep 4, 2026
Merged

danny-avila merged 13 commits into
devfrom
danny-avila/code-workspace-tool-adapter

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

I connected attached BYOM workspace reads to LibreChat’s existing read_file tool. This PR depends on LibreChat-AI/code-interpreter#90 for the authenticated Code API workspace endpoint.

  • Route explicit workspace/{relativePath} reads only when the selected code environment is attached.
  • Preserve the existing skill-file and /mnt/data behaviors for managed environments.
  • Forward the selected principal-bound worker identity through LibreChat’s existing Code API authentication path.
  • Validate request and response paths, protocol fields, result shapes, line windows, and payload sizes before returning worker content to the model.
  • Cap streamed Code API responses at 4 MiB and suppress worker-side failure details from model-visible errors.
  • Advertise bounded start_line and max_lines pagination only for attached environments.
  • Support ordinary directories and empty workspaces without requiring a Git repository.

Change Type

  • New feature (non-breaking change which adds functionality)

Testing

  • Ran 208 focused Jest tests for agent handlers, code-tool registration, and the workspace HTTP client after rebasing onto the latest origin/dev.
  • Ran TypeScript --noEmit before the upstream dependency update; after rebasing, the shared local @librechat/agents install reports pre-existing RuntimeProviderName errors in memory tests, so CI will validate against the branch lockfile.
  • Ran Node syntax checks for the changed server JavaScript files.
  • Ran a live isolated E2E with Code API on port 23115, Redis on port 26383, and an outbound worker rooted at a non-Git directory. Verified the real LibreChat handler returned a paginated workspace/notes.txt read, rejected traversal locally, and rejected an escaping symlink with HTTP 422.

Test Configuration:

  • macOS arm64
  • Node.js 24.16.0
  • Code API: http://127.0.0.1:23115/v1
  • Redis: 127.0.0.1:26383
  • Workspace: isolated plain directory with no .git metadata

Checklist

  • My code adheres to this project’s style guidelines
  • I have performed a self-review of my own code
  • I have commented in complex areas of my code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective
  • Local focused unit tests pass with my changes
  • I listed the downstream Code API dependency explicitly

Copilot AI lite review requested due to automatic review settings September 2, 2026 17:52

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.

🟡 Changes recommended

Path validation in the new workspace client should reject non-canonical segments (e.g., empty or .) to avoid ambiguity between server validation and worker path resolution.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR wires “attached BYOM workspace” file reads into LibreChat’s existing read_file tool by introducing a bounded Code API workspace-tools/execute client, advertising the workspace/ namespace only when an attached environment is selected, and routing read_file calls accordingly.

Changes:

  • Added a validated, size-bounded executeWorkspaceTool client for Code API workspace reads/search.
  • Updated agent tool registration to advertise workspace/{relativePath} + start_line/max_lines only for attached environments, and preserved upgrade behavior when skills are enabled mid-run.
  • Routed read_file calls with workspace/… paths to a new attached-workspace handler and added integration plumbing/tests through the legacy /api layer.
File summaries
File Description
packages/api/src/code/workspace.ts New Code API workspace-tools client with request/response validation and response-size bounds.
packages/api/src/code/workspace.spec.ts Unit tests covering auth forwarding, malformed results, and response bounding.
packages/api/src/code/index.ts Exports the new workspace module from the code package barrel.
packages/api/src/agents/tools.ts Adds workspaceTools flag and attached-workspace read_file schema/description.
packages/api/src/agents/tools.spec.ts Verifies attached-workspace read_file advertising and upgrade preservation.
packages/api/src/agents/skills.ts Threads workspaceTools through skill catalog injection/tool registration.
packages/api/src/agents/initialize.ts Enables workspaceTools only when the effective code env is attached.
packages/api/src/agents/handlers.ts Routes workspace/ reads to readWorkspaceFile and supports paginated line numbering.
packages/api/src/agents/handlers.spec.ts Tests routing, pagination behavior, gating to attached env only, and error redaction.
api/server/services/Files/Code/process.js Implements readWorkspaceFile that authenticates and calls executeWorkspaceTool.
api/server/services/Files/Code/process.spec.js Tests that attached-workspace reads forward auth/profile/worker identity correctly.
api/server/services/Endpoints/agents/skillDeps.js Exposes readWorkspaceFile as a stable dependency for agent handlers.
api/server/services/Endpoints/agents/skillDeps.spec.js Confirms the new dependency is surfaced through getSkillToolDeps().
Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

Comment thread packages/api/src/code/workspace.ts
Comment thread packages/api/src/agents/handlers.ts Outdated
@danny-avila
danny-avila force-pushed the danny-avila/code-workspace-tool-adapter branch from 3aad3af to 71289be Compare September 2, 2026 19:15
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review\n\nPlease review the current PR head 71289be. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-09-04T03:55:18.783146Z faec85b 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 71289be3fb

ℹ️ 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 changed the title 🧭 feat: Read Attached Workspace Files 🧳 feat: Read Files From Attached Workspaces Sep 2, 2026
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review\n\nPlease review the current PR head 71289be. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71289be3fb

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

Comment thread packages/api/src/agents/handlers.ts Outdated
Comment thread packages/api/src/code/workspace.ts
Comment thread packages/api/src/code/workspace.ts
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review the latest head

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 187d4e1780

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

Comment thread packages/api/src/agents/handlers.ts Outdated
Comment thread packages/api/src/code/workspace.ts
@danny-avila danny-avila changed the title 🧳 feat: Read Files From Attached Workspaces 👓 feat: Read Attached Workspace Files Sep 3, 2026
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review commit 2158f38

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 2158f385b3

ℹ️ 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 commit 2684e03 (supersedes the earlier head request)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2684e0310c

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

Comment thread packages/api/src/code/workspace.ts
Comment thread packages/api/src/code/workspace.ts
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head faec85b. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: faec85b4a4

ℹ️ 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 b7fd4ba into dev Sep 4, 2026
31 checks passed
@danny-avila
danny-avila deleted the danny-avila/code-workspace-tool-adapter branch September 4, 2026 13:58
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