openclaw - 💡(How to fix) Fix [Feature]: Support external unified session storage for stateless session mode [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63492Fetched 2026-04-09 07:53:08
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
labeled ×1

Introduce a pluggable session storage backend (Redis, MongoDB, etc.) to enable stateless session sharing across multiple Openclaw instances, eliminating session stickiness and improving horizontal scalability.

Error Message

2025-03-20 10:15:45 WARN [session] Session session_abc123 not found in local storage (./data/sessions/) 2025-03-20 10:15:45 ERROR [middleware] Failed to load session, starting new empty session

Root Cause

Introduce a pluggable session storage backend (Redis, MongoDB, etc.) to enable stateless session sharing across multiple Openclaw instances, eliminating session stickiness and improving horizontal scalability.

Fix Action

Fix / Workaround

2、Severity For single‑instance deployments – low (no change). For multi‑instance deployments – high (currently blocks stateless scaling; workarounds are complex and fragile).

RAW_BUFFERClick to expand / collapse

Summary

Introduce a pluggable session storage backend (Redis, MongoDB, etc.) to enable stateless session sharing across multiple Openclaw instances, eliminating session stickiness and improving horizontal scalability.

Problem to solve

Currently Openclaw stores sessions only in the local filesystem. In multi‑instance deployments (e.g., Kubernetes, load‑balanced servers), each instance has its own session files, causing:

  • Session stickiness – user requests must always be routed to the same instance; otherwise session data is lost.
  • Limited scalability – adding more instances does not help session handling capacity.
  • Poor reliability – an instance crash permanently loses its local sessions.

This makes Openclaw unsuitable for cloud‑native, distributed environments where stateless, horizontally scalable services are required.

Proposed solution

Design a unified session storage abstraction with pluggable backends, allowing sessions to be read from/written to an external storage system. The solution includes:

  1. Storage interface – defines core operations (get, set, delete, exists) as an abstract base class.
  2. File system storage (default) – keeps the current behavior for backward compatibility.
  3. External storage implementations – initially Redis (recommended) and MongoDB, with more to be added.
  4. Factory & manager – creates the appropriate storage instance based on configuration.
  5. Configuration extension – new session_storage section in the config file, e.g.:
    session_storage:
      backend: redis
      redis_host: localhost
      redis_port: 6379
      default_ttl: 604800

All session management code uses the storage interface, so the rest of the application remains unchanged. This enables any instance to access any session, achieving true stateless operation.

Alternatives considered

Sticky sessions via load balancer – does not solve the underlying issue; session loss still occurs on instance failure, and scaling is not flexible.

Client‑side sessions (e.g., JWT) – limited by payload size and security concerns, not suitable for large or sensitive session data.

Hard‑coded Redis support only – lacks extensibility and maintainability; forces a single backend without a clean abstraction.

The proposed interface‑based approach is the most maintainable, flexible, and future‑proof.

Impact

1、Affected users/systems/channels All Openclaw users deploying more than one instance (e.g., in Kubernetes, cloud auto‑scaling groups). Both single‑tenant and multi‑tenant setups benefit.

2、Severity For single‑instance deployments – low (no change). For multi‑instance deployments – high (currently blocks stateless scaling; workarounds are complex and fragile).

3、Frequency Always occurs in multi‑instance setups. As more users adopt container orchestration, this pain point becomes increasingly common.

4、Consequence Without this feature, users must either force session stickiness (which limits elasticity and fault tolerance) or accept random session failures. This leads to operational overhead, poor user experience, and increased manual intervention (e.g., clearing stale sessions, debugging routing issues).

5、Practical consequences

Delays in feature rollout for horizontally scaled deployments.

Extra manual work to manage session affinity rules and monitor instance health.

Risk of data loss when an instance crashes.

Inability to use Openclaw in serverless or ephemeral compute environments.

This enhancement is a prerequisite for production‑ready, cloud‑native Openclaw deployments.

Evidence/examples

  1. Log example showing session loss with current file‑system storage in a multi‑instance deployment Two instances (A and B). A user request hits instance A first (session created), then a subsequent request is routed to instance B: Instance A log (session creation) 2025-03-20 10:15:32 INFO [session] Created session session_abc123, saved to ./data/sessions/abc123.json 2025-03-20 10:15:33 INFO [request] User request handled by instance A, session_id=abc123

Instance B log (next request from same user) 2025-03-20 10:15:45 WARN [session] Session session_abc123 not found in local storage (./data/sessions/) 2025-03-20 10:15:45 ERROR [middleware] Failed to load session, starting new empty session

Consequence: Conversation context is lost; the agent cannot continue the previous dialogue.

Additional information

Security considerations 1、Connection credentials (passwords, URIs) for external storage must be read from environment variables or a secret manager, not hard‑coded in configuration files. 2、Sensitive session fields (e.g., user tokens) could be encrypted before storage (AES‑256‑GCM). This can be a follow‑up enhancement.

extent analysis

TL;DR

Implement a pluggable session storage backend, such as Redis or MongoDB, to enable stateless session sharing across multiple Openclaw instances.

Guidance

  • Introduce a unified session storage abstraction with a storage interface that defines core operations (get, set, delete, exists) to allow for pluggable backends.
  • Implement external storage implementations, starting with Redis and MongoDB, to enable stateless session sharing.
  • Update the configuration to include a session_storage section, allowing users to specify the backend and connection details.
  • Ensure that connection credentials for external storage are read from environment variables or a secret manager, and consider encrypting sensitive session fields before storage.

Example

session_storage:
  backend: redis
  redis_host: localhost
  redis_port: 6379
  default_ttl: 604800

This example configuration snippet demonstrates how to specify Redis as the session storage backend.

Notes

The proposed solution requires careful consideration of security implications, such as storing connection credentials securely and potentially encrypting sensitive session data. Additionally, the implementation should be designed to be extensible and maintainable, allowing for easy addition of new storage backends in the future.

Recommendation

Apply the proposed solution of introducing a pluggable session storage backend, starting with Redis and MongoDB implementations, to enable stateless session sharing and improve horizontal scalability. This approach provides a flexible and maintainable solution that addresses the current limitations of session stickiness and limited scalability.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING