From b043911325c1f39af962e5487f15520b12ceb624 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 24 Jun 2026 22:54:58 +0200 Subject: [PATCH] references: route @chat through chat/ slice --- .../chat/runtime/references/__init__.py | 2 +- .../agents/chat/runtime/references/chats.py | 44 ------------------- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 surfsense_backend/app/agents/chat/runtime/references/chats.py diff --git a/surfsense_backend/app/agents/chat/runtime/references/__init__.py b/surfsense_backend/app/agents/chat/runtime/references/__init__.py index dfbb22da3..51e543ccc 100644 --- a/surfsense_backend/app/agents/chat/runtime/references/__init__.py +++ b/surfsense_backend/app/agents/chat/runtime/references/__init__.py @@ -11,7 +11,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from app.agents.chat.runtime.path_resolver import build_path_index from app.schemas.new_chat import MentionedDocumentInfo -from .chats import resolve_chat_references +from .chat import resolve_chat_references from .connectors import resolve_connector_references from .documents import resolve_document_references from .folders import resolve_folder_references diff --git a/surfsense_backend/app/agents/chat/runtime/references/chats.py b/surfsense_backend/app/agents/chat/runtime/references/chats.py deleted file mode 100644 index be9d1025c..000000000 --- a/surfsense_backend/app/agents/chat/runtime/references/chats.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Resolve ``@chat`` mentions into pointer references. - -Chats are not KB-indexed, so a chat reference is a pointer only; its turns are -read on demand via the chat read tool, not injected here. Access checking is -delegated to the authoritative referenced-chat resolver so the rules live in one -place. -""" - -from __future__ import annotations - -from sqlalchemy.ext.asyncio import AsyncSession - -from app.agents.chat.runtime.referenced_chat_context.resolver import ( - resolve_referenced_chats, -) - -from .models import ChatReference - - -async def resolve_chat_references( - session: AsyncSession, - *, - search_space_id: int, - requesting_user_id: str | None, - current_chat_id: int, - thread_ids: list[int], -) -> list[ChatReference]: - """Map ``@chat`` thread ids to access-checked pointers (titles only).""" - if not thread_ids: - return [] - - chats = await resolve_referenced_chats( - session, - search_space_id=search_space_id, - requesting_user_id=requesting_user_id, - current_chat_id=current_chat_id, - mentioned_thread_ids=thread_ids, - ) - return [ - ChatReference(entity_id=chat.thread_id, label=chat.title) for chat in chats - ] - - -__all__ = ["resolve_chat_references"]