Skip to content

💬 fix(api): respect configured fileLimit for code output when inspection is disabled - #16977

Closed
tek123168 wants to merge 1 commit into
LibreChat-AI:devfrom
tek123168:fix/code-output-preflight-file-limit
Closed

tek123168 wants to merge 1 commit into
LibreChat-AI:devfrom
tek123168:fix/code-output-preflight-file-limit

Conversation

@tek123168

@tek123168 tek123168 commented Oct 10, 2026 •

Copy link
Copy Markdown

Fixes #16919

Summary

When a code execution run generates more than 10 files (for example, rendering presentation slides or multi-page documents), outputs were bypassing preflight preparation and falling back to raw download handling even when content inspection was disabled (inspectionActive = false) and a higher fileLimit was configured.

Root Cause

In preflightCodeOutputBatch, a hardcoded preflight limit check capped output preparation at 10 files unconditionally, forcing files above 10 into download fallbacks without image previews or dimensions. In addition, the in-memory buffer cache in process.js had a fixed capacity of 10 items, which could cause early buffer eviction during higher volume batches.

Changes

  • Preflight Batch Logic: In packages/api/src/files/code/preflight.ts, rely strictly on configuredCountExceeded when inspectionActive is false. When inspection is active, line 154 continues to enforce CODE_OUTPUT_PREFLIGHT_MAX_COUNT safely.
  • Buffer Cache Scaling: In api/server/services/Files/Code/process.js, allow cachePreparedCodeOutputBuffer capacity to scale with the active endpoint fileLimit (defaulting to 10 when unconfigured) to prevent buffer eviction during larger runs.
  • Unit Tests: Updated unit tests in packages/api/src/files/code/preflight.spec.ts to verify that outputs above 10 are prepared when fileLimit permits without inspection, and fall back to URL downloads only when fileLimit is exceeded.

@github-actions
github-actions Bot changed the base branch from main to dev October 10, 2026 20:54
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for the contribution! LibreChat merges all changes into dev first — main only moves at release time — so this pull request's base branch was switched from main to dev automatically.

Nothing is needed from you; your commits, reviews and discussion are unchanged. If the diff now shows files you did not touch, rebase onto dev:

git remote add upstream https://github.com/LibreChat-AI/LibreChat.git
git fetch upstream dev
git rebase upstream/dev
git push --force-with-lease

Maintainers: apply the target: main label and restore the base branch if this one genuinely belongs on main.

@tek123168
tek123168 force-pushed the fix/code-output-preflight-file-limit branch from c44cc7d to f7e6a42 Compare October 10, 2026 20:55
…nactive

Fixes LibreChat-AI#16919

- Rely on configuredMaxCount when inspectionActive is false
- Remove redundant inspectionCountExceeded check in preflightCodeOutputBatch
- Allow cachePreparedCodeOutputBuffer capacity to scale with configured fileLimit
- Update preflight unit tests to cover batches exceeding default count with active fileLimit
@tek123168
tek123168 force-pushed the fix/code-output-preflight-file-limit branch from f7e6a42 to 74431ec Compare October 10, 2026 21:05
@tek123168 tek123168 changed the title fix(api): respect configured fileLimit for code output when inspection is disabled 💬 fix(api): respect configured fileLimit for code output when inspection is disabled Oct 10, 2026
@tek123168

Copy link
Copy Markdown
Author

Closing this pull request to consolidate my open-source contributions under my primary GitHub account (@taieddie). I have re-submitted this PR directly from @taieddie targeting dev: #16978. Apologies for any notification noise!

@tek123168 tek123168 closed this Oct 10, 2026
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.

[Bug]: A code run with more than 10 outputs stores none of them, even with no content inspection and a higher fileLimit

1 participant