Skip to content

[Bug]: SubscriptionManager._message_subs leaks empty sets on message unsubscription and connection teardown #609

Description

@bukeeastrey

Duplicate check

  • I searched the existing open and closed issues and this is not a duplicate.

AgentOS version or commit

v2026.8.29

Area

Gateway

Reproduction steps

  1. Open a WebSocket connection and subscribe to session messages for several session keys (sessions.messages.subscribe).
  2. Unsubscribe from the sessions via sessions.messages.unsubscribe or disconnect the WebSocket client.
  3. Inspect subscription_manager._message_subs.

Expected behavior

Empty sets for sessions with no remaining subscribers are deleted from _message_subs.

Actual behavior

Stale session_key keys containing empty set() objects linger in _message_subs indefinitely, accumulating memory over time on a long-running gateway.

Environment

Windows 11, Python 3.12, uv

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: gatewayGateway services, RPC, sessions, and transportpriority: p3Low priority: minor issue, polish, or backlog workstatus: needs reviewImplementation exists and needs maintainer reviewtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions