Skip to content

Fix #1514: Auto-recall hardcodes maxResults: 10, ignoring recall.maxResultsDefault config#1986

Open
Memtensor-AI wants to merge 1 commit into
dev-v2.0.22from
bugfix/autodev-1514
Open

Fix #1514: Auto-recall hardcodes maxResults: 10, ignoring recall.maxResultsDefault config#1986
Memtensor-AI wants to merge 1 commit into
dev-v2.0.22from
bugfix/autodev-1514

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Fixed issue #1514 — the before_prompt_build auto-recall hook in apps/memos-local-openclaw/index.ts hardcoded maxResults: 10 for both the local engine.search and the Hub hubSearchMemories calls, so recall.maxResultsDefault was effectively ignored on the auto-recall path.

The fix introduces a new optional recall.autoRecallMaxResults config field (option 2 from the issue) and replaces both literal 10 values with recallCfg.autoRecallMaxResults ?? recallCfg.maxResultsDefault ?? 10. This is a strict superset of the simpler "just read maxResultsDefault" fix: when the new field is unset the hook falls through to maxResultsDefault (which defaults to 6), so the effective behaviour for users with no config changes from 10 → 6 — exactly what the issue requests. Operators who want a richer memory_search set and a leaner auto-recall set can now configure them independently.

Touched files: apps/memos-local-openclaw/index.ts (hook resolution chain + comment), src/config.ts (carry the new field through resolveConfig), src/types.ts (type declaration with doc comment referencing issue #1514), README.md (Advanced Configuration entry), and tests/config.test.ts (3 new resolveConfig tests: undefined default, explicit override, independent control alongside maxResultsDefault).

Tests: npx vitest run tests/config.test.ts tests/integration.test.ts tests/recall.test.ts tests/worker-lifecycle.test.ts → 39 passed / 0 failed. tsc --noEmit clean. The 5 unrelated failures across accuracy.test.ts / skill-auto-install.test.ts / task-processor.test.ts / update-install.test.ts reproduce identically on the unmodified baseline (verified via git stash round-trip), so they are pre-existing and out of scope.

Related Issue (Required): Fixes #1514

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Automated tests are pending.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.

Reviewer Checklist

The `before_prompt_build` auto-recall hook in
`apps/memos-local-openclaw/index.ts` hardcoded `maxResults: 10` for both
the local `engine.search` and `hubSearchMemories` calls, so the
configured `recall.maxResultsDefault` was effectively ignored on the
auto-recall path. Users who lowered `maxResultsDefault` (e.g. 3 or 5) to
reduce auto-injected token cost still got ~10+10 candidates per turn.

Adds a new optional `recall.autoRecallMaxResults` config key (per
issue #1514 option 2) with the resolution order:
  autoRecallMaxResults -> maxResultsDefault -> 10 (defensive).

This is a strict superset of the simpler "just read maxResultsDefault"
fix — when `autoRecallMaxResults` is not set the hook falls through to
`maxResultsDefault`, while operators who want a richer `memory_search`
result set and a leaner auto-recall set can configure them separately.

Tests: new resolveConfig cases cover default-undefined / explicit
override / independent control alongside maxResultsDefault. The hook
change is a literal-to-variable substitution covered by the type and
resolver contract.

Refs: #1514

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated bug Something isn't working | 功能异常

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants