Skip to content

Control UI sessions.list refresh can stall Gateway with large session stores #77056

@hansolo949

Description

@hansolo949

Summary

On a Control UI instance with a large accumulated session store (~116 visible sessions), routine sessions.list refreshes can create noticeable Gateway stalls and liveness warnings. The most visible path is the chat-turn completion refresh: Control UI requests recent sessions with activeMinutes and a relatively broad limit, which forces repeated row/model/session enrichment work during normal chat use.

This is narrower than #76562, but likely part of the same control-plane latency family.

Observed locally

Environment:

  • OpenClaw 2026.5.2
  • macOS / Node 22
  • Control UI direct webchat
  • ~116 active/visible sessions in the session store

Before local mitigation:

  • openclaw sessions --json: ~16.3s
  • imported listSessionsFromStoreAsync({}): ~20.4s
  • limit:20: ~3.9s
  • cold Control UI reconnect could produce sessions.list spikes around ~16-19s
  • liveness warnings showed event-loop delay spikes in the ~1-3s range during active UI/tooling work

After local mitigation:

  • steady sessions.list: ~69-124ms
  • Gateway reachable: ~196ms
  • quiet CPU sample: ~0.2%, sleeping
  • remaining cold reconnect RPCs (node.list, chat.history) can still briefly spike around ~0.9-1.2s, so this is not a full control-plane fix

Suspected hot paths

The local profile/debugging pointed at two avoidable costs:

  1. buildGatewaySessionRow calling isCliProvider repeatedly across many rows, which can repeatedly reach plugin/setup CLI backend discovery.
  2. Control UI chat lifecycle refreshes asking for a broader session window than the chat sidebar needs.

Some source-side work on main already appears to have improved session row hydration, but the chat completion refresh can still be bounded more aggressively.

Proposed fix

A small PR is coming that:

  • caches isCliProvider lookup results by normalized provider + configured CLI backend keys
  • caps the Control UI chat-turn session refresh to the small recent-window count the sidebar needs

This should reduce normal chat-turn control-plane pressure without changing the explicit Sessions page/search flows.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions