You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(chat,sdk): hold the resume cursor only behind records that matter
The `session-in-event-id` header has two consumers with opposite needs. A
fresh boot reads it back as the `.in` resume cursor and needs it conservative,
while a client compares it against the append sequence of its own send to
recognise a turn boundary that predates that send, which needs it exact.
Holding the cursor behind every unconsumed record served neither: an
unconsumed control record pushed the header below the sequence of the message
the turn had just answered, so a client discarded its own turn-complete and
stayed streaming.
The cursor is now held only behind records whose loss would matter, which for
chat means messages. Replaying a stop or a handover on the next boot is
benign, and a handover for a turn that never ran is discarded, so control
records no longer need to hold the cursor. The manager takes the rule as a
per-channel predicate and defaults to holding behind everything, so a missing
or throwing predicate can only make the cursor more conservative. This also
ends the case where one never-consumed record pinned the cursor for the rest
of the run.
Two further gaps in the same machinery:
The unclaimed-kind drain and the cursor rule were installed only for
`chat.customAgent`. `chat.agent` builds its task directly and got neither, so
the managed agent, which is the common surface, kept accumulating barriers
mid-turn. Both are now installed for both surfaces, with the drain attached
after each one's resume cursor is seeded so it cannot open the subscribe at
seq 0.
A handover-prepare boot claims the handover kinds so a signal arriving before
`waitForHandover` attaches is not drained, but the claim was released only
inside `waitForHandover`. A loop that never called it held the claim for the
life of the run, leaving a handover record parked at the head of the channel
where it wedged `chat.messages.next()` permanently. The claim is now also
released at the first turn boundary, by which point the handover window has
closed either way.
0 commit comments