Skip to content

Refactor WebSocket method names to sessions.* and add dynamic filtering to sessions.list #295

@flyflypeng

Description

@flyflypeng

Summary

Refactor WebSocket method names for OpenClaw compatibility and implement dynamic sessions.list endpoint with filtering capabilities.

Background & Motivation

  1. Naming Consistency: The previous WebSocket method names (e.g., session_delete, sessions_send) used a mix of snake_case and lacked a consistent namespace structure. They needed to be standardized to the sessions.xxx format (e.g., sessions.delete, sessions.send) to maintain internal consistency and ensure full compatibility with the OpenClaw API specification.
  2. Hardcoded Logic: In the initial implementation of the sessions.list method, the session filtering logic was hardcoded in the backend service (.filter(|s| s.session_key.starts_with("chatclaw:microclaw"))). This was inflexible and violated the OpenClaw API contract, which specifies that filtering should be driven by client-provided request parameters.

Expected Behavior

  • WebSocket clients must use the new sessions.xxx method names.
  • Clients calling sessions.list can optionally provide agentId or search parameters to filter the returned session list.
  • If a client calls sessions.list with an empty payload {}, the server will return all available recent sessions without any filtering.

Impact

Medium - Improves API standardization and aligns the implementation with the OpenClaw specification, enabling better integration with compatible clients.

Future Use Case: Claw Chrome Extension Integration

These enhancements to the WebSocket methods serve a broader goal: establishing a reliable foundation for building a Claw-ecosystem Chrome Extension.

By strictly adhering to the OpenClaw API contract (like sessions.list and standardizing to sessions.*), the MicroClaw backend can now seamlessly serve as the local agent engine for the Chrome Extension. This will allow the extension to query session history dynamically, manage chat sessions via standard WebSocket events, and provide users with a unified, browser-native AI assistant experience.

Image

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