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

推荐订阅源

B
Blog
V
Vulnerabilities – Threatpost
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
Latest news
Latest news
博客园 - 三生石上(FineUI控件)
美团技术团队
aimingoo的专栏
aimingoo的专栏
Google Online Security Blog
Google Online Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Threatpost
Y
Y Combinator Blog
T
Tailwind CSS Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
Arctic Wolf
C
Cyber Attacks, Cyber Crime and Cyber Security
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tenable Blog
W
WeLiveSecurity
L
LINUX DO - 热门话题
D
Docker
Cyberwarzone
Cyberwarzone
量子位
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Full Disclosure
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
T
The Exploit Database - CXSecurity.com
Engineering at Meta
Engineering at Meta
O
OpenAI News
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
IT之家
IT之家
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
L
Lohrmann on Cybersecurity
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News

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 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
fix: keep system events from extending session resets (#71845) · openclaw/openclaw@566d2d7
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, {