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.
This commit is contained in:
CREDO23 2026-06-04 13:25:23 +02:00
parent a019f18d1c
commit 64d2ad6451
3 changed files with 16 additions and 2 deletions

View file

@ -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"]

View file

@ -27,7 +27,7 @@ from langchain.agents.middleware import (
from langchain_core.language_models import BaseChatModel from langchain_core.language_models import BaseChatModel
from langgraph.types import Checkpointer 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 ( from app.agents.shared.middleware import (
RetryAfterMiddleware, RetryAfterMiddleware,
create_surfsense_compaction_middleware, create_surfsense_compaction_middleware,

View file

@ -351,7 +351,7 @@ async def stream_anonymous_chat(
async def _generate(): async def _generate():
from langchain_core.messages import AIMessage, HumanMessage 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.agents.shared.checkpointer import get_checkpointer
from app.db import shielded_async_session from app.db import shielded_async_session
from app.services.new_streaming_service import VercelStreamingService from app.services.new_streaming_service import VercelStreamingService