MCP-tool memory writes don't broadcast ACTIVITY_LOGGED — canvas can't live-refresh on them #1754

Closed
opened 2026-05-24 00:02:35 +00:00 by hongming · 0 comments
Owner

MCP-tool memory writes don't broadcast ACTIVITY_LOGGED — canvas Memory tab can't live-refresh on them

Problem

MemoryInspectorPanel.tsx (after PR #1749) subscribes to ACTIVITY_LOGGED WS events filtered to memory-write activity_types so the panel auto-refreshes when an agent commits a memory. Discovered while reviewing #1749 that the MCP-tool memory paths (commit_memory, commit_memory_v2, commit_summary, recall_memory, forget_memory) don't actually emit ACTIVITY_LOGGED on the wire.

What's missing

Today, the only emitters of ACTIVITY_LOGGED for memory operations are:

Path Source activity_type
POST /workspaces/:id/memories (REST, GLOBAL only) memories.go:218 via LogActivity memory_write_global
PATCH /workspaces/:id/memories/:id (REST, GLOBAL only) memories.go:617 via LogActivity memory_edit_global
DELETE /workspaces/:id/memories/:id (REST, GLOBAL only) memories.go via LogActivity memory_delete_global
Self-reported via POST /workspaces/:id/activity agent_log (or whatever the agent supplies)

The MCP-tool paths bypass LogActivity:

MCP tool Handler Result
commit_memory (legacy shim) mcp_tools.go:toolCommitMemorymcp_tools_memory_legacy_shim.go:commitMemoryLegacyShim → plugin (post-#1747) No LogActivity call
commit_memory_v2 mcp_tools_memory_v2.go:toolCommitMemoryV2 → plugin No LogActivity call
commit_summary mcp_tools_memory_v2.go:toolCommitSummary → plugin No LogActivity call
recall_memory (legacy shim) mcp_tools.go:toolRecallMemory → plugin No LogActivity call (reads don't need to broadcast)
forget_memory mcp_tools_memory_v2.go:toolForgetMemory → plugin No LogActivity call

So when an agent calls commit_memory from chat — the most common case — the canvas Memory tab does NOT receive an ACTIVITY_LOGGED event keyed by activity_type='memory_write'. PR #1749's filter handles this over-inclusively by also matching activity_type='agent_log', but that depends on whether the agent self-reports — which is per-runtime and not guaranteed.

Proposed fix

Add LogActivity calls in the MCP tool handlers right after the plugin call succeeds:

// in toolCommitMemoryV2 after h.memv2.plugin.CommitMemory(...) succeeds
_ = activity.LogActivity(ctx, h.database, workspaceID, activity.Payload{
    Type:   "memory_write",
    Source: "agent",
    Summary: fmt.Sprintf("commit_memory to %s", namespace),
})

Plus equivalent for toolCommitSummary (memory_summary_write?), toolForgetMemory (memory_delete?).

recall_memory reads should NOT emit — too noisy and not useful for live UI refresh.

Tracking

Once this lands, the over-inclusive agent_log filter in MemoryInspectorPanel.tsx can be narrowed to just the memory-* types. The component already has a TODO-via-comment naming this issue in its filter block (added in #1749 review).

Tier

area:memory area:observability tier:low — quality-of-life for canvas Memory tab, no security or data implications. Should land after the A0+A1 memory cleanup train (#1742, #1747) so the LogActivity calls land on the v2-only code path.

Refs

  • #1749 (canvas Memory tab live-refresh — this is the server-side counterpart)
  • #1733 (memory SSOT consolidation parent issue)
# MCP-tool memory writes don't broadcast `ACTIVITY_LOGGED` — canvas Memory tab can't live-refresh on them ## Problem `MemoryInspectorPanel.tsx` (after PR #1749) subscribes to `ACTIVITY_LOGGED` WS events filtered to memory-write `activity_type`s so the panel auto-refreshes when an agent commits a memory. Discovered while reviewing #1749 that the MCP-tool memory paths (`commit_memory`, `commit_memory_v2`, `commit_summary`, `recall_memory`, `forget_memory`) don't actually emit `ACTIVITY_LOGGED` on the wire. ## What's missing Today, the only emitters of `ACTIVITY_LOGGED` for memory operations are: | Path | Source | activity_type | |---|---|---| | `POST /workspaces/:id/memories` (REST, GLOBAL only) | `memories.go:218` via `LogActivity` | `memory_write_global` | | `PATCH /workspaces/:id/memories/:id` (REST, GLOBAL only) | `memories.go:617` via `LogActivity` | `memory_edit_global` | | `DELETE /workspaces/:id/memories/:id` (REST, GLOBAL only) | `memories.go` via `LogActivity` | `memory_delete_global` | | Self-reported via `POST /workspaces/:id/activity` | `agent_log` (or whatever the agent supplies) | The MCP-tool paths bypass `LogActivity`: | MCP tool | Handler | Result | |---|---|---| | `commit_memory` (legacy shim) | `mcp_tools.go:toolCommitMemory` → `mcp_tools_memory_legacy_shim.go:commitMemoryLegacyShim` → plugin (post-#1747) | No `LogActivity` call | | `commit_memory_v2` | `mcp_tools_memory_v2.go:toolCommitMemoryV2` → plugin | No `LogActivity` call | | `commit_summary` | `mcp_tools_memory_v2.go:toolCommitSummary` → plugin | No `LogActivity` call | | `recall_memory` (legacy shim) | `mcp_tools.go:toolRecallMemory` → plugin | No `LogActivity` call (reads don't need to broadcast) | | `forget_memory` | `mcp_tools_memory_v2.go:toolForgetMemory` → plugin | No `LogActivity` call | So when an agent calls `commit_memory` from chat — the most common case — the canvas Memory tab does NOT receive an `ACTIVITY_LOGGED` event keyed by `activity_type='memory_write'`. PR #1749's filter handles this over-inclusively by also matching `activity_type='agent_log'`, but that depends on whether the agent self-reports — which is per-runtime and not guaranteed. ## Proposed fix Add `LogActivity` calls in the MCP tool handlers right after the plugin call succeeds: ```go // in toolCommitMemoryV2 after h.memv2.plugin.CommitMemory(...) succeeds _ = activity.LogActivity(ctx, h.database, workspaceID, activity.Payload{ Type: "memory_write", Source: "agent", Summary: fmt.Sprintf("commit_memory to %s", namespace), }) ``` Plus equivalent for `toolCommitSummary` (`memory_summary_write`?), `toolForgetMemory` (`memory_delete`?). `recall_memory` reads should NOT emit — too noisy and not useful for live UI refresh. ## Tracking Once this lands, the over-inclusive `agent_log` filter in `MemoryInspectorPanel.tsx` can be narrowed to just the memory-* types. The component already has a TODO-via-comment naming this issue in its filter block (added in #1749 review). ## Tier `area:memory` `area:observability` `tier:low` — quality-of-life for canvas Memory tab, no security or data implications. Should land after the A0+A1 memory cleanup train (#1742, #1747) so the LogActivity calls land on the v2-only code path. ## Refs - #1749 (canvas Memory tab live-refresh — this is the server-side counterpart) - #1733 (memory SSOT consolidation parent issue)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#1754