Skip to content

algorithm.lightweightMemory.enabled: true does not actually skip evolution pipeline (reward/L2/L3/skill still run) #2063

Closed

Description

@llitost

Environment

  • @memtensor/memos-local-plugin v2.0.8
  • Adapter: opencode
  • OS: macOS

Config

algorithm:
  lightweightMemory:
    enabled: true

Expected behavior

The schema comment says:

When enabled, the runtime skips task/reward/L2/L3/skill evolution and keeps only summarize + embedding + retrieval filter.

Expected: skill_generate / world_model_generate / policy_evolve / policy_generate stop triggering LLM calls.

Actual behavior

All evolution calls continue firing regardless of the flag. Confirmed via api_logs table:

SELECT tool_name, count(*), datetime(max(called_at)/1000,'unixepoch') as last
FROM api_logs
WHERE tool_name IN ('skill_generate','world_model_generate','policy_evolve')
GROUP BY tool_name;

Results (with lightweightMemory.enabled: true active throughout):

tool_name count
skill_generate 19,193 (failure rate 97.5%)
world_model_generate 4,724 (failure rate 99.6%)
policy_evolve 2,122

Root cause (identified)

buildPipelineSubscribers in dist/core/pipeline/deps.js unconditionally creates and attaches all subscribers (rewardRunner, L2, L3, skill) — the lightweightMode flag does not gate this:

export function buildPipelineSubscribers(deps, buses, algorithm, session) {
    const captureRunner = createCaptureRunner({...})
    const rewardRunner = createRewardRunner({...})  // always created
    // L2, L3, skill runners created unconditionally as well

lightweightMode only does an early return inside flush(), but the subscribers are already mounted on the event bus. The episode.finalized event still triggers the full evolution chain.

Additionally, recoverOpenEpisodesAsSessionEnd at startup re-emits episode.finalized for all previously closed episodes that lack meta.lightweightMemory === true, causing a large backlog of evolution calls after every bridge restart.

Suggested fix

In buildPipelineSubscribers, skip mounting reward/L2/L3/skill subscribers when lightweightMode is true:

export function buildPipelineSubscribers(deps, buses, algorithm, session) {
    const lightweightMode = algorithm.lightweightMemory.enabled;
    const captureRunner = createCaptureRunner({...})
    
    if (!lightweightMode) {
        // only create rewardRunner, L2, L3, skill when needed
        const rewardRunner = createRewardRunner({...})
        // ...
    }

Or alternatively, check lightweightMode at the top of each subscriber's event handler and return early before any LLM call.

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    types:bugSomething isn't working | 功能异常
    contrib:help wantedExtra attention is needed | 需要社区帮助
    and removed
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jul 6, 2026
  2. added theissue type on Jul 7, 2026
  3. added
    status:readyReady for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    and removed
    status:readyReady for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发
    on Jul 8, 2026
  4. Memtensor-AI commented on Jul 8, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 00ce0051970d8558
    Working branch: feature/autodev-2063-20260708064514092
    Target branch: latest dev* branch
    Workflow: 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.

  5. Memtensor-AI commented on Jul 8, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 00ce0051970d8558 completed.

    Summary: Fixed issue #2063 — algorithm.lightweightMemory.enabled: true now actually skips the evolution pipeline in @memtensor/memos-local-plugin. Two independent root causes were addressed. First, buildPipelineSubscribers in apps/memos-local-plugin/core/pipeline/deps.ts used to attach reward / L2 / L3 / skill / feedback subscribers unconditionally, so every episode.finalized event still cascaded through the LLM-heavy chain — the fix short-circuits the subscriber wiring and returns no-op stubs whose drain/stop/detach/dispose are safe to call from flush() / shutdown(), and whose runner methods throw with a "lightweight mode" message if reached (every real caller is already gated on the flag). Second, memory-core.ts startup + periodic recovery paths (init, autoFinalizeStaleTasks, autoRescoreDirtyClosedEpisodes) used to re-emit episode.finalized for legacy episodes lacking meta.lightweightMemory === true, producing the >19k skill_generate / >4.7k world_model_generate / >2.1k policy_evolve backlog reported in the issue — those paths now close orphan / stale / dirty-closed episodes silently when the flag is on and tag their meta so subsequent restarts stay quiet. Regression coverage added at tests/unit/pipeline/lightweight-mode.test.ts: three tests exercising normal-mode listener presence, lightweight-mode listener absence on capture / reward / L2 buses, and a synthetic episode.finalized recovery emission that must produce zero reward / L2 / L3 / skill events. All 50 existing pipeline unit tests + the openclaw full-chain integration test still pass; TypeScript strict typecheck (tsc --noEmit) is clean. Three pre-existing test failures (startup-recovery, storage/migrator, v7-full-chain e2e) reproduce on the pristine base branch and are out of scope.

    Base branch: main
    Branch: feature/autodev-2063-20260708064514092
    Commit: c80d351
    PR: #2074
    Assigned to: @hijzy
    Reviewers: @hijzy

  6. added
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jul 8, 2026
  7. added a commit that references this issue on Jul 9, 2026
    de03ab2
  8. added
    area:memory记忆存储、检索、更新、召回逻辑
    and removed
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    on Jul 9, 2026
  9. added a commit that references this issue on Sep 18, 2026
    78091f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:memory记忆存储、检索、更新、召回逻辑area:pluginOpenClaw & Hermescontrib:help wantedExtra attention is needed | 需要社区帮助

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions