What happened?
When a user attaches a file via "Upload for File Search" while chatting with a shared agent (an agent with its own file_search knowledge base), the file_search tool never returns results from the newly attached file — only chunks from the agent's knowledge base come back. The model then answers "I couldn't find this information", even though the file was uploaded and embedded successfully.
Steps to Reproduce
- Configure RAG (rag_api) and create an agent with at least one file in its file_search tool resource (the "knowledge base").
- Share the agent with another user (or use any flow where
entity_id is set).
- As a regular user, start a chat with that agent, attach a small
.txt via Upload for File Search, wait for embedding to finish.
- Ask a question whose answer is only in the attached file.
Expected: the attached file's chunks appear in the tool results.
Actual: only knowledge-base files are returned; the attached file yields zero results in every query.
Root cause
createFileSearchTool (api/app/clients/tools/util/fileSearch.js) sends the agent's entity_id in every /query request to the RAG API:
const body = { file_id: file.file_id, query, k: 5 };
if (!entity_id) {
return body;
}
body.entity_id = entity_id;
But user-attached files are embedded by rag_api under the user id (no entity), while only knowledge-base files are embedded under the agent's entity_id. When the query carries entity_id, rag_api filters the vectors by that entity and returns [] for the user's file.
Verified by querying rag_api directly for a user-attached file:
- without
entity_id → 1 result (chunk found)
- with
entity_id=<agent_id> → 0 results
The HTTP layer hides this completely: both queries return 200, so the tool "succeeds" with an empty set for the attachment.
Proposed fix
primeFiles already knows which files belong to the agent's knowledge base (agentResourceIds). Tag each file with that origin and only send entity_id for knowledge-base files:
primeFiles: files.push({ file_id, filename, fromAgent: agentResourceIds.has(file.file_id) })
createQueryBody: if (!entity_id || file.fromAgent === false) return body;
Using an explicit fromAgent === false check keeps the previous behavior for any caller that doesn't set the flag. PR with tests incoming.
Version Information
Reproduced on v0.8.6 (the affected code in api/app/clients/tools/util/fileSearch.js is unchanged on current main as of 2026-06-11).
Relevant log output
# Direct RAG API query for a freshly user-attached file (embedding completed):
# without entity_id:
POST /query {"file_id":"2d6a3de3-...","query":"...","k":8}
-> 200, 1 result (chunk found)
# with the agent's entity_id (what file_search sends today):
POST /query {"file_id":"2d6a3de3-...","query":"...","k":8,"entity_id":"agent_..."}
-> 200, [] (empty)
Both requests return 200, so the tool reports "No results found" for the
attachment while the knowledge-base files keep answering — nothing in the
logs points at the entity filter.
What browsers are you seeing the problem on?
Not browser-related (server-side tool behavior).
What happened?
When a user attaches a file via "Upload for File Search" while chatting with a shared agent (an agent with its own file_search knowledge base), the
file_searchtool never returns results from the newly attached file — only chunks from the agent's knowledge base come back. The model then answers "I couldn't find this information", even though the file was uploaded and embedded successfully.Steps to Reproduce
entity_idis set)..txtvia Upload for File Search, wait for embedding to finish.Expected: the attached file's chunks appear in the tool results.
Actual: only knowledge-base files are returned; the attached file yields zero results in every query.
Root cause
createFileSearchTool(api/app/clients/tools/util/fileSearch.js) sends the agent'sentity_idin every/queryrequest to the RAG API:But user-attached files are embedded by rag_api under the user id (no entity), while only knowledge-base files are embedded under the agent's
entity_id. When the query carriesentity_id, rag_api filters the vectors by that entity and returns[]for the user's file.Verified by querying rag_api directly for a user-attached file:
entity_id→ 1 result (chunk found)entity_id=<agent_id>→ 0 resultsThe HTTP layer hides this completely: both queries return 200, so the tool "succeeds" with an empty set for the attachment.
Proposed fix
primeFilesalready knows which files belong to the agent's knowledge base (agentResourceIds). Tag each file with that origin and only sendentity_idfor knowledge-base files:primeFiles:files.push({ file_id, filename, fromAgent: agentResourceIds.has(file.file_id) })createQueryBody:if (!entity_id || file.fromAgent === false) return body;Using an explicit
fromAgent === falsecheck keeps the previous behavior for any caller that doesn't set the flag. PR with tests incoming.Version Information
Reproduced on v0.8.6 (the affected code in
api/app/clients/tools/util/fileSearch.jsis unchanged on currentmainas of 2026-06-11).Relevant log output
Both requests return 200, so the tool reports "No results found" for the
attachment while the knowledge-base files keep answering — nothing in the
logs points at the entity filter.
What browsers are you seeing the problem on?
Not browser-related (server-side tool behavior).