Skip to content

fix(memory): degrade Memory page gracefully when proactive memory is disabled#3131

Merged
houko merged 4 commits into
mainfrom
fix/memory-page-disabled-proactive
Apr 25, 2026
Merged

fix(memory): degrade Memory page gracefully when proactive memory is disabled#3131
houko merged 4 commits into
mainfrom
fix/memory-page-disabled-proactive

Conversation

@houko

@houko houko commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3070 — Memory page was unusable when [memory.proactive] enabled = false. Two underlying issues, both addressed in this PR.

Server (crates/librefang-api/src/routes/memory.rs)

  • /api/memory and /api/memory/stats previously returned 500 with "Proactive memory is not enabled" when proactive was off. That's a config state, not a server error.
  • Now return 200:
    • GET /api/memory{ memories: [], total: 0, proactive_enabled: false }
    • GET /api/memory/stats{ stats: null, proactive_enabled: false }
  • When proactive IS enabled the responses gain a proactive_enabled: true flag alongside the existing fields — no breaking changes to the response shape.
  • The internal get_pm_store() helper still returns its 500 for endpoints that genuinely require proactive memory (search, ingest, etc.); only the read-list and stats endpoints degrade gracefully.

Dashboard (MemoryPage.tsx + new query)

  • New useAgentKvMemory(agentId) hook hitting /api/memory/agents/{id}/kv. Query key from memoryKeys.agentKv(agentId) factory entry — never inline arrays.
  • New "Per-agent KV memory" section renders unconditionally — lists agents and shows each agent's KV pairs (key / value / source / created_at).
  • When proactive_enabled === false: hide proactive sections (search, semantic, stats), show a small notice card explaining the state, keep KV section visible.
  • When proactive_enabled === true: keep the proactive sections as before AND show the KV section underneath. Most users don't distinguish proactive vs KV — issue prefers the unified view.

Test plan

Server-side tests already in crates/librefang-api/tests/api_integration_test.rs (4 cases):

  • test_memory_list_returns_200_when_proactive_disabled
  • test_memory_stats_returns_200_when_proactive_disabled
  • test_memory_list_includes_proactive_enabled_when_enabled
  • test_memory_stats_includes_proactive_enabled_when_enabled

Dashboard manual checks:

  • [memory.proactive] enabled = false → Memory page renders KV memories without error
  • [memory.proactive] enabled = true → Memory page renders proactive sections + KV section underneath
  • Agent with no KV memories → empty-state row, no error
  • Existing useMemoryStats callers still get the same fields (stats top-level just gains proactive_enabled: true)

Closes #3070.

…disabled

Closes #3070.

Server: `/api/memory` and `/api/memory/stats` previously returned HTTP
500 with "Proactive memory is not enabled" when `[memory.proactive]
enabled = false`. That's a config state, not a server error — 500
triggers retries and error reporting that don't apply here. Both
endpoints now return 200 with an explicit `proactive_enabled: bool`
flag and empty/null payloads, so the dashboard can render an
explanatory notice instead of an error banner.

When proactive is enabled the same `proactive_enabled: true` flag is
added alongside the existing fields, so old clients that only read
`memories` / `stats.*` keep working unchanged.

Dashboard: MemoryPage previously only queried the proactive endpoints
and ignored `/api/memory/agents/{id}/kv` entirely — agents with real
KV memories saw an empty page. Add a `useAgentKvMemory` hook routed
through the standard query-key factory, plus a "Per-agent KV memory"
section that always renders. When proactive is disabled the page
hides the search/semantic/stats panels and shows just the KV section
plus a notice; when enabled it shows both.

Server-side tests cover both branches of both endpoints; dashboard
behaviour is verified by the existing query hook tests plus a small
factory-key test.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added the ready-for-review PR is ready for maintainer review label Apr 25, 2026
github-actions Bot and others added 2 commits April 25, 2026 12:44
Self-review found the row-level `title={formatted}` would inline the
entire KV value (potentially multi-KB JSON blobs) into the DOM as a
hover preview. With 50 agents each carrying a few large KV entries,
that adds up to MBs of attribute strings the user never reads.

Cap the preview at 2000 chars (10x the visible truncation) — long
enough that hovering still reveals "more than fits", short enough that
a runaway value can't bloat the page. Full value still lives on the
server; if we ever need a true "view full" affordance it should be a
modal, not a tooltip.
@github-actions github-actions Bot added the size/L 250-999 lines changed label Apr 25, 2026
Two CI fixes for #3131:
- Quality: cargo fmt wanted the `loopback_get` request builder on
  one line. Self-fix.
- OpenAPI Drift: the new `proactive_enabled` field on /api/memory
  and /api/memory/stats was added in source but the committed
  openapi.json was stale. `cargo xtask codegen --openapi` regenerates
  it; the four SDKs round-trip identically (serde_json::Value response
  body — no typed schema change), so only openapi.json moved.
@houko
houko merged commit 36c2e39 into main Apr 25, 2026
20 checks passed
@houko
houko deleted the fix/memory-page-disabled-proactive branch April 25, 2026 13:45
@github-actions github-actions Bot removed the ready-for-review PR is ready for maintainer review label Apr 25, 2026
@houko houko mentioned this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 250-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory page is unusable when proactive memory is disabled (500 + no KV fallback)

1 participant