Skip to content

fix: complete Issue #492 protection -- per-agent exclusion + configurable serial cooldown#521

Closed
jlin53882 wants to merge 3 commits intoCortexReach:masterfrom
jlin53882:fix/issue-492-v4
Closed

fix: complete Issue #492 protection -- per-agent exclusion + configurable serial cooldown#521
jlin53882 wants to merge 3 commits intoCortexReach:masterfrom
jlin53882:fix/issue-492-v4

Conversation

@jlin53882
Copy link
Copy Markdown
Contributor

Problem

Issue #492: memoryReflection hooks in before_prompt_build synchronously execute
LanceDB queries on every user session, causing 30-50% of sessions to fail.

Solution

Per-agent exclusion mechanism via autoRecallExcludeAgents + configurable serial cooldown.

Changes

1. isAgentOrSessionExcluded helper

Supports exact/wildcard-prefix/temp:* patterns.

2. Fixed auto-recall before_prompt_build exclusion check

Removed ineffective agentId !== undefined check.

3. Added exclusion checks to both reflection before_prompt_build hooks (priority 12 & 15)

isInternal guard + exclusion check.

4. Three-layer guard on runMemoryReflection command hook

  • Internal session guard
  • Re-entrant guard (Symbol.for + globalThis)
  • Serial cooldown guard (now configurable)

5. serialCooldownMs now configurable

Added to PluginConfig interface and openclaw.plugin.json schema.
Users can adjust via openclaw.json without code changes.

6. openclaw.plugin.json schema fixes

  • Added autoRecallExcludeAgents to top-level schema (previously only in TypeScript interface)
  • Added excludeAgents to memoryReflection.properties
  • Added serialCooldownMs to memoryReflection.properties
    (OpenClaw would strip these due to additionalProperties: false without schema definitions)

7. Added internal session guard to appendSelfImprovementNote

Consistent with agent:bootstrap hook.

8. Enhanced early-return logging with sessionKey/sessionId

Protection Matrix

Hook Protection
before_prompt_build (auto-recall) exclusion check
before_prompt_build (priority 12) isInternal guard + exclusion
before_prompt_build (priority 15) isInternal guard + exclusion
command:new/reset -> runMemoryRefl. three-layer guard
appendSelfImprovementNote internal session guard

openclaw.json Usage

{
  "memory-lancedb-pro": {
    "memoryReflection": {
      "serialCooldownMs": 60000
    },
    "autoRecallExcludeAgents": ["memory-distiller", "pi-", "temp:*"]
  }
}

Questions for Maintainers

  1. Is dual-purpose autoRecallExcludeAgents acceptable, or split into reflectionExcludeAgents?
  2. Is 120s default cooldown reasonable?
  3. Any concerns about globalThis + Symbol.for for lock maps?

Supersedes: closed PRs #515 and #520
Related to: #492
See also: Issue #514

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@jlin53882 jlin53882 closed this Apr 4, 2026
jlin53882 added a commit to jlin53882/memory-lancedb-pro that referenced this pull request Apr 4, 2026
Revert all changes except the isOwnedByAgent fix (src/reflection-store.ts):
- Remove import-markdown CLI (cli.ts) — tracked separately in PR CortexReach#426/CortexReach#482
- Remove autoRecallExcludeAgents config — tracked separately in PR CortexReach#516/CortexReach#521
- Remove idempotent register guard — separate feature request needed
- Remove recallMode parsing — unrelated to CortexReach#448
- Remove dual-memory docs (README.md) — already merged in PR CortexReach#367
- Remove script mode changes — unrelated
- Remove embedder/llm-client changes — unrelated
- Restore deleted nvidia test file — unrelated to CortexReach#448

Only src/reflection-store.ts isOwnedByAgent fix remains.
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.

1 participant