Skip to content

feat: improved agent speed and fixed it citations#1423

Merged
MODSetter merged 75 commits into
mainfrom
dev
May 21, 2026
Merged

feat: improved agent speed and fixed it citations#1423
MODSetter merged 75 commits into
mainfrom
dev

Conversation

@MODSetter
Copy link
Copy Markdown
Owner

@MODSetter MODSetter commented May 21, 2026

Description

Motivation and Context

FIX #

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR delivers agent performance improvements and a complete citations architecture overhaul. On the speed front, it introduces a dedicated planner LLM for internal utility calls (query rewriting, date extraction) — routing those short classification tasks to a small/fast model instead of the user's chat LLM yields measurable per-turn latency savings. The KB planner runnable is compiled once rather than on every turn, and background LLM calls have been stripped from the critical chat stream path to eliminate network round-trips before the user sees output. MCP connector tool discovery is now cached in the database so repeated connector list calls hit a sub-second disk read instead of a 5+ second network round-trip, and subagent compilation timings are logged so slow middleware or tool loads surface in production observability. On the citations side, the PR replaces brittle marker-based memory storage with a heading-based markdown document model that can parse and normalize both legacy (YYYY-MM-DD) [fact] bullets and new - YYYY-MM-DD: text entries, exposing user and team memory as first-class MEMORY.md and TEAM_MEMORY.md documents in the file tree that open in the same editor panel used for KB docs. The Knowledge Base subagent specialist is taught to emit [citation:chunk_id] markers in its prose so the main agent can relay them verbatim to the UI, and the citation prompt now handles both direct chunk-block channels and specialist-relayed markers with strict copy-digit-for-digit rules to prevent LLM-corrupted IDs from silently breaking the citation UI. Connector subagent system prompts are updated to cap evidence.items at a structured {total: N} count and surface matched entries in condensed one-line-per-entry action_summary prose instead of dumping raw arrays, eliminating the multi-turn context bloat that was slowing shared-thread workflows. Azure OpenAI's automatic prompt caching support is wired in for prompt_cache_key (routing affinity) while its prompt_cache_retention param is deferred until LiteLLM ships it in the Azure transformer. Token tracking logs now expose per-call cache hit ratios and wall-clock latencies so cost and speed regressions surface immediately in production telemetry, and the in-process MCP LRU eviction is replaced with a two-tier system (DB-backed cached_tools + background prefetch) so connector lifecycle events no longer stall the HTTP response.

⏱️ Estimated Review Time: 1-3 hours

💡 Review Order Suggestion
Order File Path
1 VERSION
2 surfsense_backend/pyproject.toml
3 surfsense_web/package.json
4 surfsense_browser_extension/package.json
5 surfsense_desktop/package.json
6 .github/workflows/backend-tests.yml
7 .github/workflows/code-quality.yml
8 .pre-commit-config.yaml
9 surfsense_backend/app/services/memory/__init__.py
10 surfsense_backend/app/services/memory/service.py
11 surfsense_backend/app/services/memory/validation.py
12 surfsense_backend/app/services/memory/document.py
13 surfsense_backend/app/services/memory/rewrite.py
14 surfsense_backend/app/services/memory/prompts.py
15 surfsense_backend/app/services/memory/schemas.py
16 surfsense_backend/app/agents/new_chat/tools/update_memory.py
17 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/memory/tools/update_memory.py
18 surfsense_backend/app/routes/memory_routes.py
19 surfsense_backend/app/routes/team_memory_routes.py
20 surfsense_backend/app/schemas/search_space.py
21 surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/citations/on.md
22 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_cloud.md
23 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_readonly_cloud.md
24 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/description_readonly.md
25 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_desktop.md
26 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_readonly_desktop.md
27 surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/memory_protocol/private.md
28 surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/memory_protocol/team.md
29 surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/private/description.md
30 surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/private/example.md
31 surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/team/description.md
32 surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/team/example.md
33 surfsense_backend/app/agents/new_chat/prompts/base/memory_protocol_private.md
34 surfsense_backend/app/agents/new_chat/prompts/base/memory_protocol_team.md
35 surfsense_backend/app/agents/new_chat/prompts/tools/update_memory_private.md
36 surfsense_backend/app/agents/new_chat/prompts/tools/update_memory_team.md
37 surfsense_backend/app/agents/new_chat/prompts/examples/update_memory_private.md
38 surfsense_backend/app/agents/new_chat/prompts/examples/update_memory_team.md
39 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/memory/system_prompt.md
40 surfsense_backend/app/services/llm_service.py
41 surfsense_backend/app/config/__init__.py
42 surfsense_backend/app/config/global_llm_config.example.yaml
43 surfsense_backend/app/agents/new_chat/middleware/knowledge_search.py
44 surfsense_backend/app/agents/multi_agent_chat/middleware/main_agent/knowledge_priority.py
45 surfsense_backend/app/agents/new_chat/chat_deepagent.py
46 surfsense_backend/app/agents/new_chat/tools/mcp_tools_cache.py
47 surfsense_backend/app/agents/new_chat/tools/mcp_tool.py
48 surfsense_backend/app/routes/mcp_oauth_route.py
49 surfsense_backend/app/routes/search_source_connectors_routes.py
50 surfsense_backend/app/agents/multi_agent_chat/middleware/main_agent/checkpointed_subagent_middleware/middleware.py
51 surfsense_backend/app/agents/multi_agent_chat/middleware/main_agent/checkpointed_subagent_middleware/task_tool.py
52 surfsense_backend/app/agents/multi_agent_chat/middleware/shared/kb_context_projection.py
53 surfsense_backend/app/agents/new_chat/middleware/knowledge_tree.py
54 surfsense_backend/app/agents/new_chat/middleware/memory_injection.py
55 surfsense_backend/app/agents/new_chat/prompt_caching.py
56 surfsense_backend/app/services/token_tracking_service.py
57 surfsense_web/lib/env-config.ts
58 surfsense_web/atoms/editor/editor-panel.atom.ts
59 surfsense_web/components/editor-panel/memory.ts
60 surfsense_web/components/editor-panel/editor-panel.tsx
61 surfsense_web/components/documents/DocumentNode.tsx
62 surfsense_web/components/documents/FolderTreeView.tsx
63 surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx
64 surfsense_web/contracts/types/document.types.ts
65 surfsense_web/contracts/enums/connectorIcons.tsx
66 surfsense_web/app/dashboard/[search_space_id]/search-space-settings/layout-shell.tsx
67 surfsense_web/app/dashboard/[search_space_id]/user-settings/layout-shell.tsx
68 surfsense_web/contracts/types/search-space.types.ts
69 surfsense_backend/app/routes/search_spaces_routes.py
70 surfsense_backend/app/routes/__init__.py
71 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/airtable/system_prompt.md
72 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/calendar/system_prompt.md
73 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/clickup/system_prompt.md
74 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/discord/system_prompt.md
75 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/gmail/system_prompt.md
76 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/jira/system_prompt.md
77 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/linear/system_prompt.md
78 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/luma/system_prompt.md
79 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/slack/system_prompt.md
80 surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/teams/system_prompt.md
81 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/research/system_prompt.md
82 surfsense_backend/tests/unit/agents/new_chat/test_memory_response_content.py
83 surfsense_backend/tests/unit/agents/new_chat/tools/test_update_memory_scope.py
84 surfsense_backend/tests/unit/services/test_memory_service.py
85 surfsense_backend/tests/unit/agents/new_chat/tools/test_mcp_tools_cache.py
86 surfsense_backend/tests/unit/agents/new_chat/test_prompt_caching.py
87 surfsense_backend/app/tasks/chat/stream_new_chat.py
88 surfsense_backend/app/utils/document_converters.py
89 surfsense_backend/app/agents/new_chat/middleware/kb_persistence.py
90 surfsense_backend/app/services/gmail/kb_sync_service.py
91 surfsense_backend/app/services/google_calendar/kb_sync_service.py
92 surfsense_backend/app/services/jira/kb_sync_service.py
93 surfsense_backend/app/services/onedrive/kb_sync_service.py
94 surfsense_backend/app/services/revert_service.py
95 surfsense_backend/app/tasks/connector_indexers/discord_indexer.py
96 surfsense_backend/app/tasks/connector_indexers/luma_indexer.py
97 surfsense_backend/app/tasks/connector_indexers/teams_indexer.py
98 surfsense_backend/app/tasks/document_processors/_save.py

Need help? Join our Discord

Summary by CodeRabbit

  • New Features

    • Added memory editor panel for managing personal and team memory directly in the dashboard.
    • Added team memory API endpoints for read/update/reset operations.
    • Implemented MCP tool result caching to improve connector discovery performance.
    • Added planner LLM configuration for internal knowledge prioritization tasks.
  • Improvements

    • Performance logging across agent middleware and memory operations.
    • Non-blocking embedding generation via background thread execution.
    • Enhanced knowledge base citations with structured chunk tracking.
    • Centralized backend URL configuration for simplified client setup.
  • Removed Features

    • Legacy memory editing endpoints and UI components.
    • Automatic memory extraction after agent turns.

Review Change Stack

VarunShukla07 and others added 30 commits May 19, 2026 01:16
…the editor panel, and remove deprecated memory hook
CREDO23 and others added 26 commits May 20, 2026 11:42
…t LLM

Adds an optional planner LLM role wired through KnowledgePriorityMiddleware
so KB query rewriting, date extraction, and recency classification run on a
cheap model (e.g. gpt-4o-mini, Haiku, Azure nano) instead of the user's
chat LLM. Operators opt in by setting is_planner: true on exactly one
global config; without it, behavior is unchanged.
Splits the OpenAI-family gate into per-param predicates so AZURE and
AZURE_OPENAI configs now receive prompt_cache_key for backend routing
affinity (Microsoft auto-caches GPT-4o+ deployments at >=1024 tokens;
the key clusters same-prefix requests on the same GPU pool and raises
hit rate on turn 2+). prompt_cache_retention stays opted out for Azure
because litellm 1.83.14's Azure transformer would drop it silently;
revisit when Azure's supported params list is updated.
Skip the ~1-3s MCP initialize + list_tools handshake on every cache miss
by reading tool definitions from the connector row we already load. Lazy
populate on first miss, self-heal on corrupt cache, zero schema migration.
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.
The probe answered its question (informing the cached_tools persistence
design). Future MCP session-pooling work, if revived, can recreate it.
…cument-panel

feat: improve memory extraction & add document-panel memory editing
refactor(env): replace inline process.env reads with BACKEND_URL in lib/
…forms

refactor(env): replace inline process.env reads with BACKEND_URL in connector forms and hooks
…t-dashboard

refactor(env): replace inline process.env reads with BACKEND_URL in editor, chat, dashboard and settings
…nerators

refactor(env): replace inline process.env reads with BACKEND_URL in tool-ui generators
fix: Update CI workflow versions and scoped test triggers
Resolves: surfsense_backend/app/agents/new_chat/middleware/memory_injection.py
- Took both imports: upstream moved MEMORY_HARD_LIMIT/SOFT_LIMIT to
  app.services.memory; kept our perf-logger import for timing.

Pulls in upstream changes:
- Memory document feature (services/memory refactor, removal of
  app.agents.new_chat.memory_extraction and background extraction in
  stream_new_chat — agent now drives memory via update_memory tool).
- BACKEND_URL env refactor across web tool-ui/editor/chat/dashboard/lib.
- GitHub Actions backend test workflow + pre-commit biome bump.
- Token-display polish in MessageInfoDropdown; save_memory no-update
  sentinel.

