mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
refactor(agents): evict mac-only tools/middleware from shared kernel
These were never shared with anonymous_chat (nor podcaster/video_presentation)
-- only multi_agent_chat (subagents/main agent) and the boundary use them:
shared/tools/mcp/ -> multi_agent_chat/shared/tools/mcp/
shared/tools/hitl.py -> multi_agent_chat/shared/tools/hitl.py
shared/tools/catalog.py -> multi_agent_chat/shared/tools/catalog.py
shared/middleware/dedup_tool_calls.py
-> multi_agent_chat/shared/middleware/dedup_tool_calls.py
app/agents/shared/ now holds only the genuine anon<->mac kernel:
context, middleware/{compaction,retry_after}, tools/web_search.
This commit is contained in:
parent
b7ea829371
commit
d59bb2b5aa
21 changed files with 50 additions and 40 deletions
|
|
@ -29,7 +29,7 @@ from langchain.agents.middleware import AgentMiddleware, AgentState
|
|||
from langchain_core.tools import BaseTool
|
||||
from langgraph.runtime import Runtime
|
||||
|
||||
from app.agents.shared.middleware.dedup_tool_calls import (
|
||||
from app.agents.multi_agent_chat.shared.middleware.dedup_tool_calls import (
|
||||
DedupResolver,
|
||||
wrap_dedup_key_by_arg_name,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ factories for those few tools and nothing else, so the main agent's tool
|
|||
surface stays self-contained and connector-free.
|
||||
|
||||
Tool *display* metadata for the whole app (the ``/agent/tools`` listing
|
||||
endpoint) lives separately in :mod:`app.agents.shared.tools.catalog`, a
|
||||
endpoint) lives separately in :mod:`app.agents.multi_agent_chat.shared.tools.catalog`, a
|
||||
pure-data module that imports no connectors. This registry only governs what
|
||||
the main agent actually builds and binds.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
"""Tools shared across multi_agent_chat (main agent + subagents + boundary)."""
|
||||
|
|
@ -6,7 +6,7 @@ shared by every sensitive tool (native connectors and MCP tools alike).
|
|||
|
||||
Usage inside a tool::
|
||||
|
||||
from app.agents.shared.tools.hitl import request_approval
|
||||
from app.agents.multi_agent_chat.shared.tools.hitl import request_approval
|
||||
|
||||
result = request_approval(
|
||||
action_type="gmail_email_send",
|
||||
|
|
@ -112,7 +112,9 @@ def refresh_mcp_tools_cache_for_connector(
|
|||
when an event loop is available. Neither path raises.
|
||||
"""
|
||||
try:
|
||||
from app.agents.shared.tools.mcp.tool import invalidate_mcp_tools_cache
|
||||
from app.agents.multi_agent_chat.shared.tools.mcp.tool import (
|
||||
invalidate_mcp_tools_cache,
|
||||
)
|
||||
|
||||
invalidate_mcp_tools_cache(search_space_id)
|
||||
except Exception:
|
||||
|
|
@ -133,7 +135,9 @@ def refresh_mcp_tools_cache_for_connector(
|
|||
|
||||
|
||||
async def _run_connector_prefetch(connector_id: int) -> None:
|
||||
from app.agents.shared.tools.mcp.tool import discover_single_mcp_connector
|
||||
from app.agents.multi_agent_chat.shared.tools.mcp.tool import (
|
||||
discover_single_mcp_connector,
|
||||
)
|
||||
|
||||
try:
|
||||
await discover_single_mcp_connector(connector_id)
|
||||
|
|
@ -33,14 +33,16 @@ from sqlalchemy import cast, select
|
|||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.agents.shared.middleware.dedup_tool_calls import dedup_key_full_args
|
||||
from app.agents.shared.tools.hitl import request_approval
|
||||
from app.agents.shared.tools.mcp.cache import (
|
||||
from app.agents.multi_agent_chat.shared.middleware.dedup_tool_calls import (
|
||||
dedup_key_full_args,
|
||||
)
|
||||
from app.agents.multi_agent_chat.shared.tools.hitl import request_approval
|
||||
from app.agents.multi_agent_chat.shared.tools.mcp.cache import (
|
||||
CachedMCPTools,
|
||||
read_cached_tools,
|
||||
write_cached_tools,
|
||||
)
|
||||
from app.agents.shared.tools.mcp.client import MCPClient
|
||||
from app.agents.multi_agent_chat.shared.tools.mcp.client import MCPClient
|
||||
from app.db import SearchSourceConnector
|
||||
from app.services.mcp_oauth.registry import MCP_SERVICES, get_service_by_connector_type
|
||||
from app.utils.perf import get_perf_logger
|
||||
|
|
@ -21,7 +21,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||
from app.agents.multi_agent_chat.constants import (
|
||||
CONNECTOR_TYPE_TO_CONNECTOR_AGENT_MAPS,
|
||||
)
|
||||
from app.agents.shared.tools.mcp.tool import load_mcp_tools
|
||||
from app.agents.multi_agent_chat.shared.tools.mcp.tool import load_mcp_tools
|
||||
from app.db import SearchSourceConnector
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,5 @@
|
|||
"""Cross-agent shared tools and tool metadata.
|
||||
"""Cross-agent shared tools.
|
||||
|
||||
Tool *implementations* live with the agents that own them (e.g. deliverable
|
||||
generators and their knowledge-base search helper under
|
||||
``subagents/builtins/deliverables/tools``). This package holds only the
|
||||
genuinely shared piece: the display-metadata catalog.
|
||||
Only genuinely cross-agent tool code lives here (currently web_search, imported
|
||||
directly from its module).
|
||||
"""
|
||||
|
||||
from .catalog import TOOL_CATALOG, ToolMetadata
|
||||
|
||||
__all__ = [
|
||||
"TOOL_CATALOG",
|
||||
"ToolMetadata",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue