Skip to content

Session management improvements and dashboard API - #50101

Merged
tyler6204 merged 42 commits into
openclaw:mainfrom
clay-datacurve:datacurve/session-improvements
Mar 19, 2026
Merged

tyler6204 merged 42 commits into
openclaw:mainfrom
clay-datacurve:datacurve/session-improvements

Conversation

@clay-datacurve

Copy link
Copy Markdown
Contributor

Summary

Comprehensive session management improvements spanning subagent lifecycle, dashboard APIs, real-time events, cost tracking, and default reset behavior.

Changes

Session Reset Defaults

  • Change default session reset mode from daily to idle
  • Set DEFAULT_IDLE_MINUTES to 0 (meaning disabled/never reset)
  • Treat idleMinutes=0 as "no idle expiry" — sessions never auto-reset by default

Dashboard Session API

  • Add session lifecycle gateway methods (sessions.create, sessions.send, etc.)
  • Add direct session history HTTP and SSE endpoints
  • Add dashboard session model and parent linkage support
  • Harden dashboard session events and history APIs
  • Fix dashboard session create and model metadata
  • Fix dashboard session cost metadata
  • Tighten dashboard session API metadata
  • Fix dashboard image attachments in sessions send

Real-time Events & WebSocket

  • Push session list updates over websocket
  • Emit session.message websocket events for transcript updates
  • Emit sessions.changed lifecycle event on subagent spawn
  • Stream session tool events to operator UIs
  • Emit user message transcript events and deduplicate plugin warnings

Subagent Session Management

  • Expose subagent session metadata in sessions list
  • Expose child subagent sessions in subagents list
  • Fix active subagent session status in gateway
  • Fix stale active subagent status after follow-up runs
  • Fix completed session follow-up status updates
  • Fix subagent session transcript event keys
  • Persist subagent timing in session store
  • Make cleanup: "keep" persist subagent sessions indefinitely
  • Add sessions.steer gateway coverage

Cost Tracking

  • Estimate session costs in sessions list
  • Persist accumulated session cost
  • Cache OpenRouter pricing for configured models
  • Stop guessing session model costs

Session Lifecycle & State

  • Publish terminal session lifecycle state
  • Fix gateway send session reactivation
  • Add timeout session status
  • Allow persistent dashboard orchestrator sessions
  • Allow operator-token session kills
  • Add admin HTTP endpoint to kill sessions
  • Bump session label max to 512

Auth & Security

  • Preserve operator scopes for token-authenticated backend clients
  • Preserve operator scopes without device identity

Misc Fixes

  • Include status and timing in sessions_list tool
  • Hide injected timestamp prefixes in chat UI
  • Simplify post-compaction refresh prompt
  • Fix followup queue drain config crash
  • Fix subagent spawn test config loading

Commits (42)

00d052a66 feat: change default session reset to effectively never
b60e102f6 fix: publish terminal session lifecycle state
eb504201e Fix gateway send session reactivation
3011ca623 bump session label max to 512
3b1b01f9d Fix active subagent session status in gateway
a57ec0bd7 Fix subagent session transcript event keys
03a59bac6 Persist subagent timing in session store
79a877ffb Add sessions.steer gateway coverage
48a6be805 feat: stream session tool events to operator UIs
7787adc72 Fix completed session follow-up status updates
7eb96c4c6 Fix dashboard image attachments in sessions send
0f97fd269 Fix stale active subagent status after follow-up runs
4bf67c29c Gateway: allow operator-token session kills
65a511589 fix: preserve operator scopes for token-authenticated backend clients
76c95c072 Gateway: allow persistent dashboard orchestrator sessions
daec654ba feat: emit sessions.changed lifecycle event on subagent spawn
621b75930 Emit user message transcript events and deduplicate plugin warnings
9bee56e0b Gateway: preserve operator scopes without device identity
05b19ad80 Fix subagent spawn test config loading
0a8ae67bf Gateway: add timeout session status
403b1166b Gateway: cache OpenRouter pricing for configured models
0342a0106 fix: stop guessing session model costs
fb6476299 Fix dashboard session create and model metadata
0a0b64152 fix: stop followup queue drain cfg crash
79f403111 Persist accumulated session cost
d05960179 Fix dashboard session cost metadata
b61b4ef2f fix: tighten dashboard session API metadata
6b2cbd467 Add dashboard session model and parent linkage support
eacf00f6a Add dashboard session API improvements
8db543d2e Add session lifecycle gateway methods
0e3d1c2bb Harden dashboard session events and history APIs
5fa3d04ce Add direct session history HTTP and SSE endpoints
cb814b3cd Estimate session costs in sessions list
0ef90453c Emit session.message websocket events for transcript updates
f291be3f6 feat: add admin http endpoint to kill sessions
086d93e5b feat: expose child subagent sessions in subagents list
39319aa89 feat: push session list updates over websocket
59e090863 fix: hide injected timestamp prefixes in chat ui
49e0b312c fix: include status and timing in sessions_list tool
9080fa305 feat: expose subagent session metadata in sessions list
a5e37bd31 fix: simplify post compaction refresh prompt
9c552dfb2 fix: make cleanup "keep" persist subagent sessions indefinitely

@clay-datacurve
clay-datacurve requested a review from a team as a code owner March 19, 2026 00:49
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL labels Mar 19, 2026
@greptile-apps

greptile-apps Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This is a large, multi-faceted PR spanning session lifecycle management, dashboard APIs, real-time WebSocket events, cost tracking, and auth changes. The broad scope touches 100 files across the gateway, agent runtime, and config layers. The overall direction is well-considered — changing the default idle policy to "never reset" (via DEFAULT_IDLE_MINUTES = 0) is a meaningful behavior change that is correctly threaded through the freshness evaluation logic.

Key observations:

  • Lifecycle listener resource leak: lifecycleUnsub (the unsubscribe handle from onSessionLifecycleEvent) is created in server.impl.ts and passed to createGatewayCloseHandler, but createGatewayCloseHandler's params type in server-close.ts only added transcriptUnsub — lifecycleUnsub is not declared and not called at shutdown, leaving the listener alive in SESSION_LIFECYCLE_LISTENERS after the gateway stops.
  • Pagination gap in session history SSE endpoint: paginateSessionMessages can return { hasMore: true } with no nextCursor when the first message in the page lacks seq metadata, making it impossible for clients to retrieve earlier history.
  • O(n) session-store scan on each transcript event: resolveSessionKeyForTranscriptFile iterates the full combined session store on every transcript update where update.sessionKey is absent, which could degrade under heavy load with many active sessions.
  • The new session-kill-http.ts admin endpoint and sessions-history-http.ts history/SSE endpoint are well-structured with proper auth gating.
  • Cost accumulation in session-usage.ts and OpenRouter pricing cache in model-pricing-cache.ts look correct.

Confidence Score: 3/5

  • This PR is broadly functional but has a resource-leak bug and a pagination correctness issue that should be fixed before merging.
  • Two logic-level issues lower confidence: the lifecycleUnsub listener is never cleaned up on gateway shutdown (potential for stale listeners and memory growth in long-running servers), and the session history pagination can return hasMore: true with no cursor (clients silently lose the ability to page back). Neither is catastrophic but both are observable bugs. The rest of the changes are consistent and well-tested.
  • src/gateway/server-close.ts (missing lifecycleUnsub cleanup) and src/gateway/sessions-history-http.ts (pagination cursor gap) need attention before merge.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/gateway/server-close.ts
Line: 27

Comment:
**`lifecycleUnsub` is not cleaned up on gateway shutdown**

`server.impl.ts` creates a `lifecycleUnsub` via `onSessionLifecycleEvent` (line 856) and passes it to `createGatewayCloseHandler` (line 1210), but `createGatewayCloseHandler`'s params type only added `transcriptUnsub` — `lifecycleUnsub` is absent from the type definition and has no corresponding cleanup block.

As a result, the `SESSION_LIFECYCLE_LISTENERS` set in `session-lifecycle-events.ts` will retain the listener after gateway shutdown. Beyond the memory leak this creates a risk of stale closures firing against a partially-torn-down server.

To fix, add `lifecycleUnsub` alongside the existing `transcriptUnsub`:

