Skip to content

feat: generate into a pending message, at most once - #444

Draft
robelest wants to merge 46 commits into
mainfrom
feat/150-pending-message
Draft

robelest wants to merge 46 commits into
mainfrom
feat/150-pending-message

Conversation

@robelest

Copy link
Copy Markdown
Collaborator

Draft for discussion of #150 and #168. Not for merging yet.

pendingMessageId lets a generation fill a pending message the caller saved, at most once, with its stream linked to that message. Claims live in a new claims table. example/convex/batch uses it for batch answers.

  • The first 5 commits are an unpushed rework of fix(streaming): drive step saves and failures from what the AI SDK does #397, which this depends on.
  • Known gap: if an action dies after an approved tool ran but before its result was saved, the takeover reruns the tool.
  • Known gap: the batch example's replay depends on the claimed generation's context.
  • Open questions are in PRIMITIVES.md.

…he result resolves (#388, #428)

onStepEnd only holds the step. prepareStep saves it with the next pending
message in one mutation, and a transform after the user's saves the last one
before `finish` reaches the caller. A provider error is forwarded to onError
and ends the step as failed instead of aborting the stream.
…streams to it (#150, #168)

A pendingMessageId option claims the message before the model is called. A
second claim while one runs, or once the answer is saved, throws
AlreadyClaimedError; a failed or lapsed claim continues the answer in a new
pending message. Streams record the pending message they write to, step saves
move the link, a timeout fails only that message, and recovery reads only its
streams.
…, and batch saves retry without replaying (review)
…ool step, and an approval continuation don't break the claim (review)
…ration's last save, and recover a lapsed attempt in the takeover (review)
…ing it, and find a batch whose reference was lost (review)
…a lost batch isn't confused with a newer one (review)
@robelest
robelest requested a review from ianmacartney October 31, 2026 01:25
@pkg-pr-new

pkg-pr-new Bot commented Oct 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/agent@444

commit: 29462bf

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant