Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🧹 chore: describe the init/subscribe race instead of an internal issue id (2026-09-16) (#19623)

Arvin Xud9cf1afcc856
diff --git a/packages/agent-gateway-client/PROTOCOL_V2.md b/packages/agent-gateway-client/PROTOCOL_V2.md
index 25e533f84d7..e00416a56b1 100644
--- a/packages/agent-gateway-client/PROTOCOL_V2.md
+++ b/packages/agent-gateway-client/PROTOCOL_V2.md
@@ -262,8 +262,10 @@ Subscribe algorithm (per connection, per op):
1. Record sub `{ lastSeq: Number(lastEventId ?? 0), executor, state:'replaying' }`.
2. Call op DO `hub-subscribe`. If it returns a `userId` that ≠ hub's userId ⇒
`subscribe_failed{forbidden}` and drop the sub. If `userId` is undefined (op not inited
- yet — the init/subscribe race, LOBE-10443): keep the sub with `state:'pending'`, send
- `resume_complete{ pending:true, gap:false }` and return; when an `op-lifecycle` with
+ yet — the init/subscribe race: a subscriber that arrives before the op exists must not be
+ answered with an empty replay, because the client reads an empty replay as a finished
+ session and clears the shared `runningOperation`): keep the sub with `state:'pending'`,
+ send `resume_complete{ pending:true, gap:false }` and return; when an `op-lifecycle` with
status `running` arrives for that op, run steps 3-5 for every pending sub.
3. Call op DO `replay{ since: String(lastSeq) }`; send each returned message (with
`operationId` added) in order, updating `lastSeq`.