refactor(agents): hardwire multi-agent as the only chat factory (bucket B1)

Make create_multi_agent_chat_deep_agent the unconditional agent factory in
all three streaming entry points (stream_new_chat monolith + new_chat/resume
flow orchestrators). Drop the MULTI_AGENT_CHAT_ENABLED branch and the now-unused
create_surfsense_deep_agent / _app_config imports. The single-agent
implementation (chat_deepagent.py, subagents/) is left in place; it is deleted
in a later phase. Suite green (2758 passed).
This commit is contained in:
CREDO23 2026-06-04 13:35:38 +02:00
parent 64d2ad6451
commit 724bbd6deb
3 changed files with 8 additions and 36 deletions

View file

@ -27,7 +27,6 @@ from langchain_core.messages import HumanMessage
from sqlalchemy.future import select
from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
from app.agents.new_chat.chat_deepagent import create_surfsense_deep_agent
from app.agents.shared.checkpointer import get_checkpointer
from app.agents.shared.context import SurfSenseContextSchema
from app.agents.shared.errors import BusyError
@ -1181,19 +1180,12 @@ async def stream_new_chat(
)
visibility = thread_visibility or ChatVisibility.PRIVATE
from app.config import config as _app_config
use_multi_agent = bool(_app_config.MULTI_AGENT_CHAT_ENABLED)
chat_agent_mode = "multi" if use_multi_agent else "single"
chat_agent_mode = "multi"
with contextlib.suppress(Exception):
chat_span.set_attribute("agent.mode", chat_agent_mode)
_t0 = time.perf_counter()
agent_factory = (
create_multi_agent_chat_deep_agent
if use_multi_agent
else create_surfsense_deep_agent
)
agent_factory = create_multi_agent_chat_deep_agent
# Build the agent inline. Provider 429s surface through the
# in-stream recovery loop below (``_is_provider_rate_limited``),
# which repins the thread to an eligible alternative config and
@ -2512,17 +2504,11 @@ async def stream_resume_chat(
)
visibility = thread_visibility or ChatVisibility.PRIVATE
from app.config import config as _app_config
chat_agent_mode = "multi" if _app_config.MULTI_AGENT_CHAT_ENABLED else "single"
chat_agent_mode = "multi"
with contextlib.suppress(Exception):
chat_span.set_attribute("agent.mode", chat_agent_mode)
_t0 = time.perf_counter()
agent_factory = (
create_multi_agent_chat_deep_agent
if _app_config.MULTI_AGENT_CHAT_ENABLED
else create_surfsense_deep_agent
)
agent_factory = create_multi_agent_chat_deep_agent
# Build the agent inline. Provider 429s are handled by the
# in-stream recovery loop, which repins to an eligible
# alternative config and rebuilds the agent before the user sees

View file

@ -30,10 +30,8 @@ from typing import Any, Literal
import anyio
from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
from app.agents.new_chat.chat_deepagent import create_surfsense_deep_agent
from app.agents.shared.filesystem_selection import FilesystemMode, FilesystemSelection
from app.agents.shared.middleware.busy_mutex import end_turn
from app.config import config as _app_config
from app.db import ChatVisibility, async_session_maker
from app.observability import otel as ot
from app.services.new_streaming_service import VercelStreamingService
@ -387,16 +385,11 @@ async def stream_new_chat(
)
visibility = thread_visibility or ChatVisibility.PRIVATE
use_multi_agent = bool(_app_config.MULTI_AGENT_CHAT_ENABLED)
chat_agent_mode = "multi" if use_multi_agent else "single"
chat_agent_mode = "multi"
set_agent_mode(chat_span, chat_agent_mode)
_t0 = time.perf_counter()
agent_factory = (
create_multi_agent_chat_deep_agent
if use_multi_agent
else create_surfsense_deep_agent
)
agent_factory = create_multi_agent_chat_deep_agent
# Build the agent inline. Provider 429s surface through the in-stream
# recovery loop below, which repins the thread to an eligible
# alternative config and rebuilds the agent before the user sees any

View file

@ -24,10 +24,8 @@ from uuid import UUID
import anyio
from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
from app.agents.new_chat.chat_deepagent import create_surfsense_deep_agent
from app.agents.shared.filesystem_selection import FilesystemMode, FilesystemSelection
from app.agents.shared.middleware.busy_mutex import end_turn
from app.config import config as _app_config
from app.db import ChatVisibility, async_session_maker
from app.observability import otel as ot
from app.services.chat_session_state_service import set_ai_responding
@ -326,16 +324,11 @@ async def stream_resume_chat(
)
visibility = thread_visibility or ChatVisibility.PRIVATE
use_multi_agent = bool(_app_config.MULTI_AGENT_CHAT_ENABLED)
chat_agent_mode = "multi" if use_multi_agent else "single"
chat_agent_mode = "multi"
set_agent_mode(chat_span, chat_agent_mode)
_t0 = time.perf_counter()
agent_factory = (
create_multi_agent_chat_deep_agent
if use_multi_agent
else create_surfsense_deep_agent
)
agent_factory = create_multi_agent_chat_deep_agent
agent = await build_main_agent_for_thread(
agent_factory,
llm=llm,