Verified: 1723 unit tests pass, ruff clean. No semantic regression in
stream_new_chat (their memory-extraction deletion and our preflight
removal touch different functions).
[Improvement] Agent: faster turns and lower LLM cost
…DocumentTabContent; update connector-status-config for Composio Google Drive connector maintenance
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
surf-sense-frontend Ready Ready Preview, Comment May 21, 2026 9:46pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 67ea8f2a-841d-4261-8597-23b6c733afe7

📥 Commits

Reviewing files that changed from the base of the PR and between 0f98480 and 2e58909.

⛔ Files ignored due to path filters (1)
  • surfsense_backend/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (132)
  • .github/workflows/backend-tests.yml
  • .github/workflows/code-quality.yml
  • .pre-commit-config.yaml
  • VERSION
  • surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/citations/on.md
  • surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/memory_protocol/private.md
  • surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/memory_protocol/team.md
  • surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/private/description.md
  • surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/private/example.md
  • surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/team/description.md
  • surfsense_backend/app/agents/multi_agent_chat/main_agent/system_prompt/prompts/tools/update_memory/team/example.md
  • surfsense_backend/app/agents/multi_agent_chat/middleware/main_agent/checkpointed_subagent_middleware/middleware.py
  • surfsense_backend/app/agents/multi_agent_chat/middleware/main_agent/checkpointed_subagent_middleware/task_tool.py
  • surfsense_backend/app/agents/multi_agent_chat/middleware/main_agent/knowledge_priority.py
  • surfsense_backend/app/agents/multi_agent_chat/middleware/shared/kb_context_projection.py
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/description_readonly.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_cloud.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_desktop.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_readonly_cloud.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/knowledge_base/system_prompt_readonly_desktop.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/memory/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/memory/tools/update_memory.py
  • surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/research/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/airtable/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/calendar/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/clickup/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/discord/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/gmail/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/jira/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/linear/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/luma/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/slack/system_prompt.md
  • surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/teams/system_prompt.md
  • surfsense_backend/app/agents/new_chat/chat_deepagent.py
  • surfsense_backend/app/agents/new_chat/memory_extraction.py
  • surfsense_backend/app/agents/new_chat/middleware/kb_persistence.py
  • surfsense_backend/app/agents/new_chat/middleware/knowledge_search.py
  • surfsense_backend/app/agents/new_chat/middleware/knowledge_tree.py
  • surfsense_backend/app/agents/new_chat/middleware/memory_injection.py
  • surfsense_backend/app/agents/new_chat/prompt_caching.py
  • surfsense_backend/app/agents/new_chat/prompts/base/memory_protocol_private.md
  • surfsense_backend/app/agents/new_chat/prompts/base/memory_protocol_team.md
  • surfsense_backend/app/agents/new_chat/prompts/examples/update_memory_private.md
  • surfsense_backend/app/agents/new_chat/prompts/examples/update_memory_team.md
  • surfsense_backend/app/agents/new_chat/prompts/tools/update_memory_private.md
  • surfsense_backend/app/agents/new_chat/prompts/tools/update_memory_team.md
  • surfsense_backend/app/agents/new_chat/tools/mcp_tool.py
  • surfsense_backend/app/agents/new_chat/tools/mcp_tools_cache.py
  • surfsense_backend/app/agents/new_chat/tools/update_memory.py
  • surfsense_backend/app/config/__init__.py
  • surfsense_backend/app/config/global_llm_config.example.yaml
  • surfsense_backend/app/routes/__init__.py
  • surfsense_backend/app/routes/mcp_oauth_route.py
  • surfsense_backend/app/routes/memory_routes.py
  • surfsense_backend/app/routes/search_source_connectors_routes.py
  • surfsense_backend/app/routes/search_spaces_routes.py
  • surfsense_backend/app/routes/team_memory_routes.py
  • surfsense_backend/app/schemas/search_space.py
  • surfsense_backend/app/services/gmail/kb_sync_service.py
  • surfsense_backend/app/services/google_calendar/kb_sync_service.py
  • surfsense_backend/app/services/jira/kb_sync_service.py
  • surfsense_backend/app/services/llm_service.py
  • surfsense_backend/app/services/memory/__init__.py
  • surfsense_backend/app/services/memory/document.py
  • surfsense_backend/app/services/memory/prompts.py
  • surfsense_backend/app/services/memory/rewrite.py
  • surfsense_backend/app/services/memory/schemas.py
  • surfsense_backend/app/services/memory/service.py
  • surfsense_backend/app/services/memory/validation.py
  • surfsense_backend/app/services/onedrive/kb_sync_service.py
  • surfsense_backend/app/services/revert_service.py
  • surfsense_backend/app/services/token_tracking_service.py
  • surfsense_backend/app/tasks/chat/stream_new_chat.py
  • surfsense_backend/app/tasks/chat/streaming/graph_stream/event_stream.py
  • surfsense_backend/app/tasks/chat/streaming/graph_stream/result.py
  • surfsense_backend/app/tasks/chat/streaming/handlers/tool_end.py
  • surfsense_backend/app/tasks/chat/streaming/relay/state.py
  • surfsense_backend/app/tasks/connector_indexers/discord_indexer.py
  • surfsense_backend/app/tasks/connector_indexers/luma_indexer.py
  • surfsense_backend/app/tasks/connector_indexers/teams_indexer.py
  • surfsense_backend/app/tasks/document_processors/_save.py
  • surfsense_backend/app/utils/document_converters.py
  • surfsense_backend/pyproject.toml
  • surfsense_backend/tests/unit/agents/new_chat/test_memory_response_content.py
  • surfsense_backend/tests/unit/agents/new_chat/test_prompt_caching.py
  • surfsense_backend/tests/unit/agents/new_chat/tools/test_mcp_tools_cache.py
  • surfsense_backend/tests/unit/agents/new_chat/tools/test_update_memory_scope.py
  • surfsense_backend/tests/unit/services/test_memory_service.py
  • surfsense_backend/tests/unit/tasks/chat/streaming/test_stream_output.py
  • surfsense_backend/tests/unit/test_stream_new_chat_contract.py
  • surfsense_browser_extension/package.json
  • surfsense_desktop/package.json
  • surfsense_web/app/(home)/login/GoogleLoginButton.tsx
  • surfsense_web/app/api/zero/query/route.ts
  • surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx
  • surfsense_web/app/dashboard/[search_space_id]/search-space-settings/layout-shell.tsx
  • surfsense_web/app/dashboard/[search_space_id]/search-space-settings/team-memory/page.tsx
  • surfsense_web/app/dashboard/[search_space_id]/user-settings/components/MemoryContent.tsx
  • surfsense_web/app/dashboard/[search_space_id]/user-settings/layout-shell.tsx
  • surfsense_web/app/dashboard/[search_space_id]/user-settings/memory/page.tsx
  • surfsense_web/atoms/editor/editor-panel.atom.ts
  • surfsense_web/components/assistant-ui/assistant-message.tsx
  • surfsense_web/components/assistant-ui/connector-popup/config/connector-status-config.json
  • surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/obsidian-connect-form.tsx
  • surfsense_web/components/assistant-ui/connector-popup/connector-configs/components/circleback-config.tsx
  • surfsense_web/components/assistant-ui/connector-popup/connector-configs/views/connector-edit-view.tsx
  • surfsense_web/components/assistant-ui/connector-popup/hooks/use-connector-dialog.ts
  • surfsense_web/components/assistant-ui/connector-popup/views/connector-accounts-list-view.tsx
  • surfsense_web/components/documents/DocumentNode.tsx
  • surfsense_web/components/documents/FolderTreeView.tsx
  • surfsense_web/components/editor-panel/editor-panel.tsx
  • surfsense_web/components/editor-panel/memory.ts
  • surfsense_web/components/free-chat/anonymous-chat.tsx
  • surfsense_web/components/layout/ui/right-panel/RightPanel.tsx
  • surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx
  • surfsense_web/components/layout/ui/tabs/DocumentTabContent.tsx
  • surfsense_web/components/report-panel/report-panel.tsx
  • surfsense_web/components/settings/general-settings-manager.tsx
  • surfsense_web/components/settings/prompt-config-manager.tsx
  • surfsense_web/components/settings/team-memory-manager.tsx
  • surfsense_web/components/tool-ui/generate-podcast.tsx
  • surfsense_web/components/tool-ui/generate-resume.tsx
  • surfsense_web/components/tool-ui/video-presentation/generate-video-presentation.tsx
  • surfsense_web/components/ui/fixed-toolbar.tsx
  • surfsense_web/contracts/enums/connectorIcons.tsx
  • surfsense_web/contracts/types/document.types.ts
  • surfsense_web/contracts/types/search-space.types.ts
  • surfsense_web/hooks/use-search-source-connectors.ts
  • surfsense_web/lib/apis/base-api.service.ts
  • surfsense_web/lib/auth-utils.ts
  • surfsense_web/lib/chat/thread-persistence.ts
  • surfsense_web/package.json

