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

@ -28,7 +28,7 @@ from pydantic import BaseModel
from sqlalchemy import func, select
from sqlalchemy.ext.asyncio import AsyncSession
from app.agents.shared.feature_flags import get_flags
from app.agents.multi_agent_chat.shared.feature_flags import get_flags
from app.db import (
AgentActionLog,
NewChatThread,

View file

@ -22,7 +22,10 @@ from dataclasses import asdict
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from app.agents.shared.feature_flags import AgentFeatureFlags, get_flags
from app.agents.multi_agent_chat.shared.feature_flags import (
AgentFeatureFlags,
get_flags,
)
from app.config import config
from app.db import User
from app.users import current_active_user

View file

@ -30,7 +30,7 @@ from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncSession
from app.agents.shared.feature_flags import get_flags
from app.agents.multi_agent_chat.shared.feature_flags import get_flags
from app.db import (
AgentPermissionRule,
NewChatThread,

View file

@ -32,7 +32,7 @@ from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncSession
from app.agents.shared.feature_flags import get_flags
from app.agents.multi_agent_chat.shared.feature_flags import get_flags
from app.db import (
AgentActionLog,
User,

View file

@ -236,7 +236,7 @@ async def stream_anonymous_chat(
detail="No-login mode is not enabled.",
)
from app.agents.shared.llm_config import (
from app.agents.multi_agent_chat.shared.llm_config import (
AgentConfig,
create_chat_litellm_from_agent_config,
)

View file

@ -7,7 +7,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.future import select
from sqlalchemy.orm import selectinload
from app.agents.shared.path_resolver import virtual_path_to_doc
from app.agents.multi_agent_chat.shared.path_resolver import virtual_path_to_doc
from app.db import (
Chunk,
Document,

View file

@ -24,13 +24,13 @@ from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.future import select
from sqlalchemy.orm import selectinload
from app.agents.shared.filesystem_selection import (
from app.agents.multi_agent_chat.shared.filesystem_selection import (
ClientPlatform,
FilesystemMode,
FilesystemSelection,
LocalFilesystemMount,
)
from app.agents.shared.middleware.busy_mutex import (
from app.agents.multi_agent_chat.shared.middleware.busy_mutex import (
get_cancel_state,
is_cancel_requested,
manager,
@ -476,7 +476,7 @@ async def _revert_turns_for_regenerate(
def _try_delete_sandbox(thread_id: int) -> None:
"""Fire-and-forget sandbox + local file deletion so the HTTP response isn't blocked."""
from app.agents.shared.sandbox import (
from app.agents.multi_agent_chat.shared.sandbox import (
delete_local_sandbox_files,
delete_sandbox,
is_sandbox_enabled,

View file

@ -51,7 +51,10 @@ async def download_sandbox_file(
):
"""Download a file from the Daytona sandbox associated with a chat thread."""
from app.agents.shared.sandbox import get_or_create_sandbox, is_sandbox_enabled
from app.agents.multi_agent_chat.shared.sandbox import (
get_or_create_sandbox,
is_sandbox_enabled,
)
if not is_sandbox_enabled():
raise HTTPException(status_code=404, detail="Sandbox is not enabled")
@ -71,7 +74,7 @@ async def download_sandbox_file(
"You don't have permission to access files in this thread",
)
from app.agents.shared.sandbox import get_local_sandbox_file
from app.agents.multi_agent_chat.shared.sandbox import get_local_sandbox_file
# Prefer locally-persisted copy (sandbox may already be deleted)
local_content = get_local_sandbox_file(thread_id, path)