fix: keep failed turns in saved history from breaking the chat - #54
Open
asasemahmed wants to merge 2 commits into
Open
asasemahmed wants to merge 2 commits into
asasemahmed wants to merge 2 commits into
Conversation
Contributor
|
Needs a fix before merge. The |
Connecting to a Rich Threads conversation replays its saved events,
including RUN_ERROR from any earlier failed turn. CopilotKit reports
those through onError as agent_run_error_event, so one failed reply
made the conversation fail to load ("Could not load conversation")
on every visit and showed a stale error banner.
While history replays, ignore agent_run_error_event only. Connection
failures (agent_connect_failed) still block loading, and errors from
new turns still stop the run and the follow-up queue.
asasemahmed
force-pushed
the
fix/replayed-history-errors
branch
from
September 25, 2026 20:19
155706a to
aa53c02
Compare
Contributor
Author
asasemahmed
force-pushed
the
fix/replayed-history-errors
branch
from
September 26, 2026 22:01
aa53c02 to
45f00bc
Compare
Contributor
Author
|
Addressed the review: the replay flag is now a per-load counter, and the description states that a live-run failure after a reload is swallowed. CI is green now. |
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 changed
When one chat turn fails (for example, a provider rejects the API key), the main conversation stays broken afterwards:
Connecting to a Rich Threads conversation replays its saved events, including the
RUN_ERRORfrom the earlier failed turn. CopilotKit core reports replayed run errors throughonErrorwith codeagent_run_error_event.hydrate()treated any error duringconnectAgentas a failed load, and the chat-wideonErrorsubscriber showed it as a new error.Now:
runConversationTurnaccepts error codes to ignore.hydrate()and the chat error subscriber ignore onlyagent_run_error_event.agent_connect_failed) still block loading. Errors from new turns still stop the run and pause the follow-up queue, as before.Behavior change: if a live run fails while a reload is reconnecting to it, that error is now swallowed like a replayed one. No banner is shown; the failed turn stays in the transcript.
Verification
tests/conversation-sdk.test.tsuse the realCopilotKitCore:RUN_ERRORrejects without the ignore list, which reproduces the bug, and resolves with it.pnpm typecheckpasses.biome cipasses on the changed files.pnpm test: 200 passed, 0 failed, 1 skipped (POSIX-only).Integration limits
chat.tsx.