Repository navigation
Description
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)
npm install -g openclaw@2026.5.19- Pair a Telegram / Slack / WhatsApp account, start an agent (coding agent, ops assistant — anything that runs for days).
- Use it normally for a week.
Observed:
- Every night at
atHour: 4local time, the direct-chat session is reset. Long-term context is gone. The agent does not remember yesterday. - The active
.jsonltranscript 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:
session.resetByType.direct: ship a default of{ mode: "idle", idleMinutes: 10080 }(7 days idle) instead of falling back todaily atHour:4. Daily reset is fine forgroupandthread, not fordirect.agents.defaults.compaction.maxActiveTranscriptBytes: ship a sensible default (e.g."5mb"or"10mb") withtruncateAfterCompaction: true, so preflight compaction actually kicks in.session.maintenance.mode: default toenforcewith a conservativepruneAfter(e.g.90d) instead ofwarn. Logging-only that never cleans up is just disk leakage.- Documentation: the docs at
docs/concepts/compaction.mdanddocs/gateway/config-agents.mddescribe 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
kindinstead ofmodemakes 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.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 21, 2026
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:
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:
What I checked:
src/config/sessions/reset-policy.ts:22, d9aedc32a131)src/auto-reply/reply/session.test.ts:2550, d9aedc32a131)src/config/sessions/entry-freshness.ts:94, d9aedc32a131)src/config/sessions/entry-freshness.ts:94, d9aedc32a131)src/auto-reply/reply/memory-flush.ts:26, d9aedc32a131)src/config/defaults.ts:529, d9aedc32a131)Likely related people:
src/config/sessions/reset-policy.ts,src/auto-reply/reply/memory-flush.ts,src/auto-reply/reply/agent-runner-memory.ts)src/config/sessions/reset-policy.ts,src/auto-reply/reply/session.ts,src/auto-reply/reply/memory-flush.ts)src/config/sessions/entry-freshness.ts,src/gateway/server-methods/agent.ts,src/auto-reply/reply/agent-runner-memory.ts)src/auto-reply/reply/session.ts,src/config/sessions/store-maintenance.ts,src/auto-reply/reply/agent-runner-memory.ts)src/config/sessions/reset-policy.ts,src/auto-reply/reply/session.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.brtkwr commentedon May 23, 2026
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:
config get agents.defaults.compactionconfirms it's loaded. But the heartbeat session (agent:main:main) still reached568,575bytes JSONL /900,976bytes trajectory across 8 days, withcompactionCount: 0andtotalTokensFresh: true. NopreflightCompaction check/triggeredlines in logs over the period.Reading the source:
resolveMaxActiveTranscriptBytesreturns the parsed number correctly given our config.readSessionLogSnapshotdoes a plainfs.stat()on the resolved session log path — would return568575in our case.activeTranscriptBytes >= maxActiveTranscriptBytesshould fire.runPreflightCompactionIfNeededis invoked on every reply via the queue runner inagent-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:
compactEmbeddedPiSessionpath 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.jsthe 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.
moeedahmed commentedon May 25, 2026
Additional live data point from OpenClaw
2026.5.22on macOS / LaunchAgent, with a long-running Telegram Operator setup.This was a production incident rather than a synthetic repro:
session.maintenance.maxDiskByteswas100mbandhighWaterByteswas80mb.147M.0files because the pressure was from active same-day sessions and trajectory logs, not old files beyondpruneAfter.Local containment that restored stability:
.trajectory.jsonlfiles out of active session dirs.session.maintenance.maxDiskBytesto200mbandhighWaterBytesto160mb.111M, Medic36M, Founder32M, Guardian26M.112M, 75 files, 39 trajectory JSONL files..trajectory.jsonlfiles still totalled about82Macross 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:
.trajectory.jsonlas diagnostic/reasoning telemetry with its own retention/budget, or exclude it from the conversation session disk budget.pruneAfterage expiry.0files.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.
steipete commentedon Jul 11, 2026
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-up4eef09dc3f5d), 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.