Skip to content

fix: respect framework-level memorySearch.enabled switch in autoRecall#141

Open
eisen0419 wants to merge 1 commit intoCortexReach:masterfrom
eisen0419:fix/issue-58-respect-memory-search-enabled
Open

fix: respect framework-level memorySearch.enabled switch in autoRecall#141
eisen0419 wants to merge 1 commit intoCortexReach:masterfrom
eisen0419:fix/issue-58-respect-memory-search-enabled

Conversation

@eisen0419
Copy link

Summary

Fixes #58autoRecall now respects the framework-level memorySearch.enabled switch.

Previously, when agents.defaults.memorySearch.enabled = false in OpenClaw config, the plugin still executed auto-recall because the before_agent_start handler did not check the framework-level setting.

Changes

  • Added resolveFrameworkMemorySearchEnabled(cfg, agentId) helper that reads memorySearch.enabled from api.config, checking agent-specific override first (agents.list[].memorySearch.enabled), then falling back to agents.defaults.memorySearch.enabled
  • Added early return in before_agent_start handler when framework memorySearch.enabled = false, with a debug log message
  • Moved agentId resolution earlier in the handler to support the check (no behavioral change for the existing code path)

Precedence

agents.defaults agent-specific Result
false not set skip recall
false true allow recall
true false skip recall
not set not set allow recall (unchanged)

Test plan

  • New standalone test file test/issue-58-framework-memory-search.test.mjs with 3 cases:
    • defaults.memorySearch.enabled=false → skips recall, 0 embedding requests
    • defaults=false + agent override true → allows recall
    • defaults=true + agent override false → skips recall
  • Existing test/config-session-strategy-migration.test.mjs still passes

@AliceLJY
Copy link
Collaborator

Review: fix: respect framework-level memorySearch.enabled switch in autoRecall

Verdict: Fix-then-merge — same blocking item as #148.


✅ What's working

  • Priority chain is correct: agent-level override → agents.defaultsundefined (allow recall). Existing users with no memorySearch config see zero behavior change
  • Early return placement is right — framework permission check happens before shouldSkipRetrieval(), not after
  • Test infrastructure is solid: real HTTP embedding server mock makes the assertions trustworthy (no false passes from over-mocking)
  • All 3 test cases pass, including the agent-override-wins scenarios
  • agentId move to top of handler is a clean refactor; resolveHookAgentId is pure, no side effects

🔴 Blocking (same issue as #148)

New test file is not wired into npm test. issue-58-framework-memory-search.test.mjs is missing from package.json scripts — CI never runs it.

Fix: append to the test script in package.json:

&& node --test test/issue-58-framework-memory-search.test.mjs

🟡 Suggested before merge

Missing backward-compat test — the most common real-world scenario (user upgrades without adding memorySearch to config) has no test coverage. Adding one case would close the gap:

test("issue #58: no memorySearch config → recall proceeds normally", async () => {
  const outcome = await runAutoRecallScenario({}); // empty OpenClaw config
  assert.ok(outcome.requests > 0);
});

⚪ Non-blocking

  • NODE_PATH hardcodes /opt/homebrew — harmless in Docker (jiti resolves without it), but worth making portable
  • catch { // ignore } in resolveFrameworkMemorySearchEnabled is intentionally fail-open; a short comment would help future readers

Merge order note

This should merge before #123 (fresh-session continuity fix) since both touch the autoRecall skip logic. #148 can go in either order — different files.

Good fix. The two-level config lookup matches how OpenClaw models other agent settings (e.g. resolveAgentPrimaryModelRef follows the same pattern).

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.

autoRecall 绕过了框架层 memorySearch.enabled 开关

2 participants