mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
refactor(agents): introduce chat/ category; dissolve top-level agents/shared
Recursive shared-folder rule: a shared/ must be shared by ALL siblings at its
level. The kernel (context, compaction, retry_after, web_search) was shared by
only 2 of the agents -- anonymous_chat + multi_agent_chat -- never by podcaster
or video_presentation. Those 2 are the "chat" category, so their shared code
belongs in that category's shared/, not the top-level one.
app/agents/anonymous_chat/ -> app/agents/chat/anonymous_chat/
app/agents/multi_agent_chat/ -> app/agents/chat/multi_agent_chat/
app/agents/shared/ -> app/agents/chat/shared/ (anon<->mac kernel)
Top-level app/agents/shared/ is gone: nothing was shared across all three
categories (chat / podcaster / video_presentation).
~289 import sites rewritten (app.agents.{anonymous_chat,multi_agent_chat,shared}
-> app.agents.chat.*); all moves are git renames (history preserved).
app/agents/ now: chat/, podcaster/, video_presentation/, runtime/.
This commit is contained in:
parent
d59bb2b5aa
commit
24b62a63b4
570 changed files with 712 additions and 613 deletions
|
|
@ -9,8 +9,10 @@ from __future__ import annotations
|
|||
|
||||
from typing import Any
|
||||
|
||||
from app.agents.multi_agent_chat.shared.filesystem_selection import FilesystemSelection
|
||||
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import (
|
||||
FilesystemSelection,
|
||||
)
|
||||
from app.agents.chat.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.db import ChatVisibility
|
||||
from app.services.connector_service import ConnectorService
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ from __future__ import annotations
|
|||
from collections.abc import AsyncGenerator
|
||||
from typing import Any
|
||||
|
||||
from app.agents.multi_agent_chat.shared.filesystem_selection import FilesystemMode
|
||||
from app.agents.multi_agent_chat.shared.middleware.kb_persistence import (
|
||||
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import FilesystemMode
|
||||
from app.agents.chat.multi_agent_chat.shared.middleware.kb_persistence import (
|
||||
commit_staged_filesystem_state,
|
||||
)
|
||||
from app.services.new_streaming_service import VercelStreamingService
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import logging
|
|||
import time
|
||||
from typing import Any, Literal
|
||||
|
||||
from app.agents.multi_agent_chat.shared.errors import BusyError
|
||||
from app.agents.multi_agent_chat.shared.middleware.busy_mutex import (
|
||||
from app.agents.chat.multi_agent_chat.shared.errors import BusyError
|
||||
from app.agents.chat.multi_agent_chat.shared.middleware.busy_mutex import (
|
||||
get_cancel_state,
|
||||
is_cancel_requested,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ from langchain_core.messages import HumanMessage
|
|||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.future import select
|
||||
|
||||
from app.agents.multi_agent_chat.shared.filesystem_selection import FilesystemMode
|
||||
from app.agents.multi_agent_chat.shared.mention_resolver import (
|
||||
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import FilesystemMode
|
||||
from app.agents.chat.multi_agent_chat.shared.mention_resolver import (
|
||||
resolve_mentions,
|
||||
substitute_in_text,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ tells the user what to change.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.agents.chat.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.observability import otel as ot
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ from typing import Any, Literal
|
|||
|
||||
import anyio
|
||||
|
||||
from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
|
||||
from app.agents.multi_agent_chat.shared.filesystem_selection import (
|
||||
from app.agents.chat.multi_agent_chat import create_multi_agent_chat_deep_agent
|
||||
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import (
|
||||
FilesystemMode,
|
||||
FilesystemSelection,
|
||||
)
|
||||
from app.agents.multi_agent_chat.shared.middleware.busy_mutex import end_turn
|
||||
from app.agents.chat.multi_agent_chat.shared.middleware.busy_mutex import end_turn
|
||||
from app.db import ChatVisibility, async_session_maker
|
||||
from app.observability import otel as ot
|
||||
from app.services.new_streaming_service import VercelStreamingService
|
||||
|
|
@ -829,7 +829,7 @@ async def stream_new_chat(
|
|||
# downloadable after the Daytona sandbox auto-deletes.
|
||||
if stream_result and stream_result.sandbox_files:
|
||||
with contextlib.suppress(Exception):
|
||||
from app.agents.multi_agent_chat.shared.sandbox import (
|
||||
from app.agents.chat.multi_agent_chat.shared.sandbox import (
|
||||
is_sandbox_enabled,
|
||||
persist_and_delete_sandbox,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ mention lists / request ids / turn ids without rebuilding the graph.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.agents.shared.context import SurfSenseContextSchema
|
||||
from app.agents.chat.shared.context import SurfSenseContextSchema
|
||||
|
||||
|
||||
def build_new_chat_runtime_context(
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ from app.prompts import TITLE_GENERATION_PROMPT
|
|||
from app.services.new_streaming_service import VercelStreamingService
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.agents.chat.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.services.token_tracking_service import TokenAccumulator
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ from uuid import UUID
|
|||
|
||||
import anyio
|
||||
|
||||
from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
|
||||
from app.agents.multi_agent_chat.shared.filesystem_selection import (
|
||||
from app.agents.chat.multi_agent_chat import create_multi_agent_chat_deep_agent
|
||||
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import (
|
||||
FilesystemMode,
|
||||
FilesystemSelection,
|
||||
)
|
||||
from app.agents.multi_agent_chat.shared.middleware.busy_mutex import end_turn
|
||||
from app.agents.chat.multi_agent_chat.shared.middleware.busy_mutex import end_turn
|
||||
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
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ async def build_resume_routing(
|
|||
``surfsense_resume_value`` configurable; parallel siblings each pop their
|
||||
own entry so they never race.
|
||||
"""
|
||||
from app.agents.multi_agent_chat.main_agent.middleware.checkpointed_subagent_middleware.resume_routing import (
|
||||
from app.agents.chat.multi_agent_chat.main_agent.middleware.checkpointed_subagent_middleware.resume_routing import (
|
||||
build_lg_resume_map,
|
||||
collect_pending_tool_calls,
|
||||
slice_decisions_by_tool_call,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ can rely on ``runtime.context`` always being populated.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.agents.shared.context import SurfSenseContextSchema
|
||||
from app.agents.chat.shared.context import SurfSenseContextSchema
|
||||
|
||||
|
||||
def build_resume_chat_runtime_context(
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from typing import Any
|
|||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.agents.multi_agent_chat.shared.llm_config import (
|
||||
from app.agents.chat.multi_agent_chat.shared.llm_config import (
|
||||
AgentConfig,
|
||||
create_chat_litellm_from_agent_config,
|
||||
create_chat_litellm_from_config,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from dataclasses import dataclass
|
|||
from typing import TYPE_CHECKING
|
||||
from uuid import UUID
|
||||
|
||||
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.agents.chat.multi_agent_chat.shared.llm_config import AgentConfig
|
||||
from app.db import shielded_async_session
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from typing import Literal
|
|||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.agents.multi_agent_chat.shared.middleware.busy_mutex import end_turn
|
||||
from app.agents.chat.multi_agent_chat.shared.middleware.busy_mutex import end_turn
|
||||
from app.observability import otel as ot
|
||||
from app.services.auto_model_pin_service import (
|
||||
mark_runtime_cooldown,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from __future__ import annotations
|
|||
from collections.abc import AsyncGenerator, Awaitable, Callable
|
||||
from typing import Any
|
||||
|
||||
from app.agents.multi_agent_chat.shared.filesystem_selection import FilesystemMode
|
||||
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import FilesystemMode
|
||||
from app.services.new_streaming_service import VercelStreamingService
|
||||
from app.tasks.chat.streaming.agent.event_loop import stream_agent_events
|
||||
from app.tasks.chat.streaming.shared.stream_result import StreamResult
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import traceback
|
|||
from collections.abc import Iterator
|
||||
from typing import Any, Literal
|
||||
|
||||
from app.agents.multi_agent_chat.shared.errors import BusyError
|
||||
from app.agents.chat.multi_agent_chat.shared.errors import BusyError
|
||||
from app.observability import metrics as ot_metrics, otel as ot
|
||||
from app.services.new_streaming_service import VercelStreamingService
|
||||
from app.tasks.chat.streaming.errors.classifier import classify_stream_exception
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ def _unwrap_command_output(raw_output: Any) -> Any:
|
|||
"""Replace a ``Command`` from a tool return with its inner ``ToolMessage``.
|
||||
|
||||
Tools that participate in receipt-style state writes (see
|
||||
``app.agents.multi_agent_chat.shared.receipts.command.with_receipt``) return a
|
||||
``app.agents.chat.multi_agent_chat.shared.receipts.command.with_receipt``) return a
|
||||
``Command(update={"messages": [ToolMessage(...)], "receipts": [...]})``.
|
||||
LangChain's ``on_tool_end`` event surfaces that ``Command`` verbatim as
|
||||
``data.output``, which the rest of this handler can't introspect: it has
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def iter_completion_emission_frames(
|
|||
# ``ready`` is the live success status now that the tool waits for the
|
||||
# Celery worker to reach a terminal state. ``pending`` is retained as a
|
||||
# legacy branch for old saved chats that pre-date the wait-for-terminal
|
||||
# change (see ``app.agents.multi_agent_chat.subagents.builtins.deliverables.deliverable_wait``).
|
||||
# change (see ``app.agents.chat.multi_agent_chat.subagents.builtins.deliverables.deliverable_wait``).
|
||||
if status == "ready":
|
||||
yield ctx.streaming_service.format_terminal_info(
|
||||
f"Video presentation generated successfully: {out.get('title', 'Presentation')}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue