c29c9d1790
A group member turn is a session-scoped RPC sequence (resume → attach → prompt.submit → poll) issued with the runtime id its first RPC minted, but requestForBot routes every RPC through its own request-scoped socket lease (retained:false secondaries in store/gateway). Between two RPCs the refcount hits 0, the leased socket closes, the gateway detaches the runtime session on WS disconnect, the orphan reaper frees it after grace, and the next RPC — prompt.submit, unwrapped — dies 4001 'not in memory'. The member turn aborts and the sub-profile bot goes silent in the room. - store/gateway: retainGatewayForAgent(connectionId, profile) — refcounted hold on the pooled socket with an idempotent release, mirroring the existing request-lease machinery. - sdk: host.retainProfile(route) exposes the retain to plugins (feature-detected by consumers; older hosts keep working). - hermes-bots plugin: runGroupChatMemberTurn acquires the lease before ensureGroupChatSession's first RPC and releases in finally, so the socket that minted the runtime id stays open across attach+submit+poll; and prompt.submit gets a one-shot catch-and-retry that re-resumes via the STORED session id on 4001-class failures (belt-and-braces for routes the lease can't cover). 4007 'never existed' keeps flowing to session.create. Tests: simulated 4001 on first submit recovers via re-resume and delivers; lease held across attach+submit (mock refcount never hits 0 mid-turn); lease released after success AND failure; no-retainProfile host feature detection; store-level retain/release + idempotent double-release + the unretained disposal race.