Skip to content

Give session recovery one owner #494

Closed

Description

@lynnswap

Why

Session recovery in MCPClientSessionAuthority takes about 1,000 lines and eight state types (RecoveryState, RecoveryBackgroundLease, RetiredRecovery, RecoveryPlan, HiddenHandshake, and others). The worker runs detached from the actor and re-authorizes itself after each step, and cancelled recoveries are kept in a second table so that close() can wait for them. A second actor, InitializedMCPClientSession, sits on top for request correlation.

What

  • Recovery has one owner for its task and state, and close() waits for it without a table of retired work.

  • Recovery keeps its guarantees: one shared handshake for concurrent callers, at most one replay of a request rejected before processing, no replay when delivery is unknown, and a failed recovery leaves the connection unavailable until reconnect(timeout:).

  • Whether a recovery continues after its last waiting caller is cancelled is decided and documented. Today it is abandoned unless the event stream started it.

  • Ref: Bring the package structure and SDK API in line with the owned-host design #483

Activity

  1. lynnswap commented on Nov 20, 2026

    @lynnswap
    OwnerAuthor

    Decision: a recovery continues after its last waiting caller is cancelled. It ends when it completes, when its own deadline passes, or when the client closes. Today the abandoned recovery leaves the connection unavailable until reconnect(timeout:), so cancelling one request can stop every later request.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions