Skip to content

feat(rag): Add folder-scoped search filter #662

Closed

Description

@larryro

Summary

Add an optional folder_path filter parameter to the RAG search API, allowing search results to be scoped to documents within a specific folder hierarchy. Currently, RAG search is scoped only by team_id — there is no way to restrict results to a particular folder.

Motivation

Users organize documents into folders (e.g., /templates, /data-room/project-alpha). When asking the AI to "find precedents in folder X" or "search only within the data room", the system should be able to restrict search results to that folder scope.

Proposed Changes

RAG Search API

Add optional folder_path parameter to POST /api/v1/search:

{
  "query": "change of control clause",
  "team_id": "team_123",
  "folder_path": "/data-room/project-alpha",
  "top_k": 10
}

When folder_path is provided, only return results from documents whose path starts with the given prefix (hierarchical matching).

Database Changes

  • Ensure folder_path is stored in private_knowledge.documents during ingestion
  • The folder path should be passed from the platform when uploading documents to RAG
  • Add an index on (team_id, folder_path) if needed for performance

Platform Side

  • Update the RAG upload action to include folder path from document metadata
  • Update rag_search_tool.ts to accept an optional folderPath parameter
  • Update query_rag_context.ts if folder-scoped auto-injection is desired

Acceptance Criteria

  • RAG search API accepts optional folder_path parameter
  • Results correctly filtered to matching folder prefix
  • Folder path stored during document ingestion
  • rag_search agent tool supports folderPath parameter
  • Tests covering: folder filtering, nested folder matching, no folder (existing behavior unchanged)

Activity

  1. added
    priority: medium
    feat
    service: rag
    on Mar 4, 2026
  2. yannickmonney commented on Apr 7, 2026

    @yannickmonney
    Contributor

    This requires changes to the RAG service Python API (services/rag/). The folder_path parameter needs to be added to the search endpoint and the vector query needs to support metadata filtering by folder path.

  3. yannickmonney commented on May 31, 2026

    @yannickmonney
    Contributor

    Triaged — valid feature, keeping open. Confirmed there's no folder_path filter in the RAG search API today (only query / team_id / top_k). This would add an optional folder-prefix filter so search can be scoped to a folder hierarchy — spanning the RAG Python API (vector metadata filtering) and the platform RAG tool. Assigned to me. Related metadata-filtering work: #1517.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featpriority: mediumservice: platformservice: rag

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions