From 64d2ad6451a69018d19b1feadc61df31c571c846 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Thu, 4 Jun 2026 13:25:23 +0200 Subject: [PATCH] refactor(agents): promote anonymous_agent to its own anonymous_chat/ package (slice 8) The anonymous / free-chat agent is a distinct live agent (not part of the single-agent stack and not shared infrastructure), so it gets its own top-level package app/agents/anonymous_chat/ (sibling to multi_agent_chat). Moved new_chat/anonymous_agent.py -> anonymous_chat/agent.py with a package __init__ re-exporting create_anonymous_chat_agent + build_anonymous_system_prompt. Repointed its only new_chat import (the context shim) to app.agents.shared.context and updated the single importer (anonymous_chat_routes). The test_import_all guard auto-discovers the new package via pkgutil.walk_packages, so it is covered. --- .../app/agents/anonymous_chat/__init__.py | 14 ++++++++++++++ .../anonymous_agent.py => anonymous_chat/agent.py} | 2 +- .../app/routes/anonymous_chat_routes.py | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 surfsense_backend/app/agents/anonymous_chat/__init__.py rename surfsense_backend/app/agents/{new_chat/anonymous_agent.py => anonymous_chat/agent.py} (99%) diff --git a/surfsense_backend/app/agents/anonymous_chat/__init__.py b/surfsense_backend/app/agents/anonymous_chat/__init__.py new file mode 100644 index 000000000..91d857dc5 --- /dev/null +++ b/surfsense_backend/app/agents/anonymous_chat/__init__.py @@ -0,0 +1,14 @@ +"""Anonymous / free-chat agent. + +The no-login chat experience: a deliberately minimal agent that bypasses the +full SurfSense deep-agent stack (filesystem, knowledge-base persistence, +subagents, skills, memory) and answers with an optional ``web_search`` tool and +an optional read-only uploaded document. See :mod:`.agent` for details. +""" + +from app.agents.anonymous_chat.agent import ( + build_anonymous_system_prompt, + create_anonymous_chat_agent, +) + +__all__ = ["build_anonymous_system_prompt", "create_anonymous_chat_agent"] diff --git a/surfsense_backend/app/agents/new_chat/anonymous_agent.py b/surfsense_backend/app/agents/anonymous_chat/agent.py similarity index 99% rename from surfsense_backend/app/agents/new_chat/anonymous_agent.py rename to surfsense_backend/app/agents/anonymous_chat/agent.py index b3eab37ca..24ad6487c 100644 --- a/surfsense_backend/app/agents/new_chat/anonymous_agent.py +++ b/surfsense_backend/app/agents/anonymous_chat/agent.py @@ -27,7 +27,7 @@ from langchain.agents.middleware import ( from langchain_core.language_models import BaseChatModel from langgraph.types import Checkpointer -from app.agents.new_chat.context import SurfSenseContextSchema +from app.agents.shared.context import SurfSenseContextSchema from app.agents.shared.middleware import ( RetryAfterMiddleware, create_surfsense_compaction_middleware, diff --git a/surfsense_backend/app/routes/anonymous_chat_routes.py b/surfsense_backend/app/routes/anonymous_chat_routes.py index f7e84be3c..1a283ef29 100644 --- a/surfsense_backend/app/routes/anonymous_chat_routes.py +++ b/surfsense_backend/app/routes/anonymous_chat_routes.py @@ -351,7 +351,7 @@ async def stream_anonymous_chat( async def _generate(): from langchain_core.messages import AIMessage, HumanMessage - from app.agents.new_chat.anonymous_agent import create_anonymous_chat_agent + from app.agents.anonymous_chat import create_anonymous_chat_agent from app.agents.shared.checkpointer import get_checkpointer from app.db import shielded_async_session from app.services.new_streaming_service import VercelStreamingService