Skip to content

Conversation

@benverhees
Copy link
Contributor

@benverhees benverhees commented Sep 4, 2025

Summary

This PR fixes an issue where file search citation markers were being output in file_search results, and the file_search tool description included instructions on using the citation markers for all users regardless of their permissions or configuration settings. The changes make citation functionality conditional based on both the user's FILE_CITATIONS permission and whether file citations are enabled in the configuration.

Key Changes:

  • Added fileCitations parameter to createFileSearchTool function to control citation marker output
  • Implemented permission checking using checkAccess to verify FILE_CITATIONS permission
  • Made citation anchor markers (\ue202turn0file${index}) conditional in search results
  • Made citation instructions in tool descriptions conditional based on user permissions and config settings

Problem Fixed:
The file search tool was including citation anchor markers (e.g., \ue202turn0file0, \ue202turn0file1) in file_search results, regardless of permissions or configuration settings. However, the actual UI components that would render these markers as clickable links to documents are only displayed for users with proper permissions and when fileCitations were enabled. This resulted in raw, non-functional citation markers in responses when file citations were disabled in the configuration.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

Test Process:

  1. Test with file citations enabled in configuration
  2. Test with file citations disabled in configuration
  3. Upload files and perform file searches in both scenarios
  4. Verify that:
    • When enabled: citation markers appear in file search results and context contains instructions about using citation markers
    • When disabled: no citation markers appear in file search results and context contains no instructions about using citation markers
    • File search functionality works correctly in both cases

Test Configuration:

  • File citations enabled/disabled in configuration

Checklist

Please delete any irrelevant options.

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • Local unit tests pass with my changes

@benverhees benverhees changed the title Fix/citation markers fix: Make file search citations markers conditional Sep 4, 2025
@danny-avila
Copy link
Owner

thanks for the PR!

@danny-avila danny-avila changed the title fix: Make file search citations markers conditional 🔍 fix: Conditionally Display File Search Citations Based on Permissions Sep 5, 2025
@danny-avila danny-avila changed the base branch from main to dev September 5, 2025 13:10
@danny-avila danny-avila changed the title 🔍 fix: Conditionally Display File Search Citations Based on Permissions 🔍 fix: Display File Search Citations Based on Permissions Sep 5, 2025
@danny-avila danny-avila merged commit eef9302 into danny-avila:dev Sep 5, 2025
5 checks passed
* @param {IUser} options.user - The user object
* @param {AppConfig} options.appConfig - The app configuration object
* @param {GraphRunnableConfig['configurable']} options.metadata - The metadata
* @param {any} options.toolArtifact - The tool artifact containing structured data
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danny-avila was this intentional?

Copy link
Owner

@danny-avila danny-avila Sep 5, 2025

Choose a reason for hiding this comment

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

I did intentionally add the JSDoc typing on the right-hand side of the git diff i.e.

* @param {{ [Tools.file_search]: { sources: Object[]; fileCitations: boolean } }} options.toolArtifact - The tool artifact containing structured data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I was confused, thinking there was a mismatch in naming, but I see now that the toolArtifact contains the file_search 😅

Copy link
Owner

Choose a reason for hiding this comment

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

no worries, thanks for inspecting the code!

mforman pushed a commit to mforman/LibreChat that referenced this pull request Sep 8, 2025
…a#9454)

* Make file search citations conditional

* refactor: improve permission handling to avoid redundant checks by including it in artifact

* chore: reorder imports for better organization and clarity

---------

Co-authored-by: Danny Avila <[email protected]>
mforman pushed a commit to mforman/LibreChat that referenced this pull request Sep 8, 2025
…a#9454)

* Make file search citations conditional

* refactor: improve permission handling to avoid redundant checks by including it in artifact

* chore: reorder imports for better organization and clarity

---------

Co-authored-by: Danny Avila <[email protected]>
arbreton pushed a commit to arbreton/LibreChat that referenced this pull request Oct 9, 2025
…a#9454)

* Make file search citations conditional

* refactor: improve permission handling to avoid redundant checks by including it in artifact

* chore: reorder imports for better organization and clarity

---------

Co-authored-by: Danny Avila <[email protected]>
Guiraud pushed a commit to Guiraud/LibreChat that referenced this pull request Nov 21, 2025
…a#9454)

* Make file search citations conditional

* refactor: improve permission handling to avoid redundant checks by including it in artifact

* chore: reorder imports for better organization and clarity

---------

Co-authored-by: Danny Avila <[email protected]>
patricksn3ll pushed a commit to patricksn3ll/LibreChat that referenced this pull request Dec 11, 2025
…a#9454)

* Make file search citations conditional

* refactor: improve permission handling to avoid redundant checks by including it in artifact

* chore: reorder imports for better organization and clarity

---------

Co-authored-by: Danny Avila <[email protected]>
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