Skip to content

group chat optimization#135

Merged
jsyqrt merged 16 commits into
mainfrom
feat/mcp-pool-optimization
May 17, 2026
Merged

group chat optimization#135
jsyqrt merged 16 commits into
mainfrom
feat/mcp-pool-optimization

Conversation

@jsyqrt
Copy link
Copy Markdown
Contributor

@jsyqrt jsyqrt commented May 17, 2026

No description provided.

jsyqrt and others added 16 commits May 15, 2026 15:53
Replace per-agent MCP process spawning with a pooled model that reuses
warm processes, eliminates Chrome permission popups, and dynamically
scales between minSize and demand. Fallback to per-agent when pool is
not configured.

Co-authored-by: Cursor <cursoragent@cursor.com>
…cross navigation

- Expand L2 panel when clicking a team in L1 sidebar (desktop)
- Stop ResizeObserver from overwriting user's L2 preference to localStorage;
  l2SpaceTight alone controls hiding when space is insufficient

Co-authored-by: Cursor <cursoragent@cursor.com>
Pool now initializes by default (pool.enabled !== false) regardless of
whether a remote debugging port is configured. Also make warmUp resilient
to partial spawn failures via allSettled.

Co-authored-by: Cursor <cursoragent@cursor.com>
…tab, and bulk read

- Add paginated loading with scroll-to-bottom trigger for notification history
- Auto-select tab on panel open based on pending approvals / unread notifications
- Mark all related notifications (by taskId/requirementId) as read after approval

Co-authored-by: Cursor <cursoragent@cursor.com>
…ch failure

When all search backends fail due to network issues, suggest using
web_fetch or browser tool to search directly, rather than advising
users to configure HTTPS_PROXY.

Co-authored-by: Cursor <cursoragent@cursor.com>
…wser automation

Add ChromeLauncher that auto-starts Chrome with --remote-debugging-port
on markus startup (dedicated mode, default). Pool processes connect via
--browserUrl eliminating permission dialogs entirely. Users can switch to
autoConnect mode in Settings for access to existing browser sessions.
Also adds Chrome detection step in Onboarding flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
…launcher improvements

- Add reply_to_id support across task/requirement comments and channel messages
- Implement batch-aware comment_response prompts to reduce echo chamber amplification
- Enhance deliberation and group chat prompts with convergence checks
- Improve ChromeLauncher with stale lock cleanup, port conflict resolution, IPv4/IPv6 support
- Remove dedicated Chrome connection mode from Settings UI (use autoConnect only)
- Update docs (API, ARCHITECTURE, MAILBOX-SYSTEM, PROMPT-ENGINEERING, STATE-MACHINES)

Co-authored-by: Cursor <cursoragent@cursor.com>
The dedicated Chrome instance was unstable (auto-updater crashes) and
the MCP pool doesn't solve the permission dialog problem — each pooled
process still triggers a dialog on first Chrome connection. Revert to
per-agent MCP connections with optional remoteDebuggingPort for users
who manually start Chrome with debugging enabled.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
… chat leaks

- Add 51 new tests across 3 files covering all critical attention/mailbox paths:
  - detectAbnormalCompletion: 12 pure-function unit tests
  - heuristicDecision: 10 tests covering all priority rules (R1–R9)
  - processFocusedItem: 5 status transition paths (complete/defer/cancel/retry/error)
  - checkYieldPoint, runLoop shutdown re-enqueue, applyDeliberationResult edge cases
  - handleMessage interrupt flow via attention loop (Phase 3)
  - End-to-end mailbox lifecycle: enqueue→process→complete, interrupt→defer→reprocess,
    deliberation reordering, inline completion, abnormal retry, shutdown safety

- Fix recall_context tool crash when LLM omits required scope parameter:
  infer scope='channel' when channel_key is provided

- Fix group chat message leaks:
  - Catch creative NO_RESPONSE variants (e.g. "[context check — no response needed]")
  - Filter hallucinated slash commands from other platforms (/history, /help, /status, etc.)
    with mandatory slash prefix to avoid false positives on normal text

Co-authored-by: Cursor <cursoragent@cursor.com>
…robustness, and group chat guardrails

