OpenClaw / OpenClaw Core
Merged upstreamPerformanceMerged Aug 21, 2026

Avoid session-store reads during streamed Gateway responses

Fixed OpenClaw Gateway streaming so restart-recovery session-store discovery runs only for lifecycle phases that consume durable recovery state, not for every streamed response event.

openclaw/openclaw · #125872

Performance and reliability improvement

Streamed agent responses no longer pay restart-recovery session-store discovery cost on every event.

Problem

Gateway session-store discovery ran once per stream event, so post-turn work scaled with streamed answer length. Assistant, thinking, tool, and fallback events were touching a durable-state path they did not need.

Approach

Restricted restart-recovery lookup to the recognized lifecycle phases that consume it: start, end, and error. Streamed assistant, thinking, tool, and fallback events keep their delivery behavior without invoking the session-store discovery path.

Impact and scope

  • Prevents longer streamed agent responses from accumulating avoidable restart-recovery lookup overhead.
  • Preserves restart suppression and terminal lifecycle handling while reducing unnecessary durable-state reads.
  • Improves Gateway behavior for multi-agent workloads where response length and event volume can grow quickly.

Validation

  • Added focused Gateway event-bus coverage showing assistant and fallback stream events no longer trigger unexpected session-entry reads.
  • Used a V8 precise-call-coverage probe against an isolated real Gateway: main ran 23 resolver calls, the fix reduced it to 2 for start and end.
  • PR evidence reports 146 Gateway agent-event tests, 60 recovery/runtime tests, and changed-file checks passed.