diff --git a/surfsense_backend/app/routes/__init__.py b/surfsense_backend/app/routes/__init__.py index 02367606b..5e3c84c8c 100644 --- a/surfsense_backend/app/routes/__init__.py +++ b/surfsense_backend/app/routes/__init__.py @@ -29,6 +29,7 @@ from .jira_add_connector_route import router as jira_add_connector_router from .linear_add_connector_route import router as linear_add_connector_router from .logs_routes import router as logs_router from .luma_add_connector_route import router as luma_add_connector_router +from .memory_routes import router as memory_router from .model_list_routes import router as model_list_router from .new_chat_routes import router as new_chat_router from .new_llm_config_routes import router as new_llm_config_router @@ -98,4 +99,5 @@ router.include_router(incentive_tasks_router) # Incentive tasks for earning fre router.include_router(stripe_router) # Stripe checkout for additional page packs router.include_router(youtube_router) # YouTube playlist resolution router.include_router(prompts_router) +router.include_router(memory_router) # User personal memory (memory.md style) router.include_router(autocomplete_router) # Lightweight autocomplete with KB context diff --git a/surfsense_backend/app/routes/search_spaces_routes.py b/surfsense_backend/app/routes/search_spaces_routes.py index 78be97aa1..6fd92fd18 100644 --- a/surfsense_backend/app/routes/search_spaces_routes.py +++ b/surfsense_backend/app/routes/search_spaces_routes.py @@ -5,6 +5,7 @@ from sqlalchemy import func from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.future import select +from app.agents.new_chat.tools.update_memory import MEMORY_HARD_LIMIT from app.config import config from app.db import ( ImageGenerationConfig, @@ -255,6 +256,13 @@ async def update_search_space( raise HTTPException(status_code=404, detail="Search space not found") update_data = search_space_update.model_dump(exclude_unset=True) + + if "shared_memory_md" in update_data and len(update_data["shared_memory_md"] or "") > MEMORY_HARD_LIMIT: + raise HTTPException( + status_code=400, + detail=f"Team memory exceeds {MEMORY_HARD_LIMIT:,} character limit.", + ) + for key, value in update_data.items(): setattr(db_search_space, key, value) await session.commit() diff --git a/surfsense_backend/app/schemas/search_space.py b/surfsense_backend/app/schemas/search_space.py index 054fe1465..e3b50be65 100644 --- a/surfsense_backend/app/schemas/search_space.py +++ b/surfsense_backend/app/schemas/search_space.py @@ -21,6 +21,7 @@ class SearchSpaceUpdate(BaseModel): description: str | None = None citations_enabled: bool | None = None qna_custom_instructions: str | None = None + shared_memory_md: str | None = None class SearchSpaceRead(SearchSpaceBase, IDModel, TimestampModel): @@ -29,6 +30,7 @@ class SearchSpaceRead(SearchSpaceBase, IDModel, TimestampModel): user_id: uuid.UUID citations_enabled: bool qna_custom_instructions: str | None = None + shared_memory_md: str | None = None model_config = ConfigDict(from_attributes=True)