openclaw - ✅(Solved) Fix openclaw tasks maintenance --apply should also prune session registry [1 pull requests, 3 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73867Fetched 2026-04-29 06:13:58
View on GitHub
Comments
3
Participants
4
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×3cross-referenced ×1

PR fix notes

PR #74023: [AI-assisted] fix(tasks): prune stale cron session registry entries

Description (problem / solution / changelog)

Summary

  • Problem: tasks maintenance did not prune stale cron session registry entries.
  • Why it matters: old cron run sessions can remain in the registry after run state has aged out, creating stale maintenance state.
  • What changed: added a maintenance sweep for stale cron session registry entries while preserving currently running cron jobs and non-cron sessions.
  • What did NOT change (scope boundary): no task scheduling, run execution, or non-cron session lifecycle behavior changed.

AI-assisted: yes, built with Codex. I understand the code changes and verified the focused regression locally.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #73867
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: maintenance cleaned task-related state but left stale cron run session registry entries behind.
  • Missing detection / guardrail: no regression covered pruning old cron session registry rows while preserving active jobs.
  • Contributing context (if known): N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/commands/tasks.test.ts
  • Scenario the test should lock in: tasks maintenance previews and applies stale cron session registry pruning, preserves running cron jobs, and leaves non-cron sessions untouched.
  • Why this is the smallest reliable guardrail: it exercises the maintenance command behavior directly without involving cron execution.
  • Existing test that already covers this (if any): N/A
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

tasks maintenance output can now include a session registry maintenance line when stale cron session entries are found or pruned.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Windows
  • Runtime/container: local Node.js / pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): N/A

Steps

  1. Create stale cron session registry entries older than the maintenance cutoff.
  2. Run tasks maintenance in preview/apply modes.
  3. Confirm stale cron sessions are reported/pruned while running cron jobs and non-cron sessions remain.

Expected

  • Stale cron run session registry entries are pruned by maintenance.

Actual

  • Before this change, stale cron run sessions stayed in the registry.

Evidence

  • Failing test/log before + passing after

Focused local validation:

node scripts/test-projects.mjs src/commands/tasks.test.ts
Test Files  1 passed (1)
Tests       3 passed (3)

Human Verification (required)

  • Verified scenarios: focused regression in src/commands/tasks.test.ts; git diff --check before commit.
  • Edge cases checked: running cron jobs are preserved; non-cron sessions are not pruned by this sweep.
  • What you did not verify: full repo pnpm test / pnpm check.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: accidentally pruning an active cron session.
    • Mitigation: the maintenance sweep preserves sessions for cron jobs currently marked running in jobs-state.json, and regression coverage locks this in.

Changed files

  • docs/automation/tasks.md (modified, +3/-1)
  • docs/cli/tasks.md (modified, +5/-1)
  • src/commands/tasks.test.ts (modified, +117/-3)
  • src/commands/tasks.ts (modified, +152/-1)
RAW_BUFFERClick to expand / collapse

Currently 'tasks maintenance' only prunes task-flows. With registry cleanup not yet handled by agent_end (see related issue), maintenance should also offer a session registry sweep with conservative criteria (entries with updatedAt >7d AND not currently in jobs-state.json running set).

extent analysis

TL;DR

Implement a session registry sweep in the 'tasks maintenance' process to remove outdated entries.

Guidance

  • Identify the current implementation of 'tasks maintenance' and extend it to include a session registry sweep.
  • Define the conservative criteria for removing entries: updatedAt > 7d and not present in the jobs-state.json running set.
  • Develop a method to query the session registry and filter out entries based on the defined criteria.
  • Test the updated 'tasks maintenance' process to ensure it correctly removes outdated session registry entries.

Example

# Pseudo-code example, actual implementation may vary
def sweep_session_registry():
    outdated_entries = session_registry.query(updatedAt < datetime.now() - timedelta(days=7))
    running_jobs = load_running_jobs_from_json()
    entries_to_remove = [entry for entry in outdated_entries if entry not in running_jobs]
    session_registry.remove(entries_to_remove)

Notes

The implementation details may vary depending on the actual technology stack and database schema used. This guidance assumes a basic understanding of the existing 'tasks maintenance' process and session registry structure.

Recommendation

Apply workaround: Implement the session registry sweep in the 'tasks maintenance' process, as the related issue regarding agent_end handling registry cleanup is still pending.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix openclaw tasks maintenance --apply should also prune session registry [1 pull requests, 3 comments, 4 participants]