Skip to content

WebSocket session identifier field is inconsistent and should be standardized to key #297

@flyflypeng

Description

@flyflypeng

Background

The WebSocket protocol in MicroClaw uses inconsistent JSON field names for session identifiers (sessionKey, sessionId, session_id, and key), which breaks compatibility with OpenClaw clients expecting key.

Expected Behavior

All WebSocket request/response payloads and event payloads should use a single field name for session identifier:

  • key

Internally, Rust code can keep session_key, but serde should map it to/from key.

Impact

High - Protocol inconsistency impacts client interoperability and can cause session resolution/parsing failures in integrations expecting OpenClaw-compatible payloads.

Proposed Fix

  1. Keep internal Rust field names as session_key.
  2. Use serde mapping for all relevant structs:
    • #[serde(rename = "key")]
  3. Ensure all JSON payload builders return:
    • "key": session_key
  4. Remove legacy mixed naming in WebSocket method responses/events.

Verification

  • cargo check passes.
  • Related unit test run passes:
    • cargo test test_expected_closed_socket_errors_are_downgraded

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions