Repository navigation
Description
Pre-submission checklist
- I have searched existing issues and this hasn't been mentioned before
- I have read the project documentation and confirmed this issue doesn't already exist
- This issue is specific to MemOS and not a general software issue
Bug Description
When @memtensor/memos-local-openclaw-plugin is used as the OpenClaw memory slot, cron runs can be contaminated by prior meta-discussion about the cron itself.
The plugin performs auto-recall in before_agent_start for every turn. For cron runs, it uses the cron prompt as the recall query, which causes it to retrieve previous conversations about prompt tuning, policy changes, debugging, and rerun requests for that same cron job.
Those recalled memories are then injected back into the scheduled run as system context, so the cron output drifts away from the actual task and starts replying with unrelated meta-discussion.
Observed effects include:
- cron output says things like “I already changed the cron”
- output summarizes previous human discussions about task policy
- output mentions rerun/debugging status instead of only executing the scheduled task
- session logs contain injected memory blocks beginning with:
## User's conversation history (from memory system)
This is especially harmful for autonomous scheduled jobs because it changes task semantics.
How to Reproduce
- Install and enable
@memtensor/memos-local-openclaw-pluginas the OpenClaw memory slot. - Create an OpenClaw cron job with a stable name and repeated scheduled runs.
- Run the cron normally at least once.
- In regular chat, discuss this cron job several times, for example:
- ask why its output is wrong
- ask to rewrite its prompt or policy
- discuss whether it should trade or not trade
- ask for reruns, debugging, or cron body changes
- Let the cron run again.
- Observe that the cron output begins to include prior meta-discussion instead of only the intended scheduled task output.
A representative session key pattern is:
agent:main:cron:<jobId>
Relevant observations during reproduction:
- runtime logs showed auto-recall queries derived from the cron prompt itself
- session logs showed injected memory blocks starting with:
## User's conversation history (from memory system)
- disabling the plugin and resetting the cron session immediately stopped the contamination
Environment
- Repository:
MemTensor/MemOS - Plugin package:
@memtensor/memos-local-openclaw-plugin - Plugin version:
1.0.3 - OpenClaw version:
v2026.3.11 - Node.js runtime observed in gateway logs:
v22.20.0 - Deployment: self-hosted OpenClaw gateway on Linux via
systemd --user - Plugin role: configured as the OpenClaw memory slot
- OpenClaw built-in memory search: disabled
Additional Context
This appears to be in the same problem family as existing issues/PRs around auto-recall and injected prompt contamination, but I could not find one specific to cron sessions.
From local investigation, the root cause appears to be:
- auto-recall runs for cron turns without any cron/session exclusion
- the recall query is built from the cron prompt itself
- the cron uses a stable session key namespace like
agent:main:cron:* - prior meta-discussion about the cron becomes highly retrievable and is injected back into later runs
Suggested fixes:
- skip auto-recall by default for cron sessions, e.g.
agent:*:cron:* - or add config such as:
autoRecall.excludeCron = trueautoRecall.excludeSessionKeyPrefixes
- or avoid using full cron prompts as recall queries
- or suppress recall of memories that are clearly meta-discussion about the current cron/job itself
Willingness to Implement
- I'm willing to implement this myself
- I would like someone else to implement this
Activity
[-]fix:[/-][+]bug(openclaw-plugin): auto-recall contaminates cron runs with prior meta-discussion[/+]Vran9 commentedon Mar 21, 2026
me too
fix(openclaw-plugin): skip auto-recall for cron sessions to prevent m…
github-actions commentedon Apr 23, 2026
This issue has been automatically marked as stale due to inactivity.
MaiHHConnect commentedon Jun 2, 2026
Memtensor-AI commentedon Jun 29, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
361246167d2f06abWorking branch:
bugfix/autodev-1311Target branch:
latest dev* branchWorkflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
fix(openclaw-plugin): skip auto-recall for cron sessions (#1311)
Memtensor-AI commentedon Jun 29, 2026
✅ AutoDev task
361246167d2f06abcompleted.Summary: Fixed GitHub issue #1311 (openclaw-plugin cron-run contamination by auto-recall).
Root cause: the
before_prompt_buildhook inapps/memos-local-openclaw/index.tsignoredhookCtx.sessionKeyand used the cron prompt itself as the recall query. Because cron jobs reuse stable session keys of the formagent:<id>:cron:<jobId>and prior meta-discussion about the cron (prompt tuning, debugging, rerun requests) lives under the same agent owner with vocabulary that mirrors the cron body, those discussions ranked highest and got injected back as a## User's conversation history (from memory system)system block on the next scheduled run, derailing the cron output.Fix: added a new pure helper
shouldSkipAutoRecallForSession(sessionKey, cfg)inapps/memos-local-openclaw/src/recall/session-policy.tsand an early-return gate at the top of the hook that short-circuits the entire memory + skill auto-recall path for cron / excluded session keys. Behaviour is controlled by a new optionalautoRecallconfig block onMemosLocalConfigwithexcludeCron(default true) andexcludeSessionKeyPatterns(default empty). The cron-segment matcher is/(?:^|:)cron(?::|$)/i, which is:-boundary aware so identifiers likecronosare not caught. Capture and the explicitmemory_search/memory_gettools are intentionally untouched — only the automatic injection is suppressed inside cron runs.Tests: 9 unit cases for the policy helper (default behaviour, cron-segment matching, boundary guard, opt-out, custom regex, invalid regex fallback) plus 4 integration cases that drive the actual hook with mocked storage/engine/summarizer and assert
RecallEngine.searchis/isn't called depending on session key + config.npx vitest run tests/{session-policy,auto-recall-cron-gate,config,plugin-openclaw-wiring,openclaw-fallback}.test.ts→ 5 files, 32 tests pass.npx tsc --noEmit→ exit 0.Diff is contained to 6 files inside
apps/memos-local-openclaw/: index.ts (8-line early-return gate + 1 import), src/recall/session-policy.ts (new helper), src/types.ts (newAutoRecallConfiginterface), src/config.ts (defaultautoRecallblock inresolveConfig), tests/session-policy.test.ts (new), tests/auto-recall-cron-gate.test.ts (new). No DB schema change, no public tool-API change, no data migration.Base branch:
mainBranch:
bugfix/autodev-1311Commit:
befb899PR: #1970
Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
Fix #1311: bug(openclaw-plugin): auto-recall contaminates cron runs w…