#Session auto reset
1 messages · Page 1 of 1 (latest)
Yep, and compaction is separate from reset.
If you want fresh session IDs periodically, use session.reset:
{
session: {
reset: {
mode: "daily",
atHour: 4, // gateway local time
idleMinutes: 720, // optional, whichever hits first
},
},
}
If this is mainly a Discord thread thing, you can scope it just for threads:
{
session: {
resetByType: {
thread: { mode: "idle", idleMinutes: 720 },
},
},
}
Important bit: reset does not delete old logs, it just starts a new sessionId.
So if you also want the on-disk session store to stay small, enable maintenance too:
{
session: {
maintenance: {
mode: "enforce",
pruneAfter: "30d",
maxEntries: 500,
resetArchiveRetention: "30d",
},
},
}
Useful docs:
- https://docs.openclaw.ai/concepts/session
- https://docs.openclaw.ai/reference/session-management-compaction
- https://docs.openclaw.ai/gateway/configuration-reference#session
And for a one-off preview/cleanup:
openclaw sessions cleanup --dry-runopenclaw sessions cleanup --enforce
So short version: yes, use session.reset for periodic fresh sessions, and session.maintenance if you also want old logs pruned.
what is the equivalent of reset mode daily? /new or /reset? what's the difference between the two?
Pretty much yes, reset.mode: "daily" is the automatic equivalent of doing /new or /reset for that session key.
A couple details:
- It does not reset exactly at 4:00 and send anything by itself.
- It marks the session stale, then the next message after the boundary starts a fresh
sessionId.
As for /new vs /reset:
- In normal sessions: basically no difference.
/resetis an alias for/new. - Extra thing
/newcan do:/new <model>can start fresh and switch model.
So in practice:
- want a clean slate now →
/reset - want a clean slate + maybe change model →
/newor/new <model> - want that to happen automatically →
session.reset
Docs:
- https://docs.openclaw.ai/tools/slash-commands
- https://docs.openclaw.ai/concepts/session
- https://docs.openclaw.ai/reference/session-management-compaction
If this fixed it, please right-click the solution message → Apps → ✅ Mark Solution so Answer Overflow can index it.
default is already "daily" and at "4"?
Yep, by default it is:
mode: "daily"atHour: 4
And that 4 is in the gateway host’s local timezone.
Tiny nuance: if someone is still using the old legacy session.idleMinutes config without an explicit session.reset, that can make it behave like idle reset instead. But with default modern behavior, yes, it’s daily at 4.
what are other possible modes, other than idle and daily?
Just those two for session.reset.mode:
dailyidle
There isn’t a third reset mode right now.
What you can vary is where they apply:
- global:
session.reset - by chat type:
session.resetByType - by channel/provider:
session.resetByChannel
But the mode values themselves are only daily and idle.
Reference: https://docs.openclaw.ai/gateway/configuration-reference#session
so if the mode is idle and the session isn't hitting idle threshold, the session log will just keep growing indefinitely?
Yes, basically.
If you set idle-only and the chat never goes idle long enough, the same sessionId keeps being reused, so the on-disk transcript keeps growing.
Important nuance:
- context size to the model stays bounded by compaction/pruning
- session log file is still append-only, so it can keep growing
So if your goal is “don’t let one transcript live forever”, I’d use:
session.reset.mode: "daily"(or daily +idleMinutes)- plus
session.maintenance.mode: "enforce"for retention cleanup
In other words, compaction helps prompt size, not transcript lifetime.
with that scenario, setting session.maintenance to enforce + max emtries will keep the same sessionId but new file will be created? will the old file remain?
Not quite, maxEntries is not a “split this long session into a new file” setting.
What it actually does:
session.maintenance.maxEntriescaps the number of session entries insessions.json- it does not rotate one active session into a new
sessionId - it does not split one growing transcript file
So in your scenario:
- if the same session keeps staying active, it keeps the same
sessionId - no new transcript file is created just because of
maxEntries
A new file only happens when the session actually rolls over, for example via:
/newor/reset- daily reset
- idle reset
Then the old transcript gets archived, and a fresh session gets a new file.
Roughly:
- old file after reset:
old-session.jsonl.reset.<timestamp> - evicted old sessions from maintenance capping:
old-session.jsonl.deleted.<timestamp>
So yes, the old file usually remains as an archive for a while, and resetArchiveRetention controls cleanup of the reset archives.
Short version: maintenance cleans up old sessions, but reset is what creates a new session/file.
ok clear now, thanks Krill