📝 Walkthrough

Walkthrough

Adds a canonical memory service and routes, removes legacy edit flows, updates agents/middleware with planner LLM, prompt-caching, and perf logs, introduces MCP tool discovery cache/refresh, offloads embeddings to threads, and aligns web UI to BACKEND_URL with a new memory editor mode.

Changes

Unified Memory and MCP Cache

Layer / File(s) Summary
Canonical memory service and router integration
app/services/memory/*, app/routes/memory_routes.py, app/routes/team_memory_routes.py, app/routes/__init__.py
Adds MemoryScope/SaveResult, read/save/reset APIs, validation, rewrite; user/team memory endpoints return MemoryRead with limits; routes wired.
Agent/tool migration to service
agents/*/tools/update_memory.py, tasks/chat/stream_new_chat.py
Tools delegate to save_memory; removes background extraction flag/flows in streaming.
Planner LLM and prompt caching
services/llm_service.py, agents/new_chat/*knowledge_*, agents/new_chat/prompt_caching.py, config/*
Adds get_planner_llm and wires planner_llm; broadens provider gating for prompt cache.
MCP cached discovery and OAuth refresh
agents/new_chat/tools/mcp_tool.py, mcp_tools_cache.py, routes*
HTTP tool discovery supports cached_tools, writes cache, refreshes after OAuth; add discover_single_mcp_connector.
Perf logs and async embedding
middleware/*, services/*kb_sync_service.py, tasks/*indexer.py, utils/document_converters.py
Adds perf timing logs; moves embed_text(s) to asyncio.to_thread across services/tasks.
Prompts and citations
system_prompt*.md
Tightens citation rules, evidence limits, and memory formatting (heading + dated bullets).
Web: memory editor mode and BACKEND_URL
components/editor-panel/*, atoms/editor/*, DocumentsSidebar.tsx, DocumentNode.tsx, contracts/*
Adds memory panel mode with limits/save/reset/export; introduces USER_MEMORY/TEAM_MEMORY doc types; switches all calls to BACKEND_URL.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Poem

I tidied the warren of memory threads,
Stitched soft limits where the carrot treads,
Cached MCP tools for a quicker hop,
Logged tiny timings—thump, don’t stop!
Planner LLM hums a quiet tune—
Backends align, the frontend swoons.
Version bumped; we’re over the moon. 🥕🐇

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

@MODSetter MODSetter merged commit 49dd840 into main May 21, 2026
6 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants