refactor(agents): move mac-only modules out of the cross-agent shared kernel

app/agents/shared/ is a sibling of anonymous_chat/podcaster/multi_agent_chat/
video_presentation, so it should only hold code shared across 2+ of those
agents. In practice podcaster and video_presentation import nothing from it,
and anonymous_chat needs only context + compaction + retry_after + web_search.
Everything else was multi_agent_chat-only (the boundary just passes through).

Move the multi_agent_chat-only cluster into multi_agent_chat/shared/ (files
moved verbatim via git rename; ~116 import sites rewritten):

  errors, feature_flags, filesystem_selection, path_resolver, prompt_caching,
  sandbox, llm_config, mention_resolver
  middleware/busy_mutex, middleware/kb_persistence

busy_mutex/llm_config/mention_resolver are boundary-only but import the moved
modules, so they were folded in to avoid a backwards shared -> multi_agent_chat
dependency. main_agent builders now import the impls directly; the shared
middleware barrel keeps only the genuinely-shared compaction + retry_after.

Also delete the dead leftover shared/plugins and shared/skills dirs (live
copies already live under main_agent/).

Remaining in app/agents/shared/: context, system_prompt(+prompts), checkpointer,
middleware/{compaction,retry_after,dedup_tool_calls}, tools/. checkpointer and
system_prompt are boundary-only infra pending a dedicated home decision.
This commit is contained in:
CREDO23 2026-06-05 12:30:15 +02:00
parent c0c4f57f5d
commit 82c5dc5b02
126 changed files with 238 additions and 196 deletions

View file

@ -9,8 +9,8 @@ from __future__ import annotations
from typing import Any
from app.agents.shared.filesystem_selection import FilesystemSelection
from app.agents.shared.llm_config import AgentConfig
from app.agents.multi_agent_chat.shared.filesystem_selection import FilesystemSelection
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
from app.db import ChatVisibility
from app.services.connector_service import ConnectorService

View file

@ -11,8 +11,8 @@ from __future__ import annotations
from collections.abc import AsyncGenerator
from typing import Any
from app.agents.shared.filesystem_selection import FilesystemMode
from app.agents.shared.middleware.kb_persistence import (
from app.agents.multi_agent_chat.shared.filesystem_selection import FilesystemMode
from app.agents.multi_agent_chat.shared.middleware.kb_persistence import (
commit_staged_filesystem_state,
)
from app.services.new_streaming_service import VercelStreamingService

View file

@ -7,8 +7,8 @@ import logging
import time
from typing import Any, Literal
from app.agents.shared.errors import BusyError
from app.agents.shared.middleware.busy_mutex import (
from app.agents.multi_agent_chat.shared.errors import BusyError
from app.agents.multi_agent_chat.shared.middleware.busy_mutex import (
get_cancel_state,
is_cancel_requested,
)

View file

@ -28,8 +28,11 @@ from langchain_core.messages import HumanMessage
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.future import select
from app.agents.shared.filesystem_selection import FilesystemMode
from app.agents.shared.mention_resolver import resolve_mentions, substitute_in_text
from app.agents.multi_agent_chat.shared.filesystem_selection import FilesystemMode
from app.agents.multi_agent_chat.shared.mention_resolver import (
resolve_mentions,
substitute_in_text,
)
from app.db import (
ChatVisibility,
NewChatThread,

View file

@ -15,7 +15,7 @@ tells the user what to change.
from __future__ import annotations
from app.agents.shared.llm_config import AgentConfig
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
from app.observability import otel as ot

View file

@ -30,8 +30,11 @@ from typing import Any, Literal
import anyio
from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
from app.agents.shared.filesystem_selection import FilesystemMode, FilesystemSelection
from app.agents.shared.middleware.busy_mutex import end_turn
from app.agents.multi_agent_chat.shared.filesystem_selection import (
FilesystemMode,
FilesystemSelection,
)
from app.agents.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
@ -826,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.shared.sandbox import (
from app.agents.multi_agent_chat.shared.sandbox import (
is_sandbox_enabled,
persist_and_delete_sandbox,
)

View file

@ -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.shared.llm_config import AgentConfig
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
from app.services.token_tracking_service import TokenAccumulator

View file

@ -24,8 +24,11 @@ from uuid import UUID
import anyio
from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
from app.agents.shared.filesystem_selection import FilesystemMode, FilesystemSelection
from app.agents.shared.middleware.busy_mutex import end_turn
from app.agents.multi_agent_chat.shared.filesystem_selection import (
FilesystemMode,
FilesystemSelection,
)
from app.agents.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

View file

@ -14,7 +14,7 @@ from typing import Any
from sqlalchemy.ext.asyncio import AsyncSession
from app.agents.shared.llm_config import (
from app.agents.multi_agent_chat.shared.llm_config import (
AgentConfig,
create_chat_litellm_from_agent_config,
create_chat_litellm_from_config,

View file

@ -19,7 +19,7 @@ from dataclasses import dataclass
from typing import TYPE_CHECKING
from uuid import UUID
from app.agents.shared.llm_config import AgentConfig
from app.agents.multi_agent_chat.shared.llm_config import AgentConfig
from app.db import shielded_async_session
if TYPE_CHECKING:

View file

@ -17,7 +17,7 @@ from typing import Literal
from sqlalchemy.ext.asyncio import AsyncSession
from app.agents.shared.middleware.busy_mutex import end_turn
from app.agents.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,

View file

@ -15,7 +15,7 @@ from __future__ import annotations
from collections.abc import AsyncGenerator, Awaitable, Callable
from typing import Any
from app.agents.shared.filesystem_selection import FilesystemMode
from app.agents.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

View file

@ -14,7 +14,7 @@ import traceback
from collections.abc import Iterator
from typing import Any, Literal
from app.agents.shared.errors import BusyError
from app.agents.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