Repository navigation
fix(mcp): add memwal_namespaces tool and empty-namespace diagnostics (#416) - #1346
harrymove-ctrl wants to merge 3 commits into
Conversation
ducnmm
left a comment
There was a problem hiding this comment.
Please address the actionable issue below before merging. Validation was offline; no production writes or live load tests were run.
| if (namespaceContext) { | ||
| const { activeNamespace, namespaces } = namespaceContext; | ||
| const activeEntry = namespaces.find((ns) => ns.name === activeNamespace); | ||
| if (!activeEntry || activeEntry.memory_count === 0) { |
There was a problem hiding this comment.
[P2] Do not infer an empty namespace from an incomplete first page
tryListNamespaces fetches only 50 namespaces and drops has_more/next_cursor. If the queried namespace exists on a later page and recall has no semantic matches, activeEntry is missing here and the tool incorrectly reports that namespace holds 0 memories. This occurs on accounts with more than 50 namespace rows; the exact helpers reproduce it with has_more=true. Preserve page completeness and return an unknown/generic result, or finish pagination/perform a targeted lookup before asserting emptiness.
There was a problem hiding this comment.
Addressed in 3b6760d.
- Updated tryListNamespaces to preserve has_more and paginate across pages until the queried target namespace is found or pagination completes.
- Updated emptyRecallText so that when pagination is incomplete (has_more is true) and activeEntry is not found, the tool returns a generic 'No matching memories found in namespace "".' message instead of incorrectly asserting that the namespace holds 0 memories.
- Added unit tests verifying pagination traversal across pages and confirming that incomplete pages never trigger the empty-namespace diagnostic.
|
@ducnmm Updated in commit 9a188af to address review feedback:
Ready for re-review. |
Summary
memwal_namespacesMCP tool (readOnlyHint: true) backed bysession.memwal.listNamespaces({ limit, cursor })so agents can list populated namespaces along with their memory counts and storage usage.editDistance,isCloseNamespaceMatch,formatNamespaceSuggestionHint,tryListNamespaces) that best-effort querieslistNamespaces({ limit: 50 })when a target namespace has 0 memories.memwal_recallempty-result handling so an unpopulated or misspelled namespace is clearly distinguished (No matching memories found (namespace "<name>" currently holds 0 memories). Did you mean namespace "..."?) from a query with 0 semantic hits in a populated namespace, while degrading gracefully iflistNamespacesis unavailable.memwal_restoreso an empty namespace (total=0, restored=0, skipped=0, failed=0, truncated=false) explicitly statesNamespace "<name>" holds 0 on-chain blobs.and suggests close existing namespaces.memwal_namespacesand namespace spelling diagnostics indocs/mcp/overview.md,docs/mcp/quickstart.md, anddocs/mcp/reference.md.services/server/scripts/mcp/__tests__/namespace-diagnostics.test.tsandrestore.test.ts.Fixes #416
Test Plan
node --test --import tsx services/server/scripts/mcp/__tests__/*.test.ts(all MCP test suites pass)