Skip to content

fix: preserve metadata in RetrieverTool when using Custom Retriever#6243

Open
limbergarcia wants to merge 4 commits intoFlowiseAI:mainfrom
limbergarcia:fix/retriever-metadata
Open

fix: preserve metadata in RetrieverTool when using Custom Retriever#6243
limbergarcia wants to merge 4 commits intoFlowiseAI:mainfrom
limbergarcia:fix/retriever-metadata

Conversation

@limbergarcia
Copy link
Copy Markdown

🐛 Bug Description

When using Custom Retriever with Retriever Tool, metadata from vector store (e.g. Qdrant) is lost and only pageContent is preserved.

Root Cause

CustomRetriever overrides getRelevantDocuments() and returns formatted documents, but RetrieverTool internally calls retriever.invoke(), which uses LangChain's _getRelevantDocuments() instead.

This causes:

  • Custom formatting to be ignored
  • Metadata handling inconsistency

Fix

Updated CustomRetriever to ensure compatibility with LangChain's invoke() flow and preserve metadata correctly.

Steps to Reproduce

  1. Use Qdrant vector store with metadata
  2. Connect:
    Qdrant → CustomRetriever → RetrieverTool → Agent
  3. Query documents
  4. Metadata is missing in response

Expected Behavior

Metadata fields like:

  • filename
  • url
  • blobType

should be preserved and accessible in the final output.

🔗 Related Issue

Closes #6242

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the CustomRetriever class by delegating document retrieval to a new _getRelevantDocuments method and ensuring resultFormat defaults to a standard value. A review comment correctly identifies a potential issue where special replacement patterns in pageContent could cause unexpected behavior during string replacement, suggesting a functional approach to ensure literal interpretation.

Comment thread packages/components/nodes/retrievers/CustomRetriever/CustomRetriever.ts Outdated
limbergarcia and others added 3 commits April 17, 2026 16:38
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.

Metadata lost when using Custom Retriever with Retriever Tool in Agent (Qdrant)

1 participant