feat: add run-scoped file sharing for subagents - #15848
Conversation
Delegate current-message files through authorized execution catalogs and publish selected immutable code-output versions through the existing file pipeline. Requires the companion agents SDK context adapter before the dependency can be released and pinned.
Keep citations and other non-sandbox artifacts on their existing delivery path while retaining private code outputs and inspected images until publication. Cover native and text delivery, nested and sibling authorization, concurrent runs, cancellation cleanup, and checkpoint recovery through the browser harness.
|
@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: dc656be12a
ℹ️ 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: 4bd39ebe8c
ℹ️ 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".
| const outputPersistence = createCodeOutputPersistence({ | ||
| publication, | ||
| claim: claimCodeFile, | ||
| commit: commitCodeFile, | ||
| }); |
There was a problem hiding this comment.
Move publication behavior out of the CJS service
Move this publication persistence orchestration into packages/api and leave process.js as a thin adapter. The change makes an /api CJS module select and coordinate the publication-specific claim/commit path, directly violating the repository boundary that newly added branches, validation, and service calls belong in the TypeScript workspace; retaining it here also leaves this new storage behavior outside that workspace's typechecked boundary.
AGENTS.md reference: AGENTS.md:L53-L57
Useful? React with 👍 / 👎.
Summary
Subagents currently cannot reliably consume the files attached to the current message or return generated files as durable conversation attachments. This adds opt-in, run-scoped sharing on top of unified upload (#15763): authorized children receive the current message's files, can inspect and refine private sandbox outputs across multiple code calls, and explicitly publish a chosen output version for the parent and user.
Fixes #14261.
SDK dependency included: danny-avila/agents#539 is merged and published in
@librechat/agents3.8.6. Both dependency manifests require^3.8.6, and the lockfile installs registry version 3.8.6, which exposesSUBAGENT_CONTEXT_VERSION = 1. A normal locked install includes the required adapter; no local SDK build is needed.How it works
The host owns file authorization, persistence and cleanup; the SDK carries a distinct execution context through child runs and tool dispatch.
sequenceDiagram participant User participant Parent participant Child participant Files as Run catalog and file storage User->>Parent: Attach a PDF and request delegated analysis Parent->>Child: Delegate with authorized current-message files Child->>Files: Lazily provision input for search or code Child->>Child: Generate, inspect and refine private output versions Child->>Files: list_run_files, then publish_artifact(artifact_id) Files-->>Parent: Durable file ID and conversation attachment Parent-->>User: Downloadable CSV or reportpackages/api/src/agents/files/owns the run manifest, per-execution sandbox context, immutable private snapshots and SDK adapter. Existing provider/text delivery and lazy search/code provisioning remain the input paths; agent setup files keep their existing scope.list_run_filesandpublish_artifactare added only to participating delegating agents and child executions. Generated files remain private until publication succeeds. Separate artifact IDs select immutable versions, including versions of the same filename; a parent cannot publish a child's private outputs.endpoints.agents.fileSharingexposes the deployment toggle, sibling policy, file count, private-byte budget and lifetime inlibrechat.yaml. The localized Share files with subagents agent setting also requires opt-in. Both toggles default off and existing saved agents need no migration.Current support is foreground chat delegation with managed code environments and teams using the same provider, endpoint, model and Responses API setting. Shared-file runs reject detached/background execution, attached workstation environments and entry points without the host adapter. Configuration, lifecycle and support details are in docs/run_files.md.
Change Type
Testing
Verified locally at LibreChat
4bd39ebe8cc794b98d11f4b7106067f2e1026448, including upstreamdevate7dea565d1fdf6f90ecae8945a8efd614a93c954, using a clean registry install of SDK 3.8.6:npx tsc --noEmitchecks passed. Formatting, package/dependency validation, circular dependency checks, config migration and i18n checks passed.npm ci, package builds and the production application build passed. The installed SDK version, capability version and registry integrity are verified before the checks; manifests and lockfile remain unchanged.npm run lighthousepassed with the 250 ms Mongo query penalty: median LCP 3,847 ms / 4,500 ms, CLS 0.0371 / 0.1, TBT 96 ms / 500 ms. All three cold navigations rendered the seeded conversation transcript.Current feature validation uses the published npm package throughout, without replacing its files or rebuilding SDK source.
GitHub CI at this head completed with 31 successful checks, five skipped and no failures. All executed workflows passed, including backend/frontend tests, typechecks, static checks, integrations, production Docker smoke and Lighthouse. Remote Playwright and Bombadil were skipped by their contributor-association guards; the local file-sharing browser results above cover both memory and Redis.
Earlier broader validation at LibreChat
dc656be12a7a6c224342c710028f8892c4ff4a31with the development SDK atc5f3f99ecovered all six unit workspaces (31,381 passing tests, 27 existing skips, combining full runs and successful focused retries), 229 browser cases per memory/Redis topology, Redis standalone/cluster and agent Mongo/Redis integrations, S3-compatible storage, Redis transport, MCP topologies and production Docker runtime checks. Those complete selections were not all repeated locally at the current head.The branch also repairs fixtures exercised by those checks: partial mocks retain real exports, Redis teardown closes both clients, LibreOffice has a real PPTX and malformed OOXML fixture, and deployment-skill download assertions compare checked-out bytes across LF/CRLF formats.
Earlier optional validation recorded seven Langfuse admin expectations failing identically at the branch base. Non-blocking Bombadil exploration failed a sidebar navigation property after list reordering; its assertion retained the old row number although the requested conversation opened. The relevant code matched base, but that exploratory run remains failed. Those optional checks were not repeated with SDK 3.8.6. Three browser cases require stateful/paired Code API protocols unavailable locally. Other credential/protocol guards and upstream secret-backed accessibility review remain unverified.
Test Configuration
Node 24.16.0 / npm 11.13.0; isolated Linux runs, Chrome and disposable MongoDB/Redis. Browser scenarios use the real app and released SDK 3.8.6 with deterministic model, Code API and RAG fixtures. Earlier SDK live-provider checks used Azure OpenAI.
Run
npm ciand follow the run-file setup and the browser harness setup, then run from the LibreChat root:Use the canonical upstream
devref if your remote is named differently. In a live session, enable deployment file sharing and the parent agent's subagent setting, attach a PDF, and ask a child to analyze it, refine a CSV in another code call, then publish the selected version. Verify download and follow-up attachment reuse; an agent without sharing enabled should not receive the two tools.Checklist