-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
document_query Tool Returns 0 Results Despite Successful Chunking
Issue Description
The document_query tool successfully chunks uploaded documents but fails to retrieve any relevant content via vector search, always returning 0 results and falling back to full raw text retrieval. This defeats the purpose of the RAG-based document query functionality.
Environment
- Agent-Zero Version: Latest 0.9.7 (fresh container, deployed: 1/23/2026)
- Models:
- Chat/Utility/Web Browser: xAI Grok 4.1 Fast Reasoning
- Embeddings:
sentence-transformers/all-MiniLM-L6-v2(default, unchanged)
- API Keys: OpenAI and xAI configured
- Setup: Brand new container, only configuration changes made were setting models and API keys
Steps to Reproduce
- Create fresh agent-zero container
- Configure models in Model Settings:
- Set Chat, Utility, and Web Browser models to xAI Grok 4.1 Fast Reasoning
- Leave embeddings model at default (HuggingFace
sentence-transformers/all-MiniLM-L6-v2)
- Add OpenAI and xAI API keys in API Keys settings
- Upload document (PDF):
Best_Value_Selection.pdf - Query: "what are the management techniques to consider in best value selection?"
Expected Behavior
The document_query tool should:
- Chunk the document ✅ (works - 36 chunks created)
- Generate embeddings for chunks ✅ (works - 2 embedding files created, 8.2 KB each)
- Perform vector similarity search ❌ (returns 0 results)
- Return relevant chunks to answer the query ❌ (fails)
Actual Behavior
Added document 'file:///a0/tmp/uploads/Best_Value_Selection.pdf' with 36 chunks
Search 'best value selection management techniques methods strategies approaches procurement evaluation trade-off' returned 0 results
Search 'best value selection techniques considerations management procurement project key methods criteria evaluation value-based tender bidding' returned 0 results
!!! No content found for documents: ["/a0/tmp/uploads/Best_Value_Selection.pdf"] matching queries: ["What are the management techniques to consider in best value selection?", "List and describe key techniques or considerations for best value selection in management."]
The tool then falls back to retrieving the full document without queries.
Complete Interaction Log
First Interaction (Greeting)
User: Hi
Agent: Greeting user back
Tool: response
Result: "Hi there! How can I assist you today?"
Second Interaction (Document Query - ISSUE)
User: what are the management techniques to consider in best value selection?
Attachments: Best_Value_Selection.pdf
Agent Tool Call:
{
"thoughts": [
"User is asking about management techniques for best value selection, with a PDF attachment likely containing the info.",
"Best to query the document directly using document_query tool.",
"Query: 'What are the management techniques to consider in best value selection?' to get precise answers.",
"After results, summarize in a structured response."
],
"headline": "Analyzing PDF for best value selection management techniques",
"tool_name": "document_query",
"tool_args": {
"document": "/a0/tmp/uploads/Best_Value_Selection.pdf",
"queries": [
"What are the management techniques to consider in best value selection?",
"List and describe key techniques or considerations for best value selection in management."
]
}
}
Tool Output:
Added document 'file:///a0/tmp/uploads/Best_Value_Selection.pdf' with 36 chunks
Search 'best value selection management techniques methods strategies approaches procurement evaluation trade-off' returned 0 results
Search 'best value selection techniques considerations management procurement project key methods criteria evaluation value-based tender bidding' returned 0 results
!!! No content found for documents: ["/a0/tmp/uploads/Best_Value_Selection.pdf"] matching queries: [...]
Agent Fallback (second attempt):
{
"thoughts": [
"Previous document_query with queries found no matching content.",
"Now fetching full document content without queries to inspect what's in the PDF.",
"If empty or irrelevant, will search web next.",
"PDF path confirmed from attachment."
],
"headline": "Retrieving full content from Best_Value_Selection.pdf",
"tool_name": "document_query",
"tool_args": {
"document": "/a0/tmp/uploads/Best_Value_Selection.pdf"
}
}
Analysis
The issue appears to be in the vector similarity search pipeline:
- ✅ Document Loading: Document is successfully loaded
- ✅ Chunking: 36 chunks created successfully
- ✅ Embedding Generation: Confirmed working - 2 embedding files created (8.2 KB each, HuggingFace sentence-transformers format)
- ❌ Vector Search: Returns 0 results for highly relevant queries
⚠️ Fallback: System falls back to raw text retrieval
Critical Finding: Embeddings ARE being generated and stored correctly. The problem is specifically in the vector similarity search/retrieval mechanism, not in the embedding generation pipeline.
Potential Root Causes
- Similarity Threshold Too Restrictive: Search threshold may be set too high, rejecting all matches
- Vector Search Algorithm Issue: The cosine similarity or distance calculation may be broken/misconfigured
- Vector Store Query Issue: The vector database query mechanism may not be properly retrieving/comparing embeddings
- Embedding Dimensionality Mismatch: Query embeddings and chunk embeddings may have different dimensions
- Index Not Built/Updated: The vector index may not be built correctly after embedding generation
Questions
- ✅ Are embeddings being generated? YES - confirmed via file system (2 files, 8.2 KB each)
- What is the configured similarity threshold for vector search?
- What vector store/search implementation is being used (FAISS, ChromaDB, etc.)?
- Can you provide debug logs showing the vector search query process?
- Are the query embeddings being generated with the same model/parameters as chunk embeddings?
- Is the vector index being properly built/loaded after embedding generation?
Expected Fix
The document_query tool should successfully retrieve relevant chunks via vector similarity search, eliminating the need for raw text fallback except in edge cases where truly no relevant content exists.
Additional Context
This is a fresh installation test - no custom modifications, extensions, or previous usage. This behavior occurs on the very first document query attempt, suggesting a default configuration or initialization issue rather than a corruption or state problem.
Evidence of embedding generation: File system shows 2 embedding files were created successfully:
huggingface_sentence-transformers_all-MiniLM-L6-v20b010d60-ef0b-5ce0-bbc6-56774988177d4(8.2 KB, added 26 minutes ago)huggingface_sentence-transformers_all-MiniLM-L6-v2798ab3a8-fa91-59ab-b571-10b6425e8587(8.2 KB, added 26 minutes ago)
This confirms the embedding pipeline works correctly, isolating the issue to the vector search/retrieval mechanism.
Workaround
Currently, the system falls back to full document retrieval which works but:
- Defeats the purpose of RAG/chunking
- May hit token limits with large documents
- Loses the benefits of semantic search
- Reduces response quality and accuracy