Skip to content

fix(session): narrow recovery to stalled requests after sleep - #4477

Closed
reachjalil wants to merge 3 commits into
devfrom
fix/narrow-sleep-recovery
Closed

reachjalil wants to merge 3 commits into
devfrom
fix/narrow-sleep-recovery

Conversation

@reachjalil

@reachjalil reachjalil commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Disposition: Incomplete, retained open

Reviewed head d988f73f04caecd77759c8c081c04565e46d4a32 against dev@858414c41c63a22eecfe331d17f3f5dd348dfc6f. The branch is unchanged and not synchronized or safe to merge. Its merge base is 2a3b4296fd9566e07410ab1eeaff9e0da51ec205 (#4470), not current dev.

Do not restore the provider transport hook merely to resolve conflicts. Do not close this as redundant: current code does not establish equivalent recovery of a still-running request after sleep.

Code comparison

  • Emergency revert: session connection recovery (#4470) #4484 (6d179f00acf322b1d46f4e30793615b0bb158296) reverted fix(session): restore connection recovery without breaking provider auth #4470, deleting the provider guard, registration, packaging entries, recovery fixture and suspend journey. The offline-UI and background-retention removals in this PR are already present through that revert; they are no longer a useful increment.
  • The remaining implementation in this PR installs guardProviderFetch(fetch, resumeMonitor) through provider.options.fetch for openwork and lpr_*. Restoring those deleted files and their registration is a reintroduction of the reverted mechanism, not a mechanical narrowing of current dev. The managed-ID/custom-fetch guards avoid the original broad OAuth-provider overwrite, but do not prove all managed auth-loader transports safe. Emergency revert: session connection recovery (#4470) #4484 itself explicitly left the reported connection failure's cause unproven.
  • Fix interrupted managed responses and safe recovery #4471 (54a7f0fa978de95806b78cec1d35ec89b7a2ba2c) now bounds managed gateway headers/body and SSE idle reads, preserves partial work, and cancels upstream. See ee/apps/inference/src/proxy.ts, chat-response.ts, and docs/managed-response-reliability.md. Those server-side deadlines do not detect a silent desktop-to-gateway socket following laptop sleep; they never replay generation.
  • feat(desktop): resume interrupted tasks gradually after restart #4636 (0857e81d897b97bc7b10b35c0b2193ec3328dab3) recovers verified unfinished tasks after server restart. apps/server/src/task-recovery.ts loads the startup set from persisted running records, observes already-active runs without re-prompting, and requires startup eligibility before issuing recovery. An engine still reporting busy after sleep does not enter that restart-only path.
  • Current apps/app/src/components/chat/message-list.tsx revalidates stalled activity without aborting or resubmitting it. This is honest feedback, not replacement socket recovery.

The residual useful outcome is bounded recovery of a managed request that is demonstrably stuck after resume, without changing auth transport or duplicating work. The current comparison proves neither that this gap is solved nor that the old hook is safe to restore. That blocks both a redundancy closure and a safe code sync in this update.

Review finding

The unresolved canceled-task witness is valid: the old suspend journey observes cancellation before the full 30-second post-resume grace expires. A replacement journey must keep the stopped task under observation beyond the complete grace window, then assert no additional provider request or tool execution. No review thread was marked resolved.

Verification

The old local result at 86f39c0ea641d1ab7317e8850082da8a338fa656 is historical, not proof for current dev or the current PR head. No merge, deployment, review request or branch deletion is included.

@vercel

vercel Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Skipped Skipped Sep 5, 2026 7:54pm UTC
openwork-den Skipped Skipped Sep 5, 2026 7:54pm UTC
openwork-diagnostics Skipped Skipped Sep 5, 2026 7:54pm UTC
openwork-landing Skipped Skipped Sep 5, 2026 7:54pm UTC

@reachjalil

reachjalil commented Sep 5, 2026 •

Copy link
Copy Markdown
Member Author

Verified PR commit: 86f39c0ea641d1ab7317e8850082da8a338fa656. pnpm evals:e2e thread-resumes-after-suspend --local — placement: local; 2 passed, 0 failed, 0 skipped. The records below contain runtime assertions; screenshots are supplementary.

Test evidence — an-in-flight-task-recovers-after-sleep-without-restarting-a-canceled-task — ✅ passed

✅ 0/1 screenshots passed · 0 expectations passed · 0 failed · 0 pending

screenshots not attached (gh < 2.99; run brew upgrade gh)

[world] mock(mcp) · desktop(local) · workspace(/tmp/openwork-suspended-turn-1788571336056) · [seed:raw] evalIn() ×6
[probe] eventually(other task is streaming and has gone quiet)
[user] see(text=/Working/) · notSee(text=The task finished after the computer resumed.)
[probe] eventually(engine re-asks the model after resuming and finishes the turn)
[user] see(text=The task finished after the computer resumed., timeoutMs=60000)
[probe] eventually(the completed turn clears its working indicator)
[user] notSee(text=/Working/) · screenshot · notSee(text=/connection lost/i) · click(text=Stopped turn) · see(Run task) · notSee(text=The second task finished.)
steps 1 ✅ the engine sleeps and wakes (40.0s)
verdict passed · 8 user observations (see ×3, notSee ×4, screenshot ×1) · 3 probes · steps 1/1

⚪ UNVALIDATED — 1. an-in-flight-task-recovers-after-sleep-without-restarting-a-canceled-task artifact 1

  • ⚪ UNVALIDATED — no visual expectations recorded.

Test run created 2026-09-05T01:22:15.508Z · Source: evals/results/test-runs/2026-09-05T01-22-15-508Z-an-in-flight-task-recovers-after-sleep-without-restarting-a-canceled-task/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4477 --test-run 2026-09-05T01-22-15-508Z-an-in-flight-task-recovers-after-sleep-without-restarting-a-canceled-task


Test evidence — an-authenticated-model-can-call-connect-with-recovery-enabled — ✅ passed

✅ 0/1 screenshots passed · 0 expectations passed · 0 failed · 0 pending

screenshots not attached (gh < 2.99; run brew upgrade gh)

[world] mock(mcp) · desktop(local) · workspace(/tmp/openwork-suspended-turn-1788571460561) · [seed:raw] evalIn() ×6 · mock(mcp) · desktop(local) · workspace(/tmp/openwork-authenticated-connect-1788571500172) · [seed:raw] evalIn() ×5
[user] type(composer, "Find my connected apps using Connect.") · click(Run task)
[probe] eventually(authenticated model invokes Connect and finishes)
[user] see(text=Connect is working with my signed-in model., timeoutMs=30000) · notSee(text=/authentication handler was bypassed|401/) · screenshot
verdict passed · 3 user observations (see ×1, notSee ×1, screenshot ×1) · 1 probes · steps 0/0

⚪ UNVALIDATED — 1. an-authenticated-model-can-call-connect-with-recovery-enabled artifact 1

  • ⚪ UNVALIDATED — no visual expectations recorded.

Test run created 2026-09-05T01:24:20.011Z · Source: evals/results/test-runs/2026-09-05T01-24-20-011Z-an-authenticated-model-can-call-connect-with-recovery-enabled/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4477 --test-run 2026-09-05T01-24-20-011Z-an-authenticated-model-can-call-connect-with-recovery-enabled

Comment on lines +58 to +62
expect(await world.completionKinds(stoppedTurnPrompt)).toEqual(["quiet"]);
await user.click({ text: "Stopped turn", exact: true });
await user.see("Run task");
await user.notSee({ text: stoppedTurnReply }, { timeoutMs: 1_000 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Canceled-task assertion ends before the recovery grace period

The new canceled-task witness can still pass if the aborted request is retried 30 seconds after resume, because the spec checks completion kinds immediately and observes the UI for only one second.

Evidence
  • guardProviderFetch schedules a retry failure 30,000 ms after the resume monitor fires when a request remains silent.
  • The spec asserts completionKinds(stoppedTurnPrompt) immediately after the other task finishes, then waits only 1,000 ms with user.notSee.
  • A canceled request whose abort cleanup is broken could therefore be reissued after that assertion and still satisfy the claimed “without restarting a canceled task” behavior.
  • Keep the canceled-task witness under observation through the full post-resume grace period before asserting that its completion list remains ['quiet'].

Identified by Warden · spec-provenance-review · 5AL-GUZ

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (86f39c0ea641d1ab7317e8850082da8a338fa656). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: d988f73
Status: ✅  Deploy successful!
Preview URL: https://1c91af8e.openwork.pages.dev
Branch Preview URL: https://fix-narrow-sleep-recovery.openwork.pages.dev

View logs

@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 5, 2026 19:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 5, 2026 19:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-app September 5, 2026 19:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 5, 2026 19:54 Inactive
@reachjalil

Copy link
Copy Markdown
Member Author

Closing: this branch was a narrowing follow-up to #4470, which #4484 reverted in full. The offline-UI cleanup here is already on dev through that revert, and the remaining change would reintroduce the reverted provider fetch hook rather than build on current dev. Recovery for a request that stalls after laptop sleep is still needed and will be addressed in a fresh change against current dev that leaves provider auth transport untouched.

This branch was previously deployed

4 inactive deployments
Preview – openwork-app — d988f73f Deployed Sep 5, 2026 by vercel[bot]
Preview – openwork-den — d988f73f Deployed Sep 5, 2026 by vercel[bot]
Preview – openwork-diagnostics — d988f73f Deployed Sep 5, 2026 by vercel[bot]
Preview – openwork-landing — d988f73f Deployed Sep 5, 2026 by vercel[bot]
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