Skip to content

Cron session accumulation can silently exhaust agent context window — no guardrails or warnings #38730

Description

@LindalyX-Lee

Draft GitHub Issue

Title: Cron session accumulation can silently exhaust agent context window — no guardrails or warnings

Problem

High-frequency OpenClaw cron jobs (e.g. every 15m / every 30m) continuously create isolated run sessions and grow the session store without visible guardrails. In a real incident, the main agent session context grew to 152k/272k (56%) and the session store reached 113 active entries. Eventually, the agent stopped replying to new inbound messages even though channels looked healthy (“all green”) — the logs showed dispatch succeeded but produced replies=0.

This failure mode is hard to diagnose because gateway/channel status can appear normal while the agent silently fails due to context/session pressure.

Evidence / Repro signals (from incident)

  • In openclaw logs --follow (and likely /tmp/openclaw/openclaw-2026-03-07.log), messages were dispatched but no reply produced:
    • [feishu] feishu[default]: dispatching to agent (session=agent:main:main)
    • [feishu] feishu[default]: dispatch complete (queuedFinal=false, replies=0)
  • openclaw sessions showed:
    • agent:main:main direct ... gpt-5.2 152k/272k (56%)
  • openclaw sessions cleanup did not reduce entries:
    • Applied maintenance. Current entries: 113 (before/after unchanged)

Root causes (missing guardrails)

  1. Cron run sessions have no TTL / auto-expiry, so store grows indefinitely
  2. No session count / context usage threshold warnings
  3. No guardrail on creating high-frequency cron jobs (no warning, no recommended minimum interval)
  4. sessions cleanup appears too weak for completed cron runs (does not reclaim)

Impact

Any user using cron can accidentally degrade the assistant until it becomes non-responsive, with a “green status but not working” symptom.

Environment

  • OpenClaw 2026.3.2
  • macOS
  • ~8 cron jobs; high-frequency examples:
    • fa44760a-b511-42bd-aeec-76233a515fa5watch-openclaw-issue-pr-37232-37234 — every 15m
    • d5b80f10-6020-4cec-8689-f97fdc68530cwatch-openai-codex-gpt54 — every 30m

Workaround

Disable high-frequency cron jobs + restart gateway:

  • openclaw cron disable <jobId>
  • openclaw gateway restart

Proposed solutions

  • Session TTL for cron runs: completed isolated cron run sessions auto-expire (e.g. 24h) and are reclaimed
  • Context usage warnings: warn when main session context exceeds threshold (e.g. 70%)
  • Cron frequency guardrail: warn when creating jobs with interval < 30m
  • Improve sessions cleanup: actually reclaim completed cron run sessions

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions