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 | 该问题是针对 MemOS 的,而不是一般软件问题
Bug Description | 问题描述
meta.rewardDirty is written when an episode is reopened, but if that episode subsequently reaches a terminal state through a path other than the ones that clear the marker, the marker is never removed. It is then indistinguishable from a live dirty state to both episodeRewardIsDirty() and a consistency watchdog built on json_type(meta_json,'$.rewardDirty') IS NOT NULL, so the episode is reported as dirty on every run — indefinitely — while being fully resolved.
Observed on a live installation: episode ep_ewndcv3q2ngk, 7 traces.
- scored heuristically and terminal-skipped —
meta.reward.skipped: true,traceCount: 2(1 turn, below the 2-exchange minimum) - reopened 89 s later —
meta.rewardDirty.reason: "episode_reopened",reopenedFor: "follow_up" - later recovered via
recoveryReason: "dirty_reward_rescore",closeReason: "finalized",rTask = 0.0
json_type(meta_json,'$.rewardDirty') still returns object 17 days later:
{"reason":"episode_reopened","reopenedFor":"follow_up","at":<ts>,"previousRTask":0,"previousScoredAt":<ts>}Manual json_remove(meta_json,'$.rewardDirty') clears every symptom immediately. Note that json_set(meta_json,'$.rewardDirty',NULL) does not — json_type then returns 'null', which is still IS NOT NULL, so any check written as a null-test keeps firing.
How to Reproduce | 如何重现
Not yet reproduced deterministically; the above is a live record. The ordering that appears to be required:
- Episode is scored and terminal-skipped → clears the marker (
core/reward/reward.ts:135). - Episode is reopened while
rTask != null || meta.reward→ re-sets the marker (core/session/episode-manager.ts:337). The skip-time clear has already run and will not run again. - Episode later reaches a terminal state through the recovery path, which finalizes it without touching the marker.
- Marker persists.
Expected: reaching a terminal/recovered state clears rewardDirty regardless of which path produced it.
Actual: marker persists; the episode is reported dirty forever.
Relevant code (verified against main, de806942)
Set:
core/session/episode-manager.ts:337— on reopen, gated onsnap.rTask != null || snap.meta.reward
Clear:
core/pipeline/memory-core.ts:1720— clears only inside the prior-failed-attempts rescan loop, and only for episodes that pass through it this passcore/pipeline/memory-core.ts:1757— clearsskipped && hasRewardDirtyMarkerrows, but over a bounded pagecore/reward/reward.ts:135and:276— clear at the moment a skip/terminal reward is written
The last three all clear at a specific moment or over a bounded page. Step 2 above re-dirties the episode after the moment-clear has passed, and the remaining two are the only later opportunities — so an episode that misses both keeps the marker permanently. Whichever of those two should have caught this row did not, which is the part worth confirming on the maintainer side; the durable fix is probably to drop the marker wherever the episode reaches a terminal reward state, rather than at each site that can write one.
Environment | 环境信息
- memos-local-plugin 2.0.16
algorithm.lightweightMemory.enabled: false- Linux (Debian-based), Node 22
- re-verified against upstream
main@de806942
Additional Context | 其他信息
Impact: an operator-facing consistency check reports the row on every run forever. That trains the reader to ignore the check, which is the same class of observability decay that made a separate monitoring review misdiagnose frozen metrics.
Relevant prior issues reviewed: #1847, #1784, #2120, #1966 — all different failure modes (dirty-scan/skip-path fixes, abandoned-episode skip, dirty-closed pagination, ghost-trace over-scoring). I could not find an existing report of the marker surviving on a resolved episode.
Activity
Memtensor-AI commentedon Sep 15, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
88cdc35c69732572Working branch:
bugfix/autodev-2370-20260915213740784Target 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(episode): clear reward.skipped on reopen to unblock dirty-rescore (…
Memtensor-AI commentedon Sep 15, 2026
✅ AutoDev task
88cdc35c69732572completed.Summary: Fixed a permanent
meta.rewardDirtymarker on episodes that were terminal-skipped and then reopened (issue #2370).Root cause:
episode-manager.ts reopen()correctly setsrewardDirty: {reason:"episode_reopened",...}on the episode meta, but leftmeta.reward.skipped: trueuntouched from the earlier heuristic-skip scoring pass.episodeRewardIsDirty()inmemory-core.tsevaluatesrewardWasSkipped()beforehasRewardDirtyMarker(), so the skip flag permanently short-circuited the function tofalse, making the episode invisible to every rescore scan path (init recovery loop, periodic dirty-closed scan, backoff filter). The marker was therefore never cleared.Fix: In
episode-manager.ts reopen(), when settingrewardDirty, also spreadreward.skipped: undefinedinto the reward object if the episode had previously been terminal-skipped. This is a targeted one-shot patch to the object written tometa; it does not change any other reward fields. The existingcollectDirtyClosedEpisodesbounded-page cleanup already handles any persisted rows that have the contradictory marker pair from before this fix.Tests: Added two regression tests to
tests/unit/session/episode-manager.test.ts: one asserting thatreward.skippedis cleared andrewardDirtyis set correctly after reopen on a previously-skipped episode, and one asserting thatrewardDirtyis not set when the episode was never scored. All 176 tests across 13 files pass.Base branch:
mainBranch:
bugfix/autodev-2370-20260915213740784Commit:
1885b7fPR: #2371
Assigned to: @hijzy
Reviewers: @whipser030, @hijzy
fix(episode): clear stale meta.rewardDirty on terminal transitions (M…
chiefmojo commentedon Sep 17, 2026
Second occurrence on the same installation, and the marker survives a fresh terminal transition
Environment: MemOS Local Plugin
2.0.16, Node, Linux, three agent instances (this is the same installation that filed the report, so this is an extension of the original case rather than an independent one).The first report's episode had a marker 17 days old — it could be read as an old residue that a cleanup pass simply hadn't reached. This one rules that out.
Episode
ep_w9p1b2stc3w1, 38 traces:meta.reward.skipped: true(the skip-time clear runs here).meta.rewardDirtyre-set (reason: "episode_reopened",reopenedFor: "follow_up"),reward.skippedlefttrue.closeReason: "finalized",rTask: 0.0.json_type(meta_json, '$.rewardDirty')still returnsobject.So the marker is not only "set on reopen and awaiting a rescore pass": it survives a subsequent terminal transition, on a row that is resolved by every other measure.
Observed state (fields that carry meaning):
{ "rTask": 0.0, "closeReason": "finalized", "reward": { "skipped": true, "traceCount": 18 }, "rewardDirty": { "reason": "episode_reopened", "reopenedFor": "follow_up" }, "trace_ids_length": 38 }The short-circuit is confirmed, not inferred. Removing the marker is the only change needed to make a null-test watchdog report clean — again JSON key removal, not a null-set. Nothing else about the row moved:
rTaskwas already terminal, no rescore ran, no new reward was written. That is consistent withepisodeRewardIsDirty()returningfalsefromrewardWasSkipped()before it ever evaluates the marker, so the row is never eligible for any of the paths that would clear it — a self-perpetuating state rather than a missed pass.One note for the fix attempt, so the retry doesn't stall the same way. PR #2371 was closed unmerged after review objected that clearing the flag by object-spreading
skipped: undefineddoes not remove the key —'skipped' in rewardremainstrue, so a consumer testing key existence still sees it. Onmain,rewardWasSkipped()reads(reward as { skipped?: unknown }).skipped === true, so anundefinedassignment does satisfy that predicate; but explicit key removal avoids the objection entirely, and clearing the marker at the terminal transitions (what the expected behaviour in the report asks for) sidesteps the question altogether.Happy to supply fuller timestamps, to verify a candidate patch against a scratch copy of this database, or to report whether a fix actually lands here — this installation has now hit the class twice, so it will show up if it recurs.
github-actions commentedon Oct 23, 2026
This issue has been automatically marked as stale due to inactivity.