```suggestion
  transcriptUnsub: (() => void) | null;
  lifecycleUnsub: (() => void) | null;
```

And add a corresponding cleanup block in the shutdown body (after the `transcriptUnsub` block):

```typescript
if (params.lifecycleUnsub) {
  try {
    params.lifecycleUnsub();
  } catch {
    /* ignore */
  }
}
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/gateway/sessions-history-http.ts
Line: 107-112

Comment:
**`hasMore: true` can be returned without a `nextCursor`**

`paginateSessionMessages` sets `hasMore: start > 0` unconditionally, but `nextCursor` is only included when `firstSeq` is a number:

```typescript
...(start > 0 && typeof firstSeq === "number" ? { nextCursor: String(firstSeq) } : {}),
```

If the first message in the returned page lacks seq metadata (i.e. `resolveMessageSeq(items[0])` returns `undefined`), the response will have `{ hasMore: true }` with no `nextCursor`. Any client that uses `nextCursor` to paginate to the previous page will be unable to do so, silently dropping history.

Consider either guaranteeing that all messages have seq metadata before this path is reached, or falling back to an index-based cursor when `firstSeq` is unavailable:

```typescript
...(start > 0
  ? { nextCursor: typeof firstSeq === "number" ? String(firstSeq) : String(start) }
  : {}),
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/gateway/session-transcript-key.ts
Line: 24-51

Comment:
**O(n) session-store scan on every transcript update**

`resolveSessionKeyForTranscriptFile` does a full linear scan over the entire combined session store, calling `resolveGatewaySessionStoreTarget` and `resolveSessionTranscriptCandidates` for every session entry on each invocation. It is called from the hot `onSessionTranscriptUpdate` handler in `server.impl.ts` whenever `update.sessionKey` is missing.

With a large session store (hundreds of long-running sessions), this will block the event loop noticeably on each transcript append. Consider caching the `sessionFile → sessionKey` lookup or ensuring that `update.sessionKey` is always provided so this fallback is never reached in the common path.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "feat: change default..."

