Skip to content

fix: clear recovered run errors during conversation replay - #106

Merged
jerelvelarde merged 3 commits into
CopilotKit:mainfrom
Twil3akine:fix/issue-63-stale-run-error
Oct 14, 2026
Merged

jerelvelarde merged 3 commits into
CopilotKit:mainfrom
Twil3akine:fix/issue-63-stale-run-error

Conversation

@Twil3akine

@Twil3akine Twil3akine commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #63.

Clear recovered agent-run errors during conversation history replay while preserving unrelated errors, including failed page saves.

Cause

A historical RUN_ERROR restores the error banner. A later successful run needs to clear that run error, but clearing the shared Chat error state also hides unrelated failures when a background run succeeds.

Fix

  • Keep run errors separate from other Chat errors.
  • Route run-related CopilotKit core errors and agent events into run-error state, including the SDK's duplicate error forwarding.
  • Clear only run-error state when RUN_FINISHED reports success.
  • Preserve save failures and non-run connection errors; retain explicit reset behavior when sending or reconnecting.

Historical events remain intact. New failures remain visible, and interrupted runs do not clear run errors.

Validation

  • Reproduced a rejected page-save request followed by a successful background finish through the installed SDK's defaultApplyEvents before the fix.
  • Regressions cover save errors coexisting with run errors, history replay, SDK error forwarding, connection failures and recovery from a failed current turn.
  • All 263 tests, format, lint, typecheck and build pass on the PR branch.
  • Local HTTP fixtures were tested with environment proxy routing disabled and non-loopback connections blocked.
  • Browser and live Intelligence verification were not performed. The build reports the existing large-chunk warning.

Prepared with AI assistance using gwitg, a GPT-6.1 Sol project lead and GPT-6 Luna workers.

@Twil3akine
Twil3akine marked this pull request as ready for review October 6, 2026 15:17

@jerelvelarde jerelvelarde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recovered-run replay fix has clear user value, but the clearing needs to target run errors rather than every error in Chat. All 11 focused replay/composer/page-request tests pass, and the real installed SDK outcome contract and subscription cleanup were checked. A separate regression fixture reproduces the unrelated-save error disappearing and passes when these added lines are removed.

Comment thread src/client/Chat.tsx Outdated
const events = agent.subscribe({
onRunErrorEvent: ({ event }) => setError(event.message),
onRunFinishedEvent: ({ outcome }) => {
if (outcome === 'success') setError('');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Only clear errors that belong to the recovered run. This clears shared error state for every successful finish, so a failed “Save conversation as page” alert disappears when a scheduled run in the same conversation finishes, even though saving still failed. A fixture rejecting the save API and delivering RUN_FINISHED through the installed SDK’s defaultApplyEvents reproduces the disappearance. Track run errors separately or scope clearing to the recovered run, and add that failed-save/background-finish regression.

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I'll update the recovery handling so that a successful run clears run errors while preserving unrelated errors, including failed page saves. I'll also add the failed-save/background-finish regression you described.

Copy link
Copy Markdown
Contributor Author

The updated commit separates run errors from unrelated errors, with regression coverage for a failed page save followed by a successful background run. I appreciate your careful review, and I'm sorry to ask for another pass. Would you mind reviewing the changes when convenient?

@jerelvelarde jerelvelarde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous failed-page-save alert blocker is fixed: run errors now have separate state, successful RUN_FINISHED clears only run errors, and unrelated save/connection errors remain visible. Running the current mounted regressions against prior reviewed f695864 reproduces three failures (both failed-save cases and unrelated connection error); all nine pass on the updated head. Actual installed SDK event application/error forwarding covers historical replay, latest/new failures, interruption, transport failure and failed-current-turn recovery.

Value/template/security: useful bounded reliability correction, accurate description, no new dependency/configuration or actionable security issue. Current main0fc09e was integrated without conflicts. The only additional correction adds appsAllowed:false and composioToolkits:[] to the new test Dot fixture to match the fields introduced by external Composio PR150; both main and contributor behavior are retained.

Verification on updated head9684e54 (Node24 clean-environment sandbox, external network and user credentials inaccessible): formatter, lint, typecheck, all327 tests and production build pass. Before integration the original head passed all five gates and263 tests. Mounted React tests use mocked UI hooks plus actual installed SDK; no browser pixel or live Intelligence check was performed. Merge remains gated on successful exact-head GitHub CI after this integration commit is pushed and final current-main compatibility.

@jerelvelarde
jerelvelarde merged commit 8efba9f into CopilotKit:main Oct 14, 2026
1 check passed
@Twil3akine
Twil3akine deleted the fix/issue-63-stale-run-error branch October 15, 2026 01:26
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.

Errors from past runs are shown again on every reconnect

2 participants