Skip to content

feat(memory): add per-agent auto-recall control#535

Open
itsmiso-ai wants to merge 1 commit intoCortexReach:masterfrom
itsmiso-ai:feat/per-agent-auto-recall-control
Open

feat(memory): add per-agent auto-recall control#535
itsmiso-ai wants to merge 1 commit intoCortexReach:masterfrom
itsmiso-ai:feat/per-agent-auto-recall-control

Conversation

@itsmiso-ai
Copy link
Copy Markdown

Implements per-agent auto-recall control as discussed in #474.

What was done

Problem

The memory-lancedb-pro plugin only supported a global autoRecall: true/false setting. Some agents (e.g. background cron workers, memory-distiller) should not have their output contaminated by auto-injected memories. Meanwhile, some agents work better with auto-recall while others don't (e.g. agents whose local LLM backend emits reasoning content to a separate field).

Solution

1. autoRecallExcludeAgents (blacklist mode)

  • Already implemented in the TypeScript logic but missing from the plugin schema — users couldn't configure it
  • Added to openclaw.plugin.json configSchema so it's now configurable via plugin settings

2. autoRecallIncludeAgents (whitelist mode) (new)

  • Added to interface, logic, parsing, and schema
  • When set, ONLY these agents receive auto-recall injection
  • Takes precedence over autoRecallExcludeAgents when both are set

Behavior

Config Result
Neither set All agents receive auto-recall (default, backward-compatible)
autoRecallIncludeAgents: ["saffron", "maple"] Only saffron and maple receive auto-recall
autoRecallExcludeAgents: ["cron-worker"] All agents EXCEPT cron-worker receive auto-recall
Both set autoRecallIncludeAgents wins (whitelist takes precedence)

Files changed

  • index.ts — interface, before_prompt_build logic, config parsing
  • openclaw.plugin.json — added autoRecallExcludeAgents and autoRecallIncludeAgents to configSchema
  • test/per-agent-auto-recall.test.mjs — 19 unit tests covering parsing and runtime logic

Tests

All 19 tests pass.

Closes #474

Implement per-agent auto-recall control as suggested in CortexReach#474:

- Add autoRecallIncludeAgents config option (whitelist mode): when set,
  ONLY these agents receive auto-recall injection
- autoRecallExcludeAgents was already implemented in logic but missing from
  the plugin schema — add it to configSchema so users can configure it
- autoRecallIncludeAgents takes precedence over autoRecallExcludeAgents when
  both are set
- Include schema definitions for both fields
- Add unit tests covering parsing, filtering, and mixed-agent runtime logic
- Tests: 19 passing
@itsmiso-ai itsmiso-ai force-pushed the feat/per-agent-auto-recall-control branch from 9079d96 to 6da96df Compare April 5, 2026 20:03
@win4r
Copy link
Copy Markdown
Collaborator

win4r commented Apr 6, 2026

@claude

@claude
Copy link
Copy Markdown

claude bot commented Apr 6, 2026

Claude Code is working…

I'll analyze this and get back to you.

View job run

@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Apr 6, 2026

Review Summary

Verdict: REQUEST-CHANGES | Value: 63% | Size: LARGE

What This PR Does

Adds per-agent auto-recall control (autoRecallIncludeAgents / autoRecallExcludeAgents) to the memory-lancedb-pro plugin, enabling selective memory injection for specific agents (e.g., disabling recall for background workers or local-LLM agents).

Must Fix

  1. F2 / EF2 — Tests unconfirmed: Full test suite timed out; the new 19 tests in test/per-agent-auto-recall.test.mjs were never confirmed passing.
  2. EF3 / MR1 — Tests not wired in: The new test file was excluded from the targeted test run and is not wired into npm test. Please add it to the test configuration.
  3. EF1 — Build failure: Build reports BUILD_FAILURE but build_error is null — cannot determine if regression or pre-existing.

Nice to Have

  • Schema descriptions claim include and exclude lists "Cannot be used together", but the runtime silently accepts both with whitelist-wins precedence. Consider warning or rejecting at config parse time.
  • agentId is never undefined at runtime (unresolvable agents fall back to 'main'), so the undefined guard is dead code.
  • Configured agent IDs are filtered but not trimmed — " myAgent " won't match "myAgent".
  • Mixed-agent scenario tests exercise a local JS stub, not the real before_prompt_build hook.

Bottom Line

Good feature — solves a real need. Please wire the new tests into npm test, confirm they pass, and resolve the build failure.


Automated review — 6 rounds | Primary: claude | Adversarial: codex

Copy link
Copy Markdown
Collaborator

@AliceLJY AliceLJY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: feat(memory): add per-agent auto-recall control

Verdict: Approve

What I checked

  1. Backward compatibility — Neither autoRecallIncludeAgents nor autoRecallExcludeAgents is required; when both are absent, all agents receive auto-recall as before. No breaking change.

  2. Schema alignmentautoRecallExcludeAgents was already implemented in TypeScript logic but missing from openclaw.plugin.json configSchema. This PR fixes that gap and adds the new autoRecallIncludeAgents alongside it. Both schema entries use { type: "array", items: { type: "string" }, default: [] }, consistent with the rest of the schema.

  3. Precedence logic — The before_prompt_build hook correctly implements: include list (if non-empty) takes precedence over exclude list. When agentId is undefined, the filter block is skipped entirely, which is the right default (no agent context = allow recall). This is well-documented in code comments.

  4. Config parsingparsePluginConfig filters both arrays to reject non-string and whitespace-only entries, matching the existing autoRecallExcludeAgents pattern. The empty-array-stays-as-empty-array behavior is correct and the runtime checks length > 0 before activating.

  5. Tests — 19 tests covering:

    • Parsing edge cases (undefined, valid array, non-string filtering, whitespace, empty array, single ID)
    • Runtime logic simulation via a faithful shouldInjectMemory helper (whitelist mode, blacklist mode, precedence, no config, undefined agentId, empty include fallthrough)
    • Uses real parsePluginConfig via jiti, not mocks
  6. CI — cli-smoke pass, version-sync pass.

Minor note (non-blocking)

The description says "Cannot be used together with autoRecallExcludeAgents" but the parser accepts both and the runtime silently picks include over exclude. This is fine for UX (no crash), but consider adding a startup warning log when both are configured, to help users catch misconfiguration. Not a blocker.

Closes #474. LGTM.

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.

Feature request: per-agent auto-recall control

4 participants