Skip to content

fix: Use document store ID instead of name for referential integrity in agent flows #4874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

naaa760
Copy link

@naaa760 naaa760 commented Jul 15, 2025

Description
This PR fixes a critical bug where renaming a document store breaks existing agent flows that reference it. The issue was caused by storing the document store reference as a hardcoded string containing both ID and name (id:name), which breaks when the name changes.

#4868

Problem

  • Agent and Retriever components were storing document store references as ${store.id}:${store.name}
  • When users renamed a document store, the stored value in agent flows retained the old name
  • The UI couldn't match the stored value with the current list, causing the flow to break
  • This affected data integrity and user experience when managing document stores

Solution

  • Changed to store only the document store ID for proper referential integrity
  • Added backward compatibility to handle both formats:
    • Old format: id:name (splits the string to extract ID)
    • New format: id only (uses ID directly)
  • The current name is always fetched from the database when needed
  • Display name is shown in the UI while only ID is stored internally

Changes Made

Modified Files:

  • Agent.ts

    • Updated listStores method to return only ID in the name field
    • Added backward compatibility in the execute method to handle both old and new formats
  • Retriever.ts

    • Applied the same changes as Agent.ts for consistency
    • Handles both formats when extracting knowledge bases

Verified Components:

  • DocumentStore component - Already uses correct format (ID only)
  • DocumentStoreVS component - Already uses correct format (ID only)

Impact

  • Backward Compatible: Existing flows with old format will continue to work
  • Forward Compatible**: New flows will use the improved ID-only format
  • User Experience**: Users can now safely rename document stores without breaking flows
  • Data Integrity: Proper referential integrity maintained using IDs

Testing

  • Tested with existing flows using old format - works correctly
  • Created new flows with renamed document stores - works correctly
  • Verified no compilation errors or linter warnings

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.

1 participant