Repository navigation
fix(agent): restore an approval ask the socket drop swallowed (PM-1738) #18949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,421
−118
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
943b07b
fix(agent): restore an approval ask the socket drop swallowed (PM-1738)
7ea3070
fix(agent): keep a restored approval single and never resurrect an an…
christian-byrne 85be037
test(agent): anchor the restored-approval card on role and name
christian-byrne 2d49daa
fix(agent): read a restored approval only from an open row
christian-byrne 571bf46
fix(agent): keep uncertain approvals retired
christian-byrne c9ace51
fix(agent): harden approval recovery lifecycle
christian-byrne 2e6313a
test(e2e): preserve allowed route handlers
christian-byrne ded0382
fix(agent): close approval recovery edge cases
christian-byrne 8e0823e
fix(agent): persist approval recovery provenance
christian-byrne ef597de
fix(agent): reconcile approval recovery state
christian-byrne d927c94
fix(agent): trust authoritative approval recovery state
christian-byrne 815be7d
fix(agent): make approval reconciliation epoch-safe
christian-byrne 4433634
fix(agent): make recovery authority connection-aware
christian-byrne 3a432f1
fix(agent): close approval recovery races
christian-byrne afa9da3
fix(agent): confirm recovered approval absence
christian-byrne 13f352c
fix(agent): bound approval recovery uncertainty
christian-byrne 365e875
fix(agent): align approval recovery ledgers
christian-byrne d39c16a
fix(agent): settle recovered approvals authoritatively
christian-byrne 7959a7f
refactor(agent): scope recovery reruns to each job
christian-byrne a4f42bc
test(agent): bound each recovery job retry
christian-byrne 88ff318
refactor(agent): keep terminal recovery canonical
christian-byrne 78f8cb3
chore(agent): refresh approval evidence
christian-byrne 57921cd
chore(agent): refresh approval review evidence
christian-byrne 974c697
test(agent): avoid wall-clock deadline race
christian-byrne 6a653eb
refactor(agent): isolate recovery event bookkeeping
christian-byrne 86641ab
chore(agent): refresh greenlight evidence
christian-byrne 5dd2843
fix(agent): preserve retired asks across pending kinds
christian-byrne fade573
fix(agent): close recovery authority gaps
christian-byrne 94a913a
Merge remote-tracking branch 'origin/main' into pm1738-live
christian-byrne b7d66c6
Merge remote-tracking branch 'origin/main' into pm1738-live
christian-byrne 30365f2
fix(agent): close cross-ask recovery gaps
christian-byrne fb19817
fix(agent): harden restored approval resolution
christian-byrne a161f8f
fix(agent): preserve pending answer ownership
christian-byrne ad7dc4d
fix(agent): close approval recovery gaps
christian-byrne f0502c6
Merge remote-tracking branch 'origin/main' into glary/agent-approval-…
christian-byrne 73f47ec
Merge remote-tracking branch 'origin/main' into glary/agent-approval-…
christian-byrne 4b404db
fix(agent): report an unconfirmed winner after a mid-POST drop
christian-byrne 21b9f60
fix(agent): keep provisional tombstones through a stale settlement
christian-byrne 7a32fd6
fix(agent): cap the unconfirmed answer report ledgers
christian-byrne 5eb234a
test(agent): send approval frame on the Agent socket
christian-byrne a8aeeba
Merge main into agent approval recovery
christian-byrne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
136 changes: 136 additions & 0 deletions
136
browser_tests/tests/agent/agentApprovalSurvivesSocketDrop.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import { | ||
| APPROVAL_RUN_OPTION_ID, | ||
| RUN_APPROVAL_EVENT, | ||
| TURN_IN_PROGRESS_MESSAGE, | ||
| agentTurnLockTest as test | ||
| } from '@e2e/fixtures/agentTurnLockFixture' | ||
|
|
||
| // PM-1738, filed under PM-1199. Reported from the agent panel while building an | ||
| // img2img and then img2video workflow: "after generate workflow, agent stopped, | ||
| // I couldn't run but need to restart agent tab. Session was remained so that I | ||
| // could run again with existing session." | ||
| // | ||
| // The service side was never hung. Its logs show the turn accepted, then | ||
| // twenty-three minutes of silence, then two posts answered 409, then a GET of | ||
| // the transcript (the tab restart) and an `asks/.../answer` four seconds later | ||
| // — the user approving a tool call the moment a reload finally drew it. A turn | ||
| // parked on a run approval stays `streaming` for as long as the user takes to | ||
| // answer, so the socket drop that swallowed the `agent_ask` frame left the | ||
| // server waiting on a card the panel never drew: no way forward, and every | ||
| // follow-up message rejected by the single-active-turn guard. | ||
| // | ||
| // Distinct from agentTurnSurvivesSocketDrop.spec.ts, which drops the socket | ||
| // around a turn the server finishes on its own. Here the server cannot finish | ||
| // without an answer, so keeping the turn live is not enough — the ask itself | ||
| // has to come back. | ||
| test.describe.configure({ timeout: 120_000 }) | ||
| test.use({ connectWebSocketToServer: false }) | ||
|
|
||
| test.describe( | ||
| 'Agent approval ask across a transient websocket reconnect', | ||
| { tag: ['@cloud', '@ui'] }, | ||
| () => { | ||
| const PROMPT = 'build an img2img workflow and then turn it into img2video' | ||
|
|
||
| test.beforeEach(async ({ turnLock }) => { | ||
| await turnLock.openOnBlankWorkflow() | ||
| await turnLock.startTurn(PROMPT) | ||
| }) | ||
|
|
||
| test('surfaces an approval whose frame the drop swallowed, and resumes on it', async ({ | ||
| turnLock | ||
| }) => { | ||
| const nextPrompt = 'now raise the video length to 48 frames' | ||
|
|
||
| const reconnected = | ||
| await test.step('the turn parks on an approval whose frame never arrives', async () => { | ||
| turnLock.parkOnApproval() | ||
| await expect(turnLock.approvalCard).toHaveCount(0) | ||
| return turnLock.dropSocket() | ||
| }) | ||
|
|
||
| await test.step('the approval surfaces without a reload', async () => { | ||
| await expect(turnLock.approvalCard).toBeVisible({ timeout: 30_000 }) | ||
| await expect(turnLock.approvalWorkflowLink).toBeVisible() | ||
| await expect(turnLock.stopButton).toBeVisible() | ||
| }) | ||
|
|
||
| await test.step('answering it reaches the server', async () => { | ||
| await turnLock.runApprovalButton.click() | ||
|
|
||
| // The fake's answer route 404s any ask id but the parked one, so a | ||
| // recorded answer proves the panel answered the ask it restored -- | ||
| // and this reads the server, not the DOM, so it proves the answer | ||
| // actually left the client. | ||
| await expect | ||
| .poll(() => turnLock.answeredAsks()) | ||
| .toEqual([APPROVAL_RUN_OPTION_ID]) | ||
|
|
||
| turnLock.resolveApproval(reconnected) | ||
| await expect(turnLock.approvalCard).toHaveCount(0) | ||
| }) | ||
|
|
||
| await test.step('the thread is usable again', async () => { | ||
| turnLock.finishTurn(reconnected) | ||
| await expect(turnLock.sendButton).toBeVisible() | ||
|
|
||
| await turnLock.composer.fill(nextPrompt) | ||
| await turnLock.sendButton.click() | ||
|
|
||
| // The post has to have actually reached the server before the absence | ||
| // of a turn-in-progress notice means anything. | ||
| await expect | ||
| .poll(() => turnLock.postAttempts()) | ||
| .toBeGreaterThanOrEqual(2) | ||
| await expect(turnLock.userBubbles).toHaveCount(2) | ||
| await expect(turnLock.userBubbles.last()).toHaveText(nextPrompt) | ||
| await expect( | ||
| turnLock.panel | ||
| .getByRole('alert') | ||
| .filter({ hasText: TURN_IN_PROGRESS_MESSAGE }) | ||
| ).toHaveCount(0) | ||
| expect(turnLock.rejectedPosts()).toBe(0) | ||
| }) | ||
| }) | ||
|
|
||
| // Recovery re-reads the persisted row on every poll, so an ask the socket | ||
| // did deliver has to be recognised as already on screen rather than | ||
| // restored again. | ||
| test('does not redraw an approval the socket already delivered', async ({ | ||
| turnLock, | ||
| page | ||
| }) => { | ||
| turnLock.parkOnApproval() | ||
| turnLock.push(await turnLock.liveSocket(), RUN_APPROVAL_EVENT) | ||
| await expect(turnLock.approvalCard).toBeVisible() | ||
| let recoveryResponses = 0 | ||
| const secondRecoveryResponse = page.waitForResponse((response) => { | ||
| const request = response.request() | ||
| if ( | ||
| request.method() !== 'GET' || | ||
| !new URL(response.url()).pathname.endsWith('/messages') | ||
| ) | ||
| return false | ||
| return ++recoveryResponses === 2 | ||
| }) | ||
|
|
||
| await turnLock.dropSocket() | ||
|
|
||
| // toHaveCount returns as soon as it passes, so the count alone would | ||
| // assert nothing before recovery has even polled. Wait until the browser | ||
| // receives two recovery responses, then let the app apply the second | ||
| // one before holding the panel to one card. | ||
| await secondRecoveryResponse | ||
| await page.evaluate( | ||
| () => | ||
| new Promise<void>((resolve) => | ||
| requestAnimationFrame(() => requestAnimationFrame(() => resolve())) | ||
| ) | ||
| ) | ||
| await expect(turnLock.approvalCard).toHaveCount(1) | ||
| await expect(turnLock.runApprovalButton).toHaveCount(1) | ||
| }) | ||
| } | ||
| ) | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.