- Add watchdog self-healing to mark DB items stuck in 'processing' as completed
  when no item is actively focused in memory (attention.ts, mailbox.ts)
- Add statusResolved safety net in processFocusedItem to prevent items from
  getting stuck if no status branch matches
- Force scenario='a2a' for a2a_message sourceType to prevent mislabeling as
  "Human Chat" in activity logs (agent.ts)
- Accept file_path/filePath as aliases for path in file tools to handle LLM
  hallucinated parameter names (file.ts)
- Add recall_context to a2a-extended tool group for better discoverability
- Filter NO_RESPONSE variants and slash commands in agent_send_group_message
  with descriptive error feedback to guide correct tool usage (api-server.ts)
- Replace hardcoded channel context count with CHANNEL_CONTEXT_MESSAGES constant
- Wire markStaleProcessingAsCompleted into persistence bridge (start.ts)

Co-authored-by: Cursor <cursoragent@cursor.com>
…cascades

Backend:
- Replace N+1 mailbox history enrichment (3+2N queries) with batch IN-clause
  queries (3 queries total) via getByMailboxItemIds on decision/activity repos
- Add missing indexes: idx_decisions_mailbox_item, idx_mailbox_agent_source
- Pre-collect team member avatars into a map instead of per-member findById
- Remove redundant execution:log broadcast from activity log handler (frontend
  never consumes it)
- Add 200ms event coalescing in WSBroadcaster for high-frequency agent events
  (agent:update/attention/focus/mailbox/decision/triage)

Frontend:
- Replace wsClient.on('*', refreshTeams) with specific event subscriptions
  (team:update, agent:removed) in Team.tsx and ChatTeamSidebar.tsx
- Add throttle wrapper for WS-driven refreshes (agents 3s, teams 5s, chats 3s)
- Increase polling intervals from 8s/15s to 30s/60s (WS handles real-time)
- Debounce MindTab WS-driven reload with 500ms window
- Fix deferred click listener leak in ChatTeamSidebar and TeamDetailPanel
- Fix HeartbeatTab loading state not tracking async refresh

Co-authored-by: Cursor <cursoragent@cursor.com>
…calls

Address the 5/16 cache hit rate drop (89%→77%) caused by high-volume
A2A group chat. Root cause: every A2A message created a throwaway session,
re-injecting 80 channel messages (~60K tokens) with zero prefix cache reuse.

Fixes:
- P0: Remove duplicate Tool Usage Rules from dynamic tier (saves ~300 tok/call)
- P0: Channel-stable session reuse for A2A/group chat (channel_{key}_{agentId})
- P1: Reduce CHANNEL_CONTEXT_MESSAGES from 80 to 40
- P1: Per-message cache breakpoints at current-turn boundary (Anthropic)
- P1: New group_chat scenario — move ~2K static rules from user message to
      cached system prompt; only per-message parts (roster, targeting) remain
- P2: Parse and propagate Anthropic cache metrics (cacheReadTokens/cacheWriteTokens)
- P2: Add systemCacheSegments to triage/interrupt judge LLM calls
- P3: Update PROMPT-ENGINEERING.md to reflect 3-tier cache architecture

Expected impact for 20-agent group chat: ~65-70% fewer input tokens per round,
cache hit rate back to ~85-90% under heavy A2A traffic.

Test: 41 files, 659 tests pass (17 new cache-optimization tests added).
Co-authored-by: Cursor <cursoragent@cursor.com>
Storm prevention layers (depth limit, per-round dedup, cooldown) now
deliver throttled messages to the agent's mailbox instead of silently
discarding them. Direct @mention messages are protected from LLM triage
drops. Consolidated mailbox items use 'merged' status instead of
misleading 'dropped'.

Memory leak fixes: MemoryStore sessions capped at 20 with LRU eviction
and lazy-load from disk, TaskQueue.completedTasks capped at 200,
expired announcements pruned, stale a2a cooldown entries cleaned up.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ges, throttle streaming KaTeX

Co-authored-by: Cursor <cursoragent@cursor.com>
…nstants

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsyqrt jsyqrt merged commit ad149a9 into main May 17, 2026
1 check 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.

1 participant