mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
Scoped codemod over surfsense_backend/app (excluding routes/, Wave E): renames search_space_id -> workspace_id, search_space -> workspace, SearchSpace -> Workspace across services, utils, tasks, agents, gateway, event_bus, notifications, podcasts, automations, observability params, and prompt .md files. Also flips the camelCase payload key searchSpaceId -> workspaceId (no backend reader; hard cutover). Preserved carve-outs (verbatim): Celery task names "delete_search_space_background" and "ai_sort_search_space" (wire names), and the OTel/metric key "search_space.id" (dashboards depend on it). Enum values 'SEARCH_SPACE' and SearchSourceConnector untouched.
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Single per-thread agent (re)build path.
|
|
|
|
A graph swap mid-turn would corrupt checkpointer state for the same
|
|
``thread_id``, so both the initial build and any mid-stream 429 recovery rebuild
|
|
must funnel through this single function.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import (
|
|
FilesystemSelection,
|
|
)
|
|
from app.agents.chat.runtime.llm_config import AgentConfig
|
|
from app.auth.context import AuthContext
|
|
from app.db import ChatVisibility
|
|
from app.services.connector_service import ConnectorService
|
|
|
|
|
|
async def build_main_agent_for_thread(
|
|
agent_factory: Any,
|
|
*,
|
|
llm: Any,
|
|
workspace_id: int,
|
|
db_session: Any,
|
|
connector_service: ConnectorService,
|
|
checkpointer: Any,
|
|
user_id: str | None,
|
|
thread_id: int | None,
|
|
agent_config: AgentConfig | None,
|
|
firecrawl_api_key: str | None,
|
|
thread_visibility: ChatVisibility | None,
|
|
filesystem_selection: FilesystemSelection | None,
|
|
disabled_tools: list[str] | None = None,
|
|
mentioned_document_ids: list[int] | None = None,
|
|
auth_context: AuthContext | None = None,
|
|
) -> Any:
|
|
return await agent_factory(
|
|
llm=llm,
|
|
workspace_id=workspace_id,
|
|
db_session=db_session,
|
|
connector_service=connector_service,
|
|
checkpointer=checkpointer,
|
|
user_id=user_id,
|
|
thread_id=thread_id,
|
|
agent_config=agent_config,
|
|
firecrawl_api_key=firecrawl_api_key,
|
|
thread_visibility=thread_visibility,
|
|
filesystem_selection=filesystem_selection,
|
|
disabled_tools=disabled_tools,
|
|
mentioned_document_ids=mentioned_document_ids,
|
|
auth_context=auth_context,
|
|
)
|