Skip to content

fix: preserve original memory types in search responses - #1646

Merged
rohitg00 merged 4 commits into
rohitg00:mainfrom
reevesc88:fix/preserve-memory-type
Nov 4, 2026
Merged

rohitg00 merged 4 commits into
rohitg00:mainfrom
reevesc88:fix/preserve-memory-type

Conversation

@reevesc88

@reevesc88 reevesc88 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Saving a memory with type: "fact" returns that type, but search currently exposes only type: "decision" after converting the memory into an observation. Clients therefore lose the original memory category when they recall or expand the same ID.

This adds optional memoryType: Memory["type"] metadata while keeping the observation type enum unchanged. Compact smart search and expanded results preserve the saved category. Recall retains it in full, compact and narrative formats, including budget-clipped previews. Compact smart search reads the already-authorized durable row so existing indexes work without a migration. The standalone fallback adds the same metadata while retaining its existing compact response fields.

Regression coverage exercises all six memory types, legacy index results, compact and expanded search, recall clipping, ordinary observations and lessons, standalone fallback, and project/agent boundaries. docs/recall.md documents the response contract. The generated test-count updates are included as required by AGENTS.md.

Validation on base c6c476d2905926727fa5848a134d7a3b38a7fa98:

  • npm run build
  • npm run skills:gen
  • npm run docs:sync
  • npm run skills:check
  • npm test -- --maxWorkers=4: 4,118 passed, six skipped
  • npm run docs:check
  • git diff --check

The dependency audit reports nine moderate findings in the unchanged dependency graph. This PR does not change dependencies. The live-server integration test and skipped unit cases were not run.

Summary by CodeRabbit

  • New Features
    • Search and recall results now preserve and display a saved memory’s original type alongside its normalized decision type.
    • The original type is included in compact, expanded, and clipped results when available.
  • Documentation
    • Clarified how memory types appear in results and noted that existing indexes need no migration.

Signed-off-by: reevesc88 <calum@ai1auslutions.com>
@vercel

vercel Bot commented Oct 31, 2026

Copy link
Copy Markdown

@reevesc88 is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The PR adds optional memoryType metadata to memory observations and compact search results. Memory search and recall responses expose the original saved type while retaining the observation type as "decision".

Changes: Memory type metadata

Layer / File(s) Summary
Metadata contract and conversion
src/types.ts, src/state/memory-utils.ts, test/memory-type-metadata.test.ts
Compressed observations and compact search results add optional memoryType fields. Memory conversion copies the saved type to memoryType and keeps type as "decision". Tests cover the type values, input preservation, and schema validation.
Smart-search metadata
src/functions/smart-search.ts, src/mcp/standalone.ts, test/memory-type-metadata.test.ts, test/mcp-standalone.test.ts
Compact memory search resolves the saved type from KV.memories and falls back to the observation’s memoryType when needed. The standalone fallback returns "decision" as type and the saved type as memoryType. Tests cover legacy indexes, read failures, filters, and saved-type preservation.
Recall responses and validation
src/functions/recall-response.ts, test/memory-type-metadata.test.ts, docs/recall.md
Recall formats include memoryType when defined. Tests cover clipping, response formats, and omission for lessons and ordinary observations. Documentation describes the metadata and compatibility behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: rohitg00

Merge Risk: Low · up to 00a76

Memory categories are preserved across search and recall. Compact search adds storage reads that can delay results or cause a timeout when storage stalls; this bounded reliability concern warrants owner awareness or follow-up.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: preserve original memory types in search responses" matches the main change. The PR adds an optional memoryType field so smart search, expanded results, and recall keep each memory's…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix: preserve original memory types in search responses" matches the main change. The PR adds an optional memoryType field so smart search, expanded results, and recall keep each memory's saved category while the observation type stays "decision". The title is specific, concise, and follows a conventional commit prefix. It does not cover the docs, tests, or standalone fallback changes, which is acceptable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 7 files. (36 skipped: 36 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 393c019e-3b99-472f-8095-e55f8914e5c9
Commits

Reviewing files that changed from the base of the PR and between c6c476d and b41a517.

Files ignored due to path filters: 2
  • assets/tags/light/stat-tests.svg is excluded by !**/*.svg
  • assets/tags/stat-tests.svg is excluded by !**/*.svg
Files selected for processing: 43
  • AGENTS.md
  • README.md
  • READMEs/README.ar-SA.md
  • READMEs/README.bn-BD.md
  • READMEs/README.cs-CZ.md
  • READMEs/README.da-DK.md
  • READMEs/README.de-DE.md
  • READMEs/README.el-GR.md
  • READMEs/README.es-ES.md
  • READMEs/README.fi-FI.md
  • READMEs/README.fr-FR.md
  • READMEs/README.he-IL.md
  • READMEs/README.hi-IN.md
  • READMEs/README.hu-HU.md
  • READMEs/README.id-ID.md
  • READMEs/README.it-IT.md
  • READMEs/README.ja-JP.md
  • READMEs/README.ko-KR.md
  • READMEs/README.nb-NO.md
  • READMEs/README.nl-NL.md
  • READMEs/README.pl-PL.md
  • READMEs/README.pt-BR.md
  • READMEs/README.pt-PT.md
  • READMEs/README.ro-RO.md
  • READMEs/README.ru-RU.md
  • READMEs/README.sv-SE.md
  • READMEs/README.th-TH.md
  • READMEs/README.tl-PH.md
  • READMEs/README.tr-TR.md
  • READMEs/README.uk-UA.md
  • READMEs/README.ur-PK.md
  • READMEs/README.vi-VN.md
  • READMEs/README.zh-CN.md
  • READMEs/README.zh-TW.md
  • docs/recall.md
  • scripts/docs-sync.state.json
  • src/functions/recall-response.ts
  • src/functions/smart-search.ts
  • src/mcp/standalone.ts
  • src/state/memory-utils.ts
  • src/types.ts
  • test/mcp-standalone.test.ts
  • test/memory-type-metadata.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

…n fallback type

- A rejected read of the stored memory while building compact results
  rejected the whole smart-search call. The read now falls back to the
  memoryType already on the ranked observation.
- Standalone fallback compact results now report type "decision", the
  same as daemon results, with the saved category in memoryType.
@rohitg00
rohitg00 merged commit 4f7252d into rohitg00:main Nov 4, 2026
1 of 2 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.

2 participants