Skip to content

Defaults cause unbounded transcript growth + nightly session death (coding-agent workloads) #85025

Closed

Description

@BytePickers

Defaults cause unbounded transcript growth + nightly session death (coding-agent workloads)

Summary

OpenClaw's out-of-the-box defaults make a long-running coding-agent / ops-assistant deployment unsafe to leave alone: sessions are killed nightly (memory-loss), and transcripts grow without bound until they degrade the runtime. Every operator has to discover the same five hardening knobs the hard way and re-apply them on every host.

We've now applied the same defensive config on three hosts (.221 production with 36+ agents, .237 reinstall, .239 ops). On each host we had to repeat the same five-layer fix. That's a clear sign the defaults are wrong, not our hosts.

Reproduction (default install)

  1. npm install -g openclaw@2026.5.19
  2. Pair a Telegram / Slack / WhatsApp account, start an agent (coding agent, ops assistant — anything that runs for days).
  3. Use it normally for a week.

Observed:

  • Every night at atHour: 4 local time, the direct-chat session is reset. Long-term context is gone. The agent does not remember yesterday.
  • The active .jsonl transcript for the session keeps growing — tens of MB after a few days of heavy use. Eventually it harms responsiveness and eats provider context budget.
  • ~/.openclaw/agents/*/sessions/ accumulates files indefinitely; nothing prunes them.

Source confirmation

Behavior comes from compiled OC source (verified against installed 2026.5.19, file dist/reset-CMlTzEqB.js):

const DEFAULT_RESET_MODE = "daily";
// ...
const mode = typeReset?.mode
          ?? baseReset?.mode
          ?? (!hasExplicitReset && legacyIdleMinutes != null ? "idle" : "daily");

So if the user does not explicitly configure session.reset / session.resetByType, the resolver falls back to "daily" with the default atHour. For a chat-bot use case that's fine. For a coding agent / ops assistant it is destructive.

Equally, agents.defaults.compaction.maxActiveTranscriptBytes is optional and unset by default, so truncateAfterCompaction never fires and the local transcript grows unbounded.

session.maintenance.mode defaults to warn instead of enforce, so the runtime just logs about old session files but never cleans them up.

What we currently have to apply on every host

This is the minimum to keep a long-running coding-agent deployment healthy:

{
  "agents": {
    "defaults": {
      "compaction": {
        "model": "anthropic/claude-sonnet-4-20250514",
        "maxActiveTranscriptBytes": "500kb",
        "truncateAfterCompaction": true,
        "memoryFlush": {
          "forceFlushTranscriptBytes": "500kb"
        }
      },
      "contextPruning": {
        "mode": "cache-ttl",
        "ttl": "5m"
      }
    }
  },
  "session": {
    "maintenance": {
      "mode": "enforce",
      "pruneAfter": "30d",
      "maxDiskBytes": "1gb"
    },
    "resetByType": {
      "direct": { "mode": "idle", "idleMinutes": 10080 }
    }
  }
}

Plus, because layers 1–4 can still be defeated by very fast trajectory growth, we also ship an external cron watchdog that parks idle-and-large transcripts:

*/15 * * * * <user> find <home>/.openclaw/agents/*/sessions/ -maxdepth 1 -name '*.jsonl' \
  -size +1M -mmin +60 \
  -exec sh -c 'mkdir -p "$(dirname "$1")/parked" && \
               mv "$1" "$(dirname "$1")/parked/$(basename "$1").parked-$(date +%Y%m%d-%H%M%S)"' _ {} \;

Proposed defaults

We're not asking for a behavior change for chat-bot installs. But these defaults should at minimum not silently destroy memory and disk for non-chat-bot installs.

Concrete suggestions:

  1. session.resetByType.direct: ship a default of { mode: "idle", idleMinutes: 10080 } (7 days idle) instead of falling back to daily atHour:4. Daily reset is fine for group and thread, not for direct.
  2. agents.defaults.compaction.maxActiveTranscriptBytes: ship a sensible default (e.g. "5mb" or "10mb") with truncateAfterCompaction: true, so preflight compaction actually kicks in.
  3. session.maintenance.mode: default to enforce with a conservative pruneAfter (e.g. 90d) instead of warn. Logging-only that never cleans up is just disk leakage.
  4. Documentation: the docs at docs/concepts/compaction.md and docs/gateway/config-agents.md describe these knobs accurately, but a section "Hardening for long-running agents" listing all five layers together would have saved us months of repeated debugging.

Schema friction (separate but related)

While applying the workaround we lost about half an hour because:

  • The docs example uses resetByType: { direct: { mode: "idle", idleMinutes: 240 } }.
  • An older / legacy variant in the codebase appears to accept (or used to accept) kind: "idle".
  • Writing kind instead of mode makes the gateway silently refuse to apply that block (no clear error message about which field is wrong).

If kind is officially deprecated, a parse-time warning pointing at the correct field would help. If it's still accepted, the docs should mention both. Right now: silent fail.

Why this matters

OpenClaw is fantastic for the coding-agent / personal-assistant use case. But that use case is exactly the one the defaults punish. The first weeks with a new deployment look like a series of mystery memory-losses and unbounded disk growth, until someone debugs deeply enough to find the five separate knobs scattered across agents.defaults, session, and an external cron.

Happy to send a PR if there's interest in any of the four default changes above.

Environment

  • OpenClaw 2026.5.19 (a185ca2)
  • Ubuntu 24.04 LTS, Node 22.x
  • Three independent hosts, same fix needed on each.

Activity

  1. clawsweeper commented on May 21, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 30, 2026, 10:04 PM ET / 02:04 UTC.

    Summary
    Keep open: current main only partially addresses the report. Session maintenance now defaults to enforce and provider-owned CLI sessions are protected from implicit daily expiry, but ordinary direct sessions still default to daily reset and active transcript byte compaction remains opt-in.

    Reproducibility: yes. for the remaining source behavior: unconfigured direct sessions still resolve to the daily reset default, and the active transcript byte guard remains inactive unless existing compaction options are explicitly set. I did not reproduce the full week-long workload live.

    Next step
    The remaining work changes compatibility-sensitive defaults and is already labeled for maintainer review and product decision, so it should not be queued as an automated fix PR.

    Review details

    Best possible solution:

    Maintainers should choose the long-running-session default policy, then land a focused change that updates reset behavior, transcript byte defaults or docs, tests, and upgrade guidance together.

    Do we have a high-confidence way to reproduce the issue?

    Yes for the remaining source behavior: unconfigured direct sessions still resolve to the daily reset default, and the active transcript byte guard remains inactive unless existing compaction options are explicitly set. I did not reproduce the full week-long workload live.

    Is this the best way to solve the issue?

    Unclear: the requested defaults are plausible, but this is not a narrow automated bug fix because changing reset and compaction defaults needs maintainer-approved compatibility policy.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Changing reset or transcript-rotation defaults can affect users who intentionally rely on daily session cuts or no automatic transcript rotation.
    • This review proves the remaining behavior from current source and release-tag inspection, but it did not run a week-long live workload reproduction.

    Codex review notes: model internal, reasoning high; reviewed against d9aedc32a131.

    Label changes

    Label justifications:

    • P2: The issue is a real defaults and stability problem with meaningful but bounded operational impact and an explicit product-decision label.
    • impact:session-state: The report centers on session memory continuity, transcript growth, compaction, and retained conversation state.
    • impact:crash-loop: The issue and follow-up comments describe gateway stalls, restart pressure, and process-level unavailability under long-running workloads.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/auto-reply/reply/session.test.ts src/config/sessions/reset.test.ts src/config/sessions/store.pruning.test.ts src/auto-reply/reply/agent-runner-memory.test.ts
    • docs sanity for docs/concepts/session.md, docs/concepts/compaction.md, docs/gateway/config-agents.md, and docs/reference/session-management-compaction.md after maintainers choose the policy

    What I checked:

    • Direct sessions still default to daily reset: The current reset resolver keeps DEFAULT_RESET_MODE as daily and falls back to it when no type, base, or legacy idle reset is configured. (src/config/sessions/reset-policy.ts:22, d9aedc32a131)
    • Current tests preserve the daily direct-session rollover: The session tests assert that an otherwise unconfigured direct session rolls over at the daily boundary when only an unrelated resetByType entry exists. (src/auto-reply/reply/session.test.ts:2550, d9aedc32a131)
    • Provider-owned CLI sessions are a partial current-main fix: Current main skips implicit expiry for provider-owned CLI sessions unless the reset policy was explicitly configured, which addresses only one subset of long-running coding-agent sessions. (src/config/sessions/entry-freshness.ts:94, d9aedc32a131)
    • Gateway provider-owned CLI fix provenance: The current main commit is fix(gateway): keep provider-owned CLI sessions across the daily default reset; it is not contained in any release tag from the local tag set. (src/config/sessions/entry-freshness.ts:94, d9aedc32a131)
    • Active transcript byte guard remains opt-in: resolveMaxActiveTranscriptBytes returns undefined unless truncateAfterCompaction is true and maxActiveTranscriptBytes parses to a positive value. (src/auto-reply/reply/memory-flush.ts:26, d9aedc32a131)
    • Compaction defaults do not enable byte rotation: applyCompactionDefaults only fills compaction.mode=safeguard; it does not set truncateAfterCompaction or maxActiveTranscriptBytes. (src/config/defaults.ts:529, d9aedc32a131)

    Likely related people:

    • Peter Steinberger: History shows related session reset freshness and oversized-transcript compaction work in the central paths. (role: feature-history contributor; confidence: high; commits: 566d2d73a323, 4cd68fafbb2a, 29af4add2a8e; files: src/config/sessions/reset-policy.ts, src/auto-reply/reply/memory-flush.ts, src/auto-reply/reply/agent-runner-memory.ts)
    • Vincent Koc: Blame and log show recent carry-forward and reset-policy extraction on the affected session defaults files. (role: recent area contributor; confidence: medium; commits: 4355e719b87e, c70be4b4afd0, 280d1cb977c4; files: src/config/sessions/reset-policy.ts, src/auto-reply/reply/session.ts, src/auto-reply/reply/memory-flush.ts)
    • Yuval Dinodia: Recent commits changed provider-owned CLI reset freshness and preflight compaction behavior related to the partial fixes for this issue. (role: recent adjacent contributor; confidence: medium; commits: d9aedc32a131, bc4b1b018a3e, caab3434612c; files: src/config/sessions/entry-freshness.ts, src/gateway/server-methods/agent.ts, src/auto-reply/reply/agent-runner-memory.ts)
    • Josh Lehman: Recent auto-reply/session storage refactors touched the session paths that would carry a default-policy change. (role: recent session seam contributor; confidence: medium; commits: 49e6f5a524bc, 127e174c9e4d; files: src/auto-reply/reply/session.ts, src/config/sessions/store-maintenance.ts, src/auto-reply/reply/agent-runner-memory.ts)
    • Ayaan Zaidi: History shows an earlier provider-owned CLI implicit-expiry mitigation on the same reset/session behavior family. (role: introduced related mitigation; confidence: medium; commits: 18869acf4690; files: src/config/sessions/reset-policy.ts, src/auto-reply/reply/session.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR 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.
    on May 21, 2026
  3. brtkwr commented on May 23, 2026

    @brtkwr

    Hit this on a single-host install (OpenClaw 2026.5.12) with codex (openai-codex/gpt-5.4) as the agent model.

    Observation

    Applied exactly the workaround config from this issue:

    "compaction": {
      "truncateAfterCompaction": true,
      "maxActiveTranscriptBytes": "500kb",
      "memoryFlush": {
        "enabled": true,
        "forceFlushTranscriptBytes": "1mb"
      }
    }

    config get agents.defaults.compaction confirms it's loaded. But the heartbeat session (agent:main:main) still reached 568,575 bytes JSONL / 900,976 bytes trajectory across 8 days, with compactionCount: 0 and totalTokensFresh: true. No preflightCompaction check / triggered lines in logs over the period.

    Reading the source:

    • resolveMaxActiveTranscriptBytes returns the parsed number correctly given our config.
    • readSessionLogSnapshot does a plain fs.stat() on the resolved session log path — would return 568575 in our case.
    • The byte-size trigger gate activeTranscriptBytes >= maxActiveTranscriptBytes should fire.
    • runPreflightCompactionIfNeeded is invoked on every reply via the queue runner in agent-runner.runtime.

    So the gates all read as passing for our case, but compaction never runs. Two theories I haven't been able to confirm:

    1. The transcript only crosses the threshold after the model call appends to it, so each tick's preflight runs against a sub-threshold file size from the previous tick. With heartbeat firing once a day, the gap could let the file oscillate around the boundary without ever triggering.
    2. The compactEmbeddedPiSession path the preflight calls may not be a viable target when the session's harness is codex (rather than embedded pi). In @openclaw/codex/dist/compact-Bl8jRPk4.js the trigger values are "manual" and "budget" — no byte-size path. So the preflight may invoke the pi compactor against a codex-owned session and silently no-op.

    Either way, the byte threshold demonstrably does not save us on codex-backed sessions on 2026.5.12. We've now disabled the heartbeat entirely (no remaining scheduled work) and installed the external park watchdog from this issue. The watchdog parked 12 historic trajectory files on first run.

    Happy to provide more detail or a minimal repro if it's useful.

  4. moeedahmed commented on May 25, 2026

    @moeedahmed
    Contributor

    Additional live data point from OpenClaw 2026.5.22 on macOS / LaunchAgent, with a long-running Telegram Operator setup.

    This was a production incident rather than a synthetic repro:

    • session.maintenance.maxDiskBytes was 100mb and highWaterBytes was 80mb.
    • The active Operator session directory reached about 147M.
    • Maintenance ran repeatedly but removed 0 files because the pressure was from active same-day sessions and trajectory logs, not old files beyond pruneAfter.
    • Event-loop delay reached about 4s during provider/auth prewarm and health monitoring started sending restart signals, which cascaded into Telegram polling conflicts.

    Local containment that restored stability:

    • Archived old session files and moved .trajectory.jsonl files out of active session dirs.
    • Raised session.maintenance.maxDiskBytes to 200mb and highWaterBytes to 160mb.
    • After cleanup, live session sizes were: Operator 111M, Medic 36M, Founder 32M, Guardian 26M.
    • The trajectory archive was readable/recoverable: 112M, 75 files, 39 trajectory JSONL files.
    • Active .trajectory.jsonl files still totalled about 82M across agents, so this is not fully solved by a larger session disk budget.

    The narrow fix shape from this incident is slightly different from only changing transcript/session defaults:

    1. Treat .trajectory.jsonl as diagnostic/reasoning telemetry with its own retention/budget, or exclude it from the conversation session disk budget.
    2. Ensure high-water cleanup can relieve same-day pressure instead of only relying on pruneAfter age expiry.
    3. Log when cleanup is blocked by active files/trajectory files so operators can see why enforcement removed 0 files.

    Acceptance proof that would have prevented this incident: create active same-day sessions with trajectory files pushing total session dir size above high-water; maintenance should either prune/archive trajectory telemetry or clearly report that only protected active conversation state remains.

  5. added
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jun 15, 2026
  6. steipete commented on Jul 11, 2026

    @steipete
    Contributor

    Default growth is now bounded: 30d prune, 500-entry cap, 2gb disk budget, zstd archives, and incremental auto-vacuum. The nightly-reset product ask can ride a fresh focused issue if still wanted.
    Sessions and transcripts moved from JSON/JSONL files to per-agent SQLite on main (0a8e3604ba24, plus follow-up 4eef09dc3f5d), and the storage rework removed or rewrote the code paths implicated here. We're closing storage-implicated reports optimistically as part of that cleanup since we can't re-verify every historical environment. If this still reproduces on current main or the next release, please open a fresh issue with new logs and link back to this one.

  7. locked as resolved and limited conversation to collaborators on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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: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:crash-loopCrash, hang, restart loop, or process-level availability failure.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