SurfSense/surfsense_backend/app/agents/new_chat
CREDO23 704d1bf18f refactor(mcp): per-connector cache refresh on lifecycle events
Collapse the invalidate + warmup pair into a single
refresh_mcp_tools_cache_for_connector(connector_id, search_space_id)
helper and scope live discovery to the one connector that changed
instead of the whole search space.

- new mcp_tool.discover_single_mcp_connector: load one connector,
  refresh OAuth if needed, force live MCP discovery so its cached_tools
  row is rewritten; returned wrappers are discarded since the in-process
  LRU is rebuilt lazily on the next user query
- mcp_tools_cache.refresh_mcp_tools_cache_for_connector: synchronously
  evicts the per-space LRU (LRU keys cannot scope finer) and schedules
  the per-connector prefetch via loop.create_task
- routes (OAuth callback, MCP POST, MCP PUT) collapse their two
  back-to-back calls into a single refresh call; DELETE handlers keep
  using bare invalidate_mcp_tools_cache (nothing to prefetch)

No new automated tests: the new functions are I/O glue (DB + network)
where mocked unit tests would test implementation rather than behavior.
The existing 9 unit tests for the cached_tools data shape are unchanged.
2026-05-20 17:43:27 +02:00
..
middleware perf(kb-planner): route internal planner calls to dedicated small/fast LLM 2026-05-20 11:42:52 +02:00
plugins chore: cleaned comments slop 2026-04-28 23:52:37 -07:00
prompts Wire Linear and Slack specialists and prompt routing. 2026-04-29 20:51:06 +02:00
skills feat: updated agent harness 2026-04-28 09:22:19 -07:00
subagents Merge upstream/dev into feature/multi-agent 2026-05-05 01:44:46 +02:00
tools refactor(mcp): per-connector cache refresh on lifecycle events 2026-05-20 17:43:27 +02:00
__init__.py cloud: added openrouter integration with global configs 2026-04-15 23:46:29 -07:00
agent_cache.py feat: implement agent caches and fix invalid prompt cache configs 2026-05-03 06:03:40 -07:00
chat_deepagent.py perf(kb-planner): route internal planner calls to dedicated small/fast LLM 2026-05-20 11:42:52 +02:00
checkpointer.py feat: implement connection pooling for AsyncPostgresSaver in checkpointer 2026-02-05 17:32:43 -08:00
context.py feat: improved document, folder mentions rendering 2026-05-09 22:15:51 -07:00
document_xml.py feat: updated file management for main agent 2026-04-28 04:32:52 -07:00
errors.py chore: cleaned comments slop 2026-04-28 23:52:37 -07:00
feature_flags.py refactor(chat): stream agent events via stream_output and remove parity v2 flag 2026-05-07 19:40:10 +02:00
filesystem_backends.py feat: updated file management for main agent 2026-04-28 04:32:52 -07:00
filesystem_selection.py feat(filesystem): refactor local filesystem handling to use mounts instead of root paths, enhancing mount management and path normalization 2026-04-24 05:59:21 +05:30
filesystem_state.py subagents/knowledge_base: wire KB specialist into orchestrator (renderer/projector split, FS middleware stack, cloud-mode gating) 2026-05-11 20:43:44 +02:00
llm_config.py feat: fixed vision/image provider specific errors and fixed podcast/video streaming 2026-05-02 19:18:53 -07:00
memory_extraction.py refactor(memory): streamline memory extraction by utilizing extract_text_content utility 2026-05-02 16:10:30 +05:30
mention_resolver.py feat: improved document, folder mentions rendering 2026-05-09 22:15:51 -07:00
path_resolver.py feat: updated file management for main agent 2026-04-28 04:32:52 -07:00
permissions.py chore: cleaned comments slop 2026-04-28 23:52:37 -07:00
plugin_loader.py chore: cleaned comments slop 2026-04-28 23:52:37 -07:00
prompt_caching.py perf(prompt-cache): enable Azure prompt_cache_key routing hint 2026-05-20 11:58:15 +02:00
sandbox.py feat: added ai file sorting 2026-04-14 01:43:30 -07:00
state_reducers.py feat: improved agent streaming 2026-04-29 07:20:31 -07:00
system_prompt.py Wire Linear and Slack specialists and prompt routing. 2026-04-29 20:51:06 +02:00
utils.py inject tools at runtime 2025-12-20 18:35:39 +02:00