惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
Y
Y Combinator Blog
月光博客
月光博客
IT之家
IT之家
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
L
LangChain Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
博客园 - Franky
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
V
Visual Studio Blog
小众软件
小众软件
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: keep system events from extending session resets (#7...
steipete · 2026-04-26 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -159,6 +159,11 @@ Docs: https://docs.openclaw.ai

159159

- Image understanding: resolve configured image models such as local LM Studio

160160

vision entries before reporting `Unknown model` when the discovery registry

161161

has not registered that provider. Fixes #66486. Thanks @zhanggpcsu.

162+

- Sessions: separate reset freshness from session-store `updatedAt`, so

163+

heartbeat, cron, exec, and gateway bookkeeping no longer prevent configured

164+

daily/idle resets from rolling long-running channel sessions. Fixes #68315,

165+

#63732, #63820, and #69083. Thanks @maxatv, @longhairedsi, @bradfreels,

166+

and @akessel56.

162167

- CLI/agents: keep `agents bind`, `agents unbind`, and `agents bindings` on

163168

setup-safe channel metadata paths so they do not preload bundled plugin

164169

runtimes or stage runtime dependencies. Fixes #71743.

Original file line numberDiff line numberDiff line change

@@ -84,7 +84,7 @@ This fires ~5–6 times per month instead of 0–1 times per month. OpenClaw use

8484

| Current session | `current` | Bound at creation time | Context-aware recurring work |

8585

| Custom session | `session:custom-id` | Persistent named session | Workflows that build on history |

8686
87-

**Main session** jobs enqueue a system event and optionally wake the heartbeat (`--wake now` or `--wake next-heartbeat`). **Isolated** jobs run a dedicated agent turn with a fresh session. **Custom sessions** (`session:xxx`) persist context across runs, enabling workflows like daily standups that build on previous summaries.

87+

**Main session** jobs enqueue a system event and optionally wake the heartbeat (`--wake now` or `--wake next-heartbeat`). Those system events do not extend daily/idle reset freshness for the target session. **Isolated** jobs run a dedicated agent turn with a fresh session. **Custom sessions** (`session:xxx`) persist context across runs, enabling workflows like daily standups that build on previous summaries.

8888
8989

For isolated jobs, “fresh session” means a new transcript/session id for each run. OpenClaw may carry safe preferences such as thinking/fast/verbose settings, labels, and explicit user-selected model/auth overrides, but it does not inherit ambient conversation context from an older cron row: channel/group routing, send or queue policy, elevation, origin, or ACP runtime binding. Use `current` or `session:<id>` when a recurring job should deliberately build on the same conversation context.

9090

@@ -433,6 +433,18 @@ openclaw doctor

433433

- If the agent should message the user itself, check that the job has a usable

434434

route (`channel: "last"` with a previous chat, or an explicit channel/target).

435435
436+

### Cron or heartbeat appears to prevent `/new`-style rollover

437+
438+

- Daily and idle reset freshness is not based on `updatedAt`; see

439+

[Session management](/concepts/session#session-lifecycle).

440+

- Cron wakeups, heartbeat runs, exec notifications, and gateway bookkeeping may

441+

update the session row for routing/status, but they do not extend

442+

`sessionStartedAt` or `lastInteractionAt`.

443+

- For legacy rows created before those fields existed, OpenClaw can recover

444+

`sessionStartedAt` from the transcript JSONL session header when the file is

445+

still available. Legacy idle rows without `lastInteractionAt` use that

446+

recovered start time as their idle baseline.

447+
436448

### Timezone gotchas

437449
438450

- Cron without `--tz` uses the gateway host timezone.

Original file line numberDiff line numberDiff line change

@@ -93,7 +93,7 @@ See [Hooks](/automation/hooks).

9393
9494

### Heartbeat

9595
96-

Heartbeat is a periodic main-session turn (default every 30 minutes). It batches multiple checks (inbox, calendar, notifications) in one agent turn with full session context. Heartbeat turns do not create task records. Use `HEARTBEAT.md` for a small checklist, or a `tasks:` block when you want due-only periodic checks inside heartbeat itself. Empty heartbeat files skip as `empty-heartbeat-file`; due-only task mode skips as `no-tasks-due`.

96+

Heartbeat is a periodic main-session turn (default every 30 minutes). It batches multiple checks (inbox, calendar, notifications) in one agent turn with full session context. Heartbeat turns do not create task records and do not extend daily/idle session reset freshness. Use `HEARTBEAT.md` for a small checklist, or a `tasks:` block when you want due-only periodic checks inside heartbeat itself. Empty heartbeat files skip as `empty-heartbeat-file`; due-only task mode skips as `no-tasks-due`.

9797
9898

See [Heartbeat](/gateway/heartbeat).

9999
Original file line numberDiff line numberDiff line change

@@ -3,6 +3,7 @@ summary: "How OpenClaw manages conversation sessions"

33

read_when:

44

- You want to understand session routing and isolation

55

- You want to configure DM scope for multi-user setups

6+

- You are debugging daily or idle session resets

67

title: "Session management"

78

---

89

@@ -59,13 +60,18 @@ Verify your setup with `openclaw security audit`.

5960

Sessions are reused until they expire:

6061
6162

- **Daily reset** (default) -- new session at 4:00 AM local time on the gateway

62-

host.

63+

host. Daily freshness is based on when the current `sessionId` started, not

64+

on later metadata writes.

6365

- **Idle reset** (optional) -- new session after a period of inactivity. Set

64-

`session.reset.idleMinutes`.

66+

`session.reset.idleMinutes`. Idle freshness is based on the last real

67+

user/channel interaction, so heartbeat, cron, and exec system events do not

68+

keep the session alive.

6569

- **Manual reset** -- type `/new` or `/reset` in chat. `/new <model>` also

6670

switches the model.

6771
6872

When both daily and idle resets are configured, whichever expires first wins.

73+

Heartbeat, cron, exec, and other system-event turns may write session metadata,

74+

but those writes do not extend daily or idle reset freshness.

6975
7076

Sessions with an active provider-owned CLI session are not cut by the implicit

7177

daily default. Use `/reset` or configure `session.reset` explicitly when those

@@ -79,6 +85,18 @@ session data.

7985

- **Store:** `~/.openclaw/agents/<agentId>/sessions/sessions.json`

8086

- **Transcripts:** `~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl`

8187
88+

`sessions.json` keeps separate lifecycle timestamps:

89+
90+

- `sessionStartedAt`: when the current `sessionId` began; daily reset uses this.

91+

- `lastInteractionAt`: last user/channel interaction that extends idle lifetime.

92+

- `updatedAt`: last store-row mutation; useful for listing and pruning, but not

93+

authoritative for daily/idle reset freshness.

94+
95+

Older rows without `sessionStartedAt` are resolved from the transcript JSONL

96+

session header when available. If an older row also lacks `lastInteractionAt`,

97+

idle freshness falls back to that session start time, not to later bookkeeping

98+

writes.

99+
82100

## Session maintenance

83101
84102

OpenClaw automatically bounds session storage over time. By default, it runs

Original file line numberDiff line numberDiff line change

@@ -1162,7 +1162,7 @@ See [Multi-Agent Sandbox & Tools](/tools/multi-agent-sandbox-tools) for preceden

11621162

- `per-channel-peer`: isolate per channel + sender (recommended for multi-user inboxes).

11631163

- `per-account-channel-peer`: isolate per account + channel + sender (recommended for multi-account).

11641164

- **`identityLinks`**: map canonical ids to provider-prefixed peers for cross-channel session sharing.

1165-

- **`reset`**: primary reset policy. `daily` resets at `atHour` local time; `idle` resets after `idleMinutes`. When both configured, whichever expires first wins.

1165+

- **`reset`**: primary reset policy. `daily` resets at `atHour` local time; `idle` resets after `idleMinutes`. When both configured, whichever expires first wins. Daily reset freshness uses the session row's `sessionStartedAt`; idle reset freshness uses `lastInteractionAt`. Background/system-event writes such as heartbeat, cron wakeups, exec notifications, and gateway bookkeeping can update `updatedAt`, but they do not keep daily/idle sessions fresh.

11661166

- **`resetByType`**: per-type overrides (`direct`, `group`, `thread`). Legacy `dm` accepted as alias for `direct`.

11671167

- **`parentForkMaxTokens`**: max parent-session `totalTokens` allowed when creating a forked thread session (default `100000`).

11681168

- If parent `totalTokens` is above this value, OpenClaw starts a fresh thread session instead of inheriting parent transcript history.

Original file line numberDiff line numberDiff line change

@@ -263,8 +263,9 @@ Use `accountId` to target a specific account on multi-account channels like Tele

263263

- If the resolved heartbeat target supports typing, OpenClaw shows typing while

264264

the heartbeat run is active. This uses the same target the heartbeat would

265265

send chat output to, and it is disabled by `typingMode: "never"`.

266-

- Heartbeat-only replies do **not** keep the session alive; the last `updatedAt`

267-

is restored so idle expiry behaves normally.

266+

- Heartbeat-only replies do **not** keep the session alive. Heartbeat metadata

267+

may update the session row, but idle expiry uses `lastInteractionAt` from the

268+

last real user/channel message, and daily expiry uses `sessionStartedAt`.

268269

- Control UI and WebChat history hide heartbeat prompts and OK-only

269270

acknowledgments. The underlying session transcript can still contain those

270271

turns for audit/replay.

Original file line numberDiff line numberDiff line change

@@ -136,6 +136,7 @@ Rules of thumb:

136136

- **Reset** (`/new`, `/reset`) creates a new `sessionId` for that `sessionKey`.

137137

- **Daily reset** (default 4:00 AM local time on the gateway host) creates a new `sessionId` on the next message after the reset boundary.

138138

- **Idle expiry** (`session.reset.idleMinutes` or legacy `session.idleMinutes`) creates a new `sessionId` when a message arrives after the idle window. When daily + idle are both configured, whichever expires first wins.

139+

- **System events** (heartbeat, cron wakeups, exec notifications, gateway bookkeeping) may mutate the session row but do not extend daily/idle reset freshness.

139140

- **Thread parent fork guard** (`session.parentForkMaxTokens`, default `100000`) skips parent transcript forking when the parent session is already too large; the new thread starts fresh. Set `0` to disable.

140141
141142

Implementation detail: the decision happens in `initSessionState()` in `src/auto-reply/reply/session.ts`.

@@ -149,7 +150,14 @@ The store’s value type is `SessionEntry` in `src/config/sessions.ts`.

149150

Key fields (not exhaustive):

150151
151152

- `sessionId`: current transcript id (filename is derived from this unless `sessionFile` is set)

152-

- `updatedAt`: last activity timestamp

153+

- `sessionStartedAt`: start timestamp for the current `sessionId`; daily reset

154+

freshness uses this. Legacy rows may derive it from the JSONL session header.

155+

- `lastInteractionAt`: last real user/channel interaction timestamp; idle reset

156+

freshness uses this so heartbeat, cron, and exec events do not keep sessions

157+

alive. Legacy rows without this field fall back to the recovered session start

158+

time for idle freshness.

159+

- `updatedAt`: last store-row mutation timestamp, used for listing, pruning, and

160+

bookkeeping. It is not the authority for daily/idle reset freshness.

153161

- `sessionFile`: optional explicit transcript path override

154162

- `chatType`: `direct | group | room` (helps UIs and send policy)

155163

- `provider`, `subject`, `room`, `space`, `displayName`: metadata for group/channel labeling

Original file line numberDiff line numberDiff line change

@@ -616,14 +616,17 @@ async function agentCommandInternal(

616616

: currentSkillsSnapshot;

617617
618618

if (skillsSnapshot && sessionStore && sessionKey && needsSkillsSnapshot) {

619+

const now = Date.now();

619620

const current = sessionEntry ?? {

620621

sessionId,

621-

updatedAt: Date.now(),

622+

updatedAt: now,

623+

sessionStartedAt: now,

622624

};

623625

const next: SessionEntry = {

624626

...current,

625627

sessionId,

626-

updatedAt: Date.now(),

628+

updatedAt: now,

629+

sessionStartedAt: current.sessionStartedAt ?? now,

627630

skillsSnapshot,

628631

};

629632

await persistSessionEntry({

@@ -637,9 +640,16 @@ async function agentCommandInternal(

637640
638641

// Persist explicit /command overrides to the session store when we have a key.

639642

if (sessionStore && sessionKey) {

643+

const now = Date.now();

640644

const entry = sessionStore[sessionKey] ??

641-

sessionEntry ?? { sessionId, updatedAt: Date.now() };

642-

const next: SessionEntry = { ...entry, sessionId, updatedAt: Date.now() };

645+

sessionEntry ?? { sessionId, updatedAt: now, sessionStartedAt: now };

646+

const next: SessionEntry = {

647+

...entry,

648+

sessionId,

649+

updatedAt: now,

650+

sessionStartedAt: entry.sessionStartedAt ?? now,

651+

lastInteractionAt: now,

652+

};

643653

if (thinkOverride) {

644654

next.thinkingLevel = thinkOverride;

645655

}

@@ -1064,6 +1074,10 @@ async function agentCommandInternal(

10641074

fallbackProvider,

10651075

fallbackModel,

10661076

result,

1077+

touchInteraction:

1078+

opts.bootstrapContextRunKind !== "cron" &&

1079+

opts.bootstrapContextRunKind !== "heartbeat" &&

1080+

!opts.internalEvents?.length,

10671081

});

10681082

sessionEntry = sessionStore[sessionKey] ?? sessionEntry;

10691083

}

Original file line numberDiff line numberDiff line change

@@ -648,6 +648,89 @@ describe("updateSessionStoreAfterAgentRun", () => {

648648

expect(persisted[sessionKey]?.estimatedCostUsd).toBeCloseTo(0.25, 4);

649649

});

650650

});

651+
652+

it("preserves lastInteractionAt for non-interactive system runs", async () => {

653+

await withTempSessionStore(async ({ storePath }) => {

654+

const cfg = {} as OpenClawConfig;

655+

const sessionKey = "agent:main:explicit:test-system-run";

656+

const sessionId = "test-system-run-session";

657+

const lastInteractionAt = Date.now() - 60 * 60_000;

658+

const sessionStartedAt = Date.now() - 2 * 60 * 60_000;

659+

const sessionStore: Record<string, SessionEntry> = {

660+

[sessionKey]: {

661+

sessionId,

662+

updatedAt: Date.now() - 10_000,

663+

sessionStartedAt,

664+

lastInteractionAt,

665+

},

666+

};

667+

await fs.writeFile(storePath, JSON.stringify(sessionStore, null, 2));

668+
669+

await updateSessionStoreAfterAgentRun({

670+

cfg,

671+

sessionId,

672+

sessionKey,

673+

storePath,

674+

sessionStore,

675+

defaultProvider: "openai",

676+

defaultModel: "gpt-5.4",

677+

result: {

678+

meta: {

679+

durationMs: 1,

680+

agentMeta: {

681+

sessionId,

682+

provider: "openai",

683+

model: "gpt-5.4",

684+

},

685+

},

686+

},

687+

touchInteraction: false,

688+

});

689+
690+

expect(sessionStore[sessionKey]?.lastInteractionAt).toBe(lastInteractionAt);

691+

expect(sessionStore[sessionKey]?.sessionStartedAt).toBe(sessionStartedAt);

692+

expect(sessionStore[sessionKey]?.updatedAt).toBeGreaterThan(lastInteractionAt);

693+

});

694+

});

695+
696+

it("advances lastInteractionAt for interactive runs", async () => {

697+

await withTempSessionStore(async ({ storePath }) => {

698+

const cfg = {} as OpenClawConfig;

699+

const sessionKey = "agent:main:explicit:test-user-run";

700+

const sessionId = "test-user-run-session";

701+

const lastInteractionAt = Date.now() - 60 * 60_000;

702+

const sessionStore: Record<string, SessionEntry> = {

703+

[sessionKey]: {

704+

sessionId,

705+

updatedAt: Date.now() - 10_000,

706+

lastInteractionAt,

707+

},

708+

};

709+

await fs.writeFile(storePath, JSON.stringify(sessionStore, null, 2));

710+
711+

await updateSessionStoreAfterAgentRun({

712+

cfg,

713+

sessionId,

714+

sessionKey,

715+

storePath,

716+

sessionStore,

717+

defaultProvider: "openai",

718+

defaultModel: "gpt-5.4",

719+

result: {

720+

meta: {

721+

durationMs: 1,

722+

agentMeta: {

723+

sessionId,

724+

provider: "openai",

725+

model: "gpt-5.4",

726+

},

727+

},

728+

},

729+

});

730+
731+

expect(sessionStore[sessionKey]?.lastInteractionAt).toBeGreaterThan(lastInteractionAt);

732+

});

733+

});

651734

});

652735
653736

describe("clearCliSessionInStore", () => {

Original file line numberDiff line numberDiff line change

@@ -49,6 +49,7 @@ export async function updateSessionStoreAfterAgentRun(params: {

4949

fallbackProvider?: string;

5050

fallbackModel?: string;

5151

result: RunResult;

52+

touchInteraction?: boolean;

5253

}) {

5354

const {

5455

cfg,

@@ -62,6 +63,8 @@ export async function updateSessionStoreAfterAgentRun(params: {

6263

fallbackModel,

6364

result,

6465

} = params;

66+

const now = Date.now();

67+

const touchInteraction = params.touchInteraction !== false;

6568
6669

const usage = result.meta.agentMeta?.usage;

6770

const promptTokens = result.meta.agentMeta?.promptTokens;

@@ -85,12 +88,15 @@ export async function updateSessionStoreAfterAgentRun(params: {

8588
8689

const entry = sessionStore[sessionKey] ?? {

8790

sessionId,

88-

updatedAt: Date.now(),

91+

updatedAt: now,

92+

sessionStartedAt: now,

8993

};

9094

const next: SessionEntry = {

9195

...entry,

9296

sessionId,

93-

updatedAt: Date.now(),

97+

updatedAt: now,

98+

sessionStartedAt: entry.sessionId === sessionId ? (entry.sessionStartedAt ?? now) : now,

99+

lastInteractionAt: touchInteraction ? now : entry.lastInteractionAt,

94100

contextTokens,

95101

};

96102

setSessionRuntimeModel(next, {