feat: stream provisional agent responses - #64
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
Author
|
Intent: Show reconnect-safe provisional answer text during agent finalization while preserving the existing validated answer as the only saved conversation result. |
devhims
force-pushed
the
feat/agent-response-streaming
branch
from
September 20, 2026 15:37
476921f to
d6e4ea0
Compare
devhims
force-pushed
the
feat/agent-response-streaming
branch
from
September 20, 2026 16:01
d6e4ea0 to
7ea9097
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Motivation
Agent runs already stream phase and tool snapshots, but the answer stays blank until final validation finishes. Users wait through the full finalization window without seeing the response being written.
Why it matters
Finalization can take much of the run. Showing provisional text makes the wait useful while keeping the saved answer subject to the existing grounding and citation checks.
What changed
The finalizer now reads AI SDK structured partial output and publishes visible text at most every 500 ms. It never exposes generated citation fields. The existing complete-answer validation still decides which answer is saved.
The Agent Durable Object stores the latest bounded draft. SSE snapshots restore that draft after reconnects. Completion, failure, cancellation, and account deletion clear it. A rejected attempt clears the old text and reports that the answer is being revised.
The dashboard labels provisional content as
Draft. It does not offer the copy action until the validated answer atomically replaces the draft.flowchart LR subgraph Before M1[finalizer model]:::ctx --> V1[validate full answer]:::ctx --> S1[terminal SSE snapshot]:::removed --> U1[user sees answer]:::ctx end subgraph After M2[finalizer model]:::ctx --> D2[persist bounded draft]:::added --> S2[live SSE snapshots]:::added --> U2[user sees draft]:::added M2 --> V2[validate full answer]:::changed --> F2[replace draft with saved answer]:::added end classDef added fill:#DCFCE7,stroke:#16A34A,color:#14532D,stroke-width:2px classDef changed fill:#FEF3C7,stroke:#D97706,color:#78350F,stroke-width:2px classDef removed fill:#FEE2E2,stroke:#DC2626,color:#7F1D1D,stroke-dasharray:4 3 classDef ctx fill:#E0F2FE,stroke:#0284C7,color:#0C4A6E linkStyle 0,1,2 stroke:#DC2626,stroke-dasharray:4 3 linkStyle 3,4,5,6,7 stroke:#16A34A,stroke-width:2px🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged
Users now see provisional answer text during finalization, while only validated output becomes conversation history.
Tests
Manual verification
The full Next build and browser execution are left to CI because the development host had 1.4 GB free memory. After Vercel creates the preview, complete an agent run and confirm the draft appears during finalization, then disappears when the cited answer arrives.
Screenshots / video
Pending the Vercel preview generated by this PR. The browser regression captures
streaming-draft.pngduring CI.Issue link
no linked issue: requested directly during development.