Skip to content

fix(component): abort in-flight generation when its message is deleted - #324

Open
robelest wants to merge 1 commit into
fix/stream-provider-errorsfrom
fix/delete-aborts-generation
Open

fix(component): abort in-flight generation when its message is deleted#324
robelest wants to merge 1 commit into
fix/stream-provider-errorsfrom
fix/delete-aborts-generation

Conversation

@robelest

@robelest robelest commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Refs #300.

deleteMessage deletes the row, its embedding, and its file refcounts. It doesn't touch a generation that's still writing to that order, so the run carries on against a message that no longer exists and blows up at finalize with Parent message ... not found.

Aborting the stream is enough to stop the run, and that path already works end to end:

abortStreamsAtOrder marks the stream aborted
  └─ next addDelta returns false
     └─ DeltaStreamer aborts
        └─ model stream aborts (streamText passes the streamer's signal as abortSignal)

Nothing was calling it on delete. So: pull abortStreamsAtOrder out of the abortByOrder mutation, have that mutation delegate to it, and call it from deleteByIds and deleteByOrder once per thread and order.

The issue suggested dropping the assert and saving the output at getMaxMessage order instead. order comes from promptMessage.order, and once the prompt is gone there's nothing sensible to anchor to — you'd be attaching stale output to whatever turn happened since. Stopping the run early means there's no output left to place.

generateText without streaming has no stream row, so it still asserts on finalize. Only the streaming path is covered here.

Deleting a message stranded any generation still writing to its order.
deleteMessage removed the row, its embedding and file refcounts, but left
the run going, so the failure only surfaced later as a missing-parent
assert when that generation finalized.

Every piece of teardown already existed and was simply never invoked:
aborting the stream makes the next addDelta return false, which aborts the
DeltaStreamer, whose signal is the model stream's abortSignal. Extract
abortStreamsAtOrder from the abortByOrder mutation and call it from
deleteByIds and deleteByOrder, deduped per thread and order.

Non-streaming generations have no stream row to abort and still assert on
finalize.

Refs #300.
@pkg-pr-new

pkg-pr-new Bot commented Aug 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 75d01bb

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