Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion py/core/base/agent/tools/built_in/get_file_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,23 @@ async def execute(

try:
doc_uuid = UUID(document_id)
filters = {"id": {"$eq": doc_uuid}}
doc_id_filter = {"id": {"$eq": doc_uuid}}
except ValueError:
logger.error(f"Invalid document_id format received: {document_id}")
return AggregateSearchResult(document_search_results=[])

# Merge search_settings filters (e.g., collection_ids) with the
# document_id filter so that collection-scoped queries are respected.
search_filters = (
getattr(context.search_settings, "filters", None)
if hasattr(context, "search_settings")
else None
)
if search_filters:
filters: dict[str, Any] = {"$and": [doc_id_filter, search_filters]}
else:
filters = doc_id_filter

options = options or {}

try:
Expand Down
3 changes: 3 additions & 0 deletions py/core/main/services/retrieval_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,7 @@ def _parse_user_and_collection_filters(
async def _build_documents_context(
self,
filter_user_id: Optional[UUID] = None,
filter_collection_ids: Optional[list[UUID]] = None,
max_summary_length: int = 128,
limit: int = 25,
reverse_order: bool = True,
Expand All @@ -1834,6 +1835,7 @@ async def _build_documents_context(
offset=0,
limit=limit,
filter_user_ids=[filter_user_id] if filter_user_id else None,
filter_collection_ids=filter_collection_ids if filter_collection_ids else None,
include_summary_embedding=False,
sort_order="DESC" if reverse_order else "ASC",
)
Expand Down Expand Up @@ -1910,6 +1912,7 @@ async def _build_aware_system_instruction(
if use_system_context:
doc_context_str = await self._build_documents_context(
filter_user_id=filter_user_id,
filter_collection_ids=filter_collection_ids,
)
logger.debug(f"Loading prompt {prompt_name}")
# Now fetch the prompt from the database prompts handler
Expand Down