Repository navigation
Keep a Bot's answer when a conversation is reloaded a moment after it answered - #2614
Closed
davidmckayv wants to merge 1 commit into
Closed
davidmckayv wants to merge 1 commit into
davidmckayv wants to merge 1 commit into
Conversation
…it answered The opening join can run more than once: in development React runs it twice on mount (StrictMode), and a kept agent is ready at once, so both runs join the thread. The gate every read of the store waits on was one per mount, opened by whichever join ended first. The first join, given up for the second, ended at once, so the sidebar list's read merged the stored history onto the agent before the second join replayed anything. That replay rebuilt the agent from the thread's first run and was cut at its deadline before the run that held the answer, and the opening's own read had been taken over by the list's, so nothing read the store again: the answer showed for half a second, then was gone. Each join now has a gate of its own, and every read waits for the newest join to settle (joinSettled). reload-keeps-answer.test.tsx (under StrictMode, real provider and gateway protocol) and reload-keeps-answer-browser.test.tsx (Chromium and WebKit) fail before and pass after.
9 tasks done
Contributor
Author
|
Superseded by #2916, which re-lands #2567 (reverted in #2606) with this fix on top. #2567 was wanted; it was reverted only for this bug, and main without it doesn't have the bug (this PR's test passes on main). With #2567 back and without this fix, the reload test fails 12 of 12; with it, it passes 20 of 20, and the browser version passes in Chromium and WebKit. |
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.
What a person saw
A person allowed a Bot's change, the Bot answered (the order number), and the page was reloaded a moment later. The answer was on screen for half a second, then gone: the conversation showed the person's message and the approved step, nothing else, until it was opened again. Found by the backend's stock AG-UI approval journey (
stock-agui-langgraph-langchain), in about two runs of seven after #2567.Why
Read from the page's own log in that journey (instrumented, looped on four runners):
main.tsx), so in development React runs the effect twice on mount, and since Keep each conversation's agent, so going back replays only what is new #2567 the conversation's agent is kept and ready at once (useKeptAgent), so both runs joined the thread. Anything else that runs the join again (the agent changing, OpenBot answering again) does the same.joinedPromise) was one per mount, opened by whichever join ended first. The first join, given up for the second, ended at once and opened it.The fix
One gate per join. Each join the opening effect makes gets its own gate, and every read that waits for the join (
pull, the rejoin of a run started elsewhere, following a turn the server carries) waits for the newest one to settle (joinSettled). A read can no longer land before the join that is replaying the thread, so the store's copy goes on after the replay, as it was meant to.Tests
app/tests/reload-keeps-answer.test.tsx: the real provider,ChannelChat, its history reader and the AG-UI reducer, under StrictMode, through a stand-in for the gateway's realtime protocol, with a thread shaped like the journey's (a run stopped for approval, then the run after Allow once). Fails on main (the page ends on "Place seed order · Fernhill Seed Shop" with no answer, as in the journey), passes with the fix: red 3 of 3, green 5 of 5.app/tests/reload-keeps-answer-browser.test.tsx: the same, opened and reloaded in a real browser, Chromium and WebKit (added to CI's real-browser list). Fails on main in both, passes with the fix in both.channel-join-replay,kept-agents,kept-transcripts,approval-answered-*,approval-carry-on-running).The looped journey with the fix, and #2567 put back on top of its revert (#2606), follow before this leaves draft.