@@ -24,6 +24,7 @@ export function createGatewayCloseHandler(params: {
mediaCleanup: ReturnType<typeof setInterval> | null;
agentUnsub: (() => void) | null;
heartbeatUnsub: (() => void) | null;
transcriptUnsub: (() => void) | null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 lifecycleUnsub is not cleaned up on gateway shutdown

server.impl.ts creates a lifecycleUnsub via onSessionLifecycleEvent (line 856) and passes it to createGatewayCloseHandler (line 1210), but createGatewayCloseHandler's params type only added transcriptUnsub — lifecycleUnsub is absent from the type definition and has no corresponding cleanup block.

As a result, the SESSION_LIFECYCLE_LISTENERS set in session-lifecycle-events.ts will retain the listener after gateway shutdown. Beyond the memory leak this creates a risk of stale closures firing against a partially-torn-down server.

To fix, add lifecycleUnsub alongside the existing transcriptUnsub:

Suggested change
transcriptUnsub: (() => void) | null;
transcriptUnsub: (() => void) | null;
lifecycleUnsub: (() => void) | null;

And add a corresponding cleanup block in the shutdown body (after the transcriptUnsub block):

if (params.lifecycleUnsub) {
  try {
    params.lifecycleUnsub();
  } catch {
    /* ignore */
  }
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/server-close.ts
Line: 27

Comment:
**`lifecycleUnsub` is not cleaned up on gateway shutdown**

`server.impl.ts` creates a `lifecycleUnsub` via `onSessionLifecycleEvent` (line 856) and passes it to `createGatewayCloseHandler` (line 1210), but `createGatewayCloseHandler`'s params type only added `transcriptUnsub` — `lifecycleUnsub` is absent from the type definition and has no corresponding cleanup block.

As a result, the `SESSION_LIFECYCLE_LISTENERS` set in `session-lifecycle-events.ts` will retain the listener after gateway shutdown. Beyond the memory leak this creates a risk of stale closures firing against a partially-torn-down server.

To fix, add `lifecycleUnsub` alongside the existing `transcriptUnsub`:

```suggestion
  transcriptUnsub: (() => void) | null;
  lifecycleUnsub: (() => void) | null;
```

And add a corresponding cleanup block in the shutdown body (after the `transcriptUnsub` block):

```typescript
if (params.lifecycleUnsub) {
  try {
    params.lifecycleUnsub();
  } catch {
    /* ignore */
  }
}
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +107 to +112
return {
items,
messages: items,
hasMore: start > 0,
...(start > 0 && typeof firstSeq === "number" ? { nextCursor: String(firstSeq) } : {}),
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 hasMore: true can be returned without a nextCursor

paginateSessionMessages sets hasMore: start > 0 unconditionally, but nextCursor is only included when firstSeq is a number:

...(start > 0 && typeof firstSeq === "number" ? { nextCursor: String(firstSeq) } : {}),

If the first message in the returned page lacks seq metadata (i.e. resolveMessageSeq(items[0]) returns undefined), the response will have { hasMore: true } with no nextCursor. Any client that uses nextCursor to paginate to the previous page will be unable to do so, silently dropping history.

Consider either guaranteeing that all messages have seq metadata before this path is reached, or falling back to an index-based cursor when firstSeq is unavailable:

...(start > 0
  ? { nextCursor: typeof firstSeq === "number" ? String(firstSeq) : String(start) }
  : {}),
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/sessions-history-http.ts
Line: 107-112

Comment:
**`hasMore: true` can be returned without a `nextCursor`**

`paginateSessionMessages` sets `hasMore: start > 0` unconditionally, but `nextCursor` is only included when `firstSeq` is a number:

```typescript
...(start > 0 && typeof firstSeq === "number" ? { nextCursor: String(firstSeq) } : {}),
```

If the first message in the returned page lacks seq metadata (i.e. `resolveMessageSeq(items[0])` returns `undefined`), the response will have `{ hasMore: true }` with no `nextCursor`. Any client that uses `nextCursor` to paginate to the previous page will be unable to do so, silently dropping history.

Consider either guaranteeing that all messages have seq metadata before this path is reached, or falling back to an index-based cursor when `firstSeq` is unavailable:

```typescript
...(start > 0
  ? { nextCursor: typeof firstSeq === "number" ? String(firstSeq) : String(start) }
  : {}),
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +24 to +51
export function resolveSessionKeyForTranscriptFile(sessionFile: string): string | undefined {
const targetPath = resolveTranscriptPathForComparison(sessionFile);
if (!targetPath) {
return undefined;
}
const cfg = loadConfig();
const { store } = loadCombinedSessionStoreForGateway(cfg);
for (const [key, entry] of Object.entries(store)) {
if (!entry?.sessionId) {
continue;
}
const target = resolveGatewaySessionStoreTarget({
cfg,
key,
scanLegacyKeys: false,
store,
});
const sessionAgentId = normalizeAgentId(target.agentId);
const matches = resolveSessionTranscriptCandidates(
entry.sessionId,
target.storePath,
entry.sessionFile,
sessionAgentId,
).some((candidate) => resolveTranscriptPathForComparison(candidate) === targetPath);
if (matches) {
return key;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 O(n) session-store scan on every transcript update

resolveSessionKeyForTranscriptFile does a full linear scan over the entire combined session store, calling resolveGatewaySessionStoreTarget and resolveSessionTranscriptCandidates for every session entry on each invocation. It is called from the hot onSessionTranscriptUpdate handler in server.impl.ts whenever update.sessionKey is missing.

With a large session store (hundreds of long-running sessions), this will block the event loop noticeably on each transcript append. Consider caching the sessionFile → sessionKey lookup or ensuring that update.sessionKey is always provided so this fallback is never reached in the common path.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/session-transcript-key.ts
Line: 24-51

Comment:
**O(n) session-store scan on every transcript update**

`resolveSessionKeyForTranscriptFile` does a full linear scan over the entire combined session store, calling `resolveGatewaySessionStoreTarget` and `resolveSessionTranscriptCandidates` for every session entry on each invocation. It is called from the hot `onSessionTranscriptUpdate` handler in `server.impl.ts` whenever `update.sessionKey` is missing.

With a large session store (hundreds of long-running sessions), this will block the event loop noticeably on each transcript append. Consider caching the `sessionFile → sessionKey` lookup or ensuring that `update.sessionKey` is always provided so this fallback is never reached in the common path.

How can I resolve this? If you propose a fix, please make it concise.

@tyler6204 tyler6204 self-assigned this Mar 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00d052a661

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +109 to +111
"sessions.create",
"sessions.send",
"sessions.abort",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Classify sessions.steer as operator write method

sessions.steer is implemented in sessionsHandlers, but it is not added to METHOD_SCOPE_GROUPS. Because authorizeOperatorScopesForMethod falls back unclassified methods to operator.admin, any client connected with least-privilege operator.write scopes will be blocked from steering with a missing scope: operator.admin error, even though sessions.send/sessions.abort are write-level operations in the same flow.

Useful? React with 👍 / 👎.

Comment on lines +62 to +64
"sessions.create",
"sessions.send",
"sessions.abort",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Advertise sessions.steer in gateway feature method list

The gateway now supports sessions.steer, but listGatewayMethods() does not include it in the advertised method set. Since hello payloads expose features.methods from this list, capability-aware clients can conclude steering is unsupported and skip calling the RPC despite the handler existing, creating a protocol/feature-discovery mismatch.

Useful? React with 👍 / 👎.

steipete added a commit that referenced this pull request Aug 9, 2026
Transcript-update broadcasts were serialized behind one global promise queue,
so one session's pending async seq read head-of-line blocked every other
session's session.message and sessions.changed delivery. Ordering is a
per-transcript contract, so key the queue by transcript identity and drop
drained lanes.

Per-message transcript usage stays derived: session.message payloads carry
live totalTokens/estimatedCostUsd as a dashboard API contract (#50101).
steipete added a commit that referenced this pull request Aug 9, 2026
* perf(gateway): per-transcript broadcast lanes

Transcript-update broadcasts were serialized behind one global promise queue,
so one session's pending async seq read head-of-line blocked every other
session's session.message and sessions.changed delivery. Ordering is a
per-transcript contract, so key the queue by transcript identity and drop
drained lanes.

Per-message transcript usage stays derived: session.message payloads carry
live totalTokens/estimatedCostUsd as a dashboard API contract (#50101).

* fix(ui): target the Cloud Worker Desktop labs row in its toggle test

The row added in #120727 reused index 6, which belongs to Message audit
metadata, so the case toggled the audit row and asserted its patch. Labs
features render in registry order, and workerDesktop is the eighth entry.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
* perf(gateway): per-transcript broadcast lanes

Transcript-update broadcasts were serialized behind one global promise queue,
so one session's pending async seq read head-of-line blocked every other
session's session.message and sessions.changed delivery. Ordering is a
per-transcript contract, so key the queue by transcript identity and drop
drained lanes.

Per-message transcript usage stays derived: session.message payloads carry
live totalTokens/estimatedCostUsd as a dashboard API contract (openclaw#50101).

* fix(ui): target the Cloud Worker Desktop labs row in its toggle test

The row added in openclaw#120727 reused index 6, which belongs to Message audit
metadata, so the case toggled the audit row and asserted its patch. Labs
features render in registry order, and workerDesktop is the eighth entry.
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* fix: make cleanup "keep" persist subagent sessions indefinitely

* feat: expose subagent session metadata in sessions list

* fix: include status and timing in sessions_list tool

* fix: hide injected timestamp prefixes in chat ui

* feat: push session list updates over websocket

* feat: expose child subagent sessions in subagents list

* feat: add admin http endpoint to kill sessions

* Emit session.message websocket events for transcript updates

* Estimate session costs in sessions list

* Add direct session history HTTP and SSE endpoints

* Harden dashboard session events and history APIs

* Add session lifecycle gateway methods

* Add dashboard session API improvements

* Add dashboard session model and parent linkage support

* fix: tighten dashboard session API metadata

* Fix dashboard session cost metadata

* Persist accumulated session cost

* fix: stop followup queue drain cfg crash

* Fix dashboard session create and model metadata

* fix: stop guessing session model costs

* Gateway: cache OpenRouter pricing for configured models

* Gateway: add timeout session status

* Fix subagent spawn test config loading

* Gateway: preserve operator scopes without device identity

* Emit user message transcript events and deduplicate plugin warnings

* feat: emit sessions.changed lifecycle event on subagent spawn

Adds a session-lifecycle-events module (similar to transcript-events)
that emits create events when subagents are spawned. The gateway
server.impl.ts listens for these events and broadcasts sessions.changed
with reason=create to SSE subscribers, so dashboards can pick up new
subagent sessions without polling.

* Gateway: allow persistent dashboard orchestrator sessions

* fix: preserve operator scopes for token-authenticated backend clients

Backend clients (like agent-dashboard) that authenticate with a valid gateway
token but don't present a device identity were getting their scopes stripped.
The scope-clearing logic ran before checking the device identity decision,
so even when evaluateMissingDeviceIdentity returned 'allow' (because
roleCanSkipDeviceIdentity passed for token-authed operators), scopes were
already cleared.

Fix: also check decision.kind before clearing scopes, so token-authenticated
operators keep their requested scopes.

* Gateway: allow operator-token session kills

* Fix stale active subagent status after follow-up runs

* Fix dashboard image attachments in sessions send

* Fix completed session follow-up status updates

* feat: stream session tool events to operator UIs

* Add sessions.steer gateway coverage

* Persist subagent timing in session store

* Fix subagent session transcript event keys

* Fix active subagent session status in gateway

* bump session label max to 512

* Fix gateway send session reactivation

* fix: publish terminal session lifecycle state

* feat: change default session reset to effectively never

- Change DEFAULT_RESET_MODE from "daily" to "idle"
- Change DEFAULT_IDLE_MINUTES from 60 to 0 (0 = disabled/never)
- Allow idleMinutes=0 through normalization (don't clamp to 1)
- Treat idleMinutes=0 as "no idle expiry" in evaluateSessionFreshness
- Default behavior: mode "idle" + idleMinutes 0 = sessions never auto-reset
- Update test assertion for new default mode

* fix: prep session management followups (openclaw#50101) (thanks @clay-datacurve)

---------

Co-authored-by: Tyler Yust <[email protected]>
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
* fix: make cleanup "keep" persist subagent sessions indefinitely

* feat: expose subagent session metadata in sessions list

* fix: include status and timing in sessions_list tool

* fix: hide injected timestamp prefixes in chat ui

* feat: push session list updates over websocket

* feat: expose child subagent sessions in subagents list

* feat: add admin http endpoint to kill sessions

* Emit session.message websocket events for transcript updates

* Estimate session costs in sessions list

* Add direct session history HTTP and SSE endpoints

* Harden dashboard session events and history APIs

* Add session lifecycle gateway methods

* Add dashboard session API improvements

* Add dashboard session model and parent linkage support

* fix: tighten dashboard session API metadata

* Fix dashboard session cost metadata

* Persist accumulated session cost

* fix: stop followup queue drain cfg crash

* Fix dashboard session create and model metadata

* fix: stop guessing session model costs

* Gateway: cache OpenRouter pricing for configured models

* Gateway: add timeout session status

* Fix subagent spawn test config loading

* Gateway: preserve operator scopes without device identity

* Emit user message transcript events and deduplicate plugin warnings

* feat: emit sessions.changed lifecycle event on subagent spawn

Adds a session-lifecycle-events module (similar to transcript-events)
that emits create events when subagents are spawned. The gateway
server.impl.ts listens for these events and broadcasts sessions.changed
with reason=create to SSE subscribers, so dashboards can pick up new
subagent sessions without polling.

* Gateway: allow persistent dashboard orchestrator sessions

* fix: preserve operator scopes for token-authenticated backend clients

Backend clients (like agent-dashboard) that authenticate with a valid gateway
token but don't present a device identity were getting their scopes stripped.
The scope-clearing logic ran before checking the device identity decision,
so even when evaluateMissingDeviceIdentity returned 'allow' (because
roleCanSkipDeviceIdentity passed for token-authed operators), scopes were
already cleared.

Fix: also check decision.kind before clearing scopes, so token-authenticated
operators keep their requested scopes.

* Gateway: allow operator-token session kills

* Fix stale active subagent status after follow-up runs

* Fix dashboard image attachments in sessions send

* Fix completed session follow-up status updates

* feat: stream session tool events to operator UIs

* Add sessions.steer gateway coverage

* Persist subagent timing in session store

* Fix subagent session transcript event keys

* Fix active subagent session status in gateway

* bump session label max to 512

* Fix gateway send session reactivation

* fix: publish terminal session lifecycle state

* feat: change default session reset to effectively never

- Change DEFAULT_RESET_MODE from "daily" to "idle"
- Change DEFAULT_IDLE_MINUTES from 60 to 0 (0 = disabled/never)
- Allow idleMinutes=0 through normalization (don't clamp to 1)
- Treat idleMinutes=0 as "no idle expiry" in evaluateSessionFreshness
- Default behavior: mode "idle" + idleMinutes 0 = sessions never auto-reset
- Update test assertion for new default mode

* fix: prep session management followups (openclaw#50101) (thanks @clay-datacurve)

---------

Co-authored-by: Tyler Yust <[email protected]>
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
* fix: make cleanup "keep" persist subagent sessions indefinitely

* feat: expose subagent session metadata in sessions list

* fix: include status and timing in sessions_list tool

* fix: hide injected timestamp prefixes in chat ui

* feat: push session list updates over websocket

* feat: expose child subagent sessions in subagents list

* feat: add admin http endpoint to kill sessions

* Emit session.message websocket events for transcript updates

* Estimate session costs in sessions list

* Add direct session history HTTP and SSE endpoints

* Harden dashboard session events and history APIs

* Add session lifecycle gateway methods

* Add dashboard session API improvements

* Add dashboard session model and parent linkage support

* fix: tighten dashboard session API metadata

* Fix dashboard session cost metadata

* Persist accumulated session cost

* fix: stop followup queue drain cfg crash

* Fix dashboard session create and model metadata

* fix: stop guessing session model costs

* Gateway: cache OpenRouter pricing for configured models

* Gateway: add timeout session status

* Fix subagent spawn test config loading

* Gateway: preserve operator scopes without device identity

* Emit user message transcript events and deduplicate plugin warnings

* feat: emit sessions.changed lifecycle event on subagent spawn

Adds a session-lifecycle-events module (similar to transcript-events)
that emits create events when subagents are spawned. The gateway
server.impl.ts listens for these events and broadcasts sessions.changed
with reason=create to SSE subscribers, so dashboards can pick up new
subagent sessions without polling.

* Gateway: allow persistent dashboard orchestrator sessions

* fix: preserve operator scopes for token-authenticated backend clients

Backend clients (like agent-dashboard) that authenticate with a valid gateway
token but don't present a device identity were getting their scopes stripped.
The scope-clearing logic ran before checking the device identity decision,
so even when evaluateMissingDeviceIdentity returned 'allow' (because
roleCanSkipDeviceIdentity passed for token-authed operators), scopes were
already cleared.

Fix: also check decision.kind before clearing scopes, so token-authenticated
operators keep their requested scopes.

* Gateway: allow operator-token session kills

* Fix stale active subagent status after follow-up runs

* Fix dashboard image attachments in sessions send

* Fix completed session follow-up status updates

* feat: stream session tool events to operator UIs

* Add sessions.steer gateway coverage

* Persist subagent timing in session store

* Fix subagent session transcript event keys

* Fix active subagent session status in gateway

* bump session label max to 512

* Fix gateway send session reactivation

* fix: publish terminal session lifecycle state

* feat: change default session reset to effectively never

- Change DEFAULT_RESET_MODE from "daily" to "idle"
- Change DEFAULT_IDLE_MINUTES from 60 to 0 (0 = disabled/never)
- Allow idleMinutes=0 through normalization (don't clamp to 1)
- Treat idleMinutes=0 as "no idle expiry" in evaluateSessionFreshness
- Default behavior: mode "idle" + idleMinutes 0 = sessions never auto-reset
- Update test assertion for new default mode

* fix: prep session management followups (openclaw#50101) (thanks @clay-datacurve)

---------

Co-authored-by: Tyler Yust <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants