Skip to content

fix(chat): follow suspended replies after a prompt is answered - #6217

Open
wang-leigang wants to merge 2 commits into
Tencent:mainfrom
wang-leigang:fix/chat-follow-resumed-prompt
Open

wang-leigang wants to merge 2 commits into
Tencent:mainfrom
wang-leigang:fix/chat-follow-resumed-prompt

Conversation

@wang-leigang

@wang-leigang wang-leigang commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Answering a suspended agent prompt can return resumed: true while the original chat stream is still open. Platform chat and the visitor widget could discard that acknowledgement and stay on the answered card. The widget also had no signed continuation endpoint to deliver the next question while the agent was still waiting for an answer.

Both views now finish reading the original stream and attach to the same assistant message with the answered prompt’s resume_pending_id. The widget sends its channel token and signed session handle to the new embed route, which applies the existing visitor session checks before delegating to the continuation handler. A hot answer (resumed: false) keeps its current stream.

A disconnected or stalled stream can recover from the saved assistant row. If SSE remains unavailable, the widget can display a new actionable question and keep following a long-running reply through signed history. A final reply delivered through either path notifies the host page and webhook once per displayed turn. When a failed buffer reset leaves multiple segments together, a scoped replay starts at the matching segment and keeps the original store cursor for new events.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

Related Issue

Reproduced on a33076802 while testing the suspended ask_user flow.

Testing

In a real Chrome iframe, submit Shanghai while the original SSE is still open. After the answer POST acknowledges the resume, finish the old SSE, then have the resumed agent ask for a SKU before suspending again.

Scenario Verified behavior
Original platform chat and original visitor widget The early acknowledgement was lost. The answered card stayed on screen.
Updated visitor widget One signed continuation GET delivered the SKU question. Answering immediately kept the same connection. Part of the stock answer appeared before the remaining text arrived. No recovery history read was needed.
Visitor replay buffer unavailable A signed history read restored the saved final reply. The host window received one message_received and the browser submitted one webhook relay in both browser scenarios.
Signed HTTP route A real Go HTTP server using an in-memory event store flushed a second question before completion, rejected a missing or mismatched signature, and scoped replay to the correct session, message and prompt.

Chrome used the actual Vue pages and a controlled HTTP fixture to exercise the response order. The Go route tests exercised the backend independently.

  • Ran every frontend test file with Chrome enabled for the optional browser test. All 3,174 tests passed, with zero skips.
  • npm run type-check and the Vite production build passed.
  • make test passed with the project’s uv-managed Python 3.13 on PATH. The signed-route and resumed-segment tests also passed under go test -race. Diff-scoped golangci-lint reported zero issues.

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

Before. The user has answered, and the conversation stays on the card.

Before the fix, the answer is accepted but the agent reply is missing

After. The same interaction displays the warehouse stock count.

After the fix, the agent reports 120 units in stock

Visitor widget. The resumed stream displays the next question while it can still be answered live.

The visitor can answer the SKU question on the resumed stream

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