Repository navigation
Expose a submission retry to clients that read the conversation stream #844
rikbrown
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Observed behaviour
A Cloudflare Durable Object can reset during a direct submission, for example with "Durable Object reset because its code was updated" after a deployment. The coordinator claims the submission again and resumes it from the persisted context. The recovery works, but a client that reads the conversation stream cannot see it:
{"type":"interrupted","message":"Tool execution was interrupted before completion. The outcome is unknown."}marker.A chat UI keeps its "working" state for the full gap. It cannot tell the user that the reply stopped and continues from the last completed step.
Cause and code location
processSubmissionemitssubmission_runningwithattemptCountandmaxAttempts, and the coordinator emitssubmission_recovery. Both go only toobserve()subscribers on the server. The attempt thatprocessSubmissionpasses tosession.processSubmissionInputholds onlysubmissionIdandattemptId, so the code that writes the response (runPersistedContextInput) cannot tell a retry from a first attempt. Both functions are indist/conversation-stream-store-*.mjsin 2.1.1.Proposed change
Pass the attempt count to the session. When an attempt after the first resumes a response that already has output, write a message data part with
{ attemptCount, maxAttempts }to that response:beginResponseOutputadopts the earlier attempt's durable anchor, soresponseHasCompletedStepis true when the earlier attempt left an assistant message. An attempt that left none has no anchor for the part, and the client's pending state already covers that case. The part name is only an example; a name chosen by the package works as well.A smaller alternative: only pass
attemptCountandmaxAttemptsin the submission attempt, and let the app write its own part.Environment
@flue/runtime2.1.1, Cloudflare coordinator,durability.maxAttemptsat its default of 10.All reactions