Skip to content
Merged
Show file tree
Hide file tree
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)
Sep 26, 2026
7ea3070
fix(agent): keep a restored approval single and never resurrect an an…
christian-byrne Oct 1, 2026
85be037
test(agent): anchor the restored-approval card on role and name
christian-byrne Oct 1, 2026
2d49daa
fix(agent): read a restored approval only from an open row
christian-byrne Oct 2, 2026
571bf46
fix(agent): keep uncertain approvals retired
christian-byrne Oct 6, 2026
c9ace51
fix(agent): harden approval recovery lifecycle
christian-byrne Oct 6, 2026
2e6313a
test(e2e): preserve allowed route handlers
christian-byrne Oct 6, 2026
ded0382
fix(agent): close approval recovery edge cases
christian-byrne Oct 6, 2026
8e0823e
fix(agent): persist approval recovery provenance
christian-byrne Oct 6, 2026
ef597de
fix(agent): reconcile approval recovery state
christian-byrne Oct 6, 2026
d927c94
fix(agent): trust authoritative approval recovery state
christian-byrne Oct 7, 2026
815be7d
fix(agent): make approval reconciliation epoch-safe
christian-byrne Oct 7, 2026
4433634
fix(agent): make recovery authority connection-aware
christian-byrne Oct 7, 2026
3a432f1
fix(agent): close approval recovery races
christian-byrne Oct 7, 2026
afa9da3
fix(agent): confirm recovered approval absence
christian-byrne Oct 7, 2026
13f352c
fix(agent): bound approval recovery uncertainty
christian-byrne Oct 7, 2026
365e875
fix(agent): align approval recovery ledgers
christian-byrne Oct 7, 2026
d39c16a
fix(agent): settle recovered approvals authoritatively
christian-byrne Oct 8, 2026
7959a7f
refactor(agent): scope recovery reruns to each job
christian-byrne Oct 8, 2026
a4f42bc
test(agent): bound each recovery job retry
christian-byrne Oct 8, 2026
88ff318
refactor(agent): keep terminal recovery canonical
christian-byrne Oct 8, 2026
78f8cb3
chore(agent): refresh approval evidence
christian-byrne Oct 8, 2026
57921cd
chore(agent): refresh approval review evidence
christian-byrne Oct 9, 2026
974c697
test(agent): avoid wall-clock deadline race
christian-byrne Oct 10, 2026
6a653eb
refactor(agent): isolate recovery event bookkeeping
christian-byrne Oct 10, 2026
86641ab
chore(agent): refresh greenlight evidence
christian-byrne Oct 10, 2026
5dd2843
fix(agent): preserve retired asks across pending kinds
christian-byrne Oct 13, 2026
fade573
fix(agent): close recovery authority gaps
christian-byrne Oct 14, 2026
94a913a
Merge remote-tracking branch 'origin/main' into pm1738-live
christian-byrne Oct 16, 2026
b7d66c6
Merge remote-tracking branch 'origin/main' into pm1738-live
christian-byrne Oct 17, 2026
30365f2
fix(agent): close cross-ask recovery gaps
christian-byrne Oct 17, 2026
fb19817
fix(agent): harden restored approval resolution
christian-byrne Oct 17, 2026
a161f8f
fix(agent): preserve pending answer ownership
christian-byrne Oct 17, 2026
ad7dc4d
fix(agent): close approval recovery gaps
christian-byrne Oct 17, 2026
f0502c6
Merge remote-tracking branch 'origin/main' into glary/agent-approval-…
christian-byrne Oct 17, 2026
73f47ec
Merge remote-tracking branch 'origin/main' into glary/agent-approval-…
christian-byrne Oct 25, 2026
4b404db
fix(agent): report an unconfirmed winner after a mid-POST drop
christian-byrne Oct 26, 2026
21b9f60
fix(agent): keep provisional tombstones through a stale settlement
christian-byrne Oct 26, 2026
7a32fd6
fix(agent): cap the unconfirmed answer report ledgers
christian-byrne Oct 26, 2026
5eb234a
test(agent): send approval frame on the Agent socket
christian-byrne Oct 26, 2026
a8aeeba
Merge main into agent approval recovery
christian-byrne Oct 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions browser_tests/fixtures/agentTurnLockFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,24 @@ const FOREIGN_TURN_DONE_EVENT: AgentWsEvent = {

const RUN_APPROVAL_ASK_ID = `${TURN_ID}:call-run-workflow`

/**
* The workflow this ask names. Not exported: it is the same workflow the
* panel's picker and tab already name, so a spec that matched it as text
* would resolve to three elements. `approvalWorkflowLink` below is the
* locator a spec should assert on instead.
*/
const APPROVAL_WORKFLOW_NAME = 'Unsaved Workflow'

/**
* The option ids this ask offers. Declared separately because `AgentWsEvent`
* types `data` loosely, so reading them back off the event would be an
* `unknown` the route would have to cast.
*/
const RUN_APPROVAL_OPTION_IDS = ['run', 'cancel'] as const

/** The option id the panel's Run button answers with. */
export const APPROVAL_RUN_OPTION_ID = RUN_APPROVAL_OPTION_IDS[0]

/**
* The frame the server sends when a turn parks waiting for the user to approve
* a run. Shaped after `pendingRunApproval`'s reader and cloud's `asks` writer:
Expand All @@ -132,8 +143,11 @@ export const RUN_APPROVAL_EVENT: AgentWsEvent = {
thread_id: THREAD_ID,
ask_id: RUN_APPROVAL_ASK_ID,
kind: 'run_approval',
prompt: 'Run workflow “Unsaved Workflow”?',
context: { workflow_id: WORKFLOW_ID, workflow_name: 'Unsaved Workflow' },
prompt: `Run workflow “${APPROVAL_WORKFLOW_NAME}”?`,
context: {
workflow_id: WORKFLOW_ID,
workflow_name: APPROVAL_WORKFLOW_NAME
},
options: [
{
id: RUN_APPROVAL_OPTION_IDS[0],
Expand Down Expand Up @@ -521,6 +535,8 @@ export class AgentTurnLockHarness {
public readonly sendButton: Locator
public readonly stopButton: Locator
public readonly runApprovalButton: Locator
public readonly approvalCard: Locator
public readonly approvalWorkflowLink: Locator
public readonly workSummary: Locator
public readonly workingRow: Locator
public readonly liveProgressRow: Locator
Expand Down Expand Up @@ -553,6 +569,14 @@ export class AgentTurnLockHarness {
name: enMessages.agent.runApproval.run,
exact: true
})
this.approvalCard = this.panel.getByText(
enMessages.agent.runApproval.question,
{ exact: true }
)
this.approvalWorkflowLink = this.panel.getByRole('button', {
name: APPROVAL_WORKFLOW_NAME,
exact: true
})
this.workSummary = this.panel.getByRole('button', {
name: new RegExp(
`^(${[
Expand Down Expand Up @@ -676,6 +700,21 @@ export class AgentTurnLockHarness {
this.server.recordAsk(event)
}

/**
* Parks the live turn on a run-approval ask the way the service does while
* it waits for the user: the assistant row stays `streaming` (so posts keep
* returning 409) and starts carrying `pending_ask`. No frame is pushed --
* that models the `agent_ask` a dropped socket never delivered.
*/
parkOnApproval(): void {
this.primePendingAsk(RUN_APPROVAL_EVENT)
}

/** The frame the server pushes once it accepts an answer to the approval. */
resolveApproval(ws: WebSocketRoute): void {
this.push(ws, RUN_APPROVAL_RESOLVED_EVENT)
}

/** True only when a test explicitly primed transcript-based recovery. */
pendingAskIsPrimed(): boolean {
return this.server.askIsPending
Expand Down
2 changes: 1 addition & 1 deletion browser_tests/fixtures/networkIsolationFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const networkIsolationFixture = base.extend<{
await context.route('**/*', async (route) => {
const url = new URL(route.request().url())
if (origins.has(url.origin)) {
await route.continue()
await route.fallback()
return
}
unexpected.add(getBlockedRequestViolation(url, route.request().method()))
Expand Down
136 changes: 136 additions & 0 deletions browser_tests/tests/agent/agentApprovalSurvivesSocketDrop.spec.ts
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)
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
await expect(turnLock.runApprovalButton).toHaveCount(1)
})
}
)
1 change: 1 addition & 0 deletions src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5991,6 +5991,7 @@
"run": "Run",
"answerFailed": "Could not send your answer. Reload the page and try again.",
"answerUncertain": "Could not confirm your answer reached the agent. It may still have been applied — reload the page to see where things stand.",
"answerAcceptedUnconfirmed": "Your answer reached the agent, but we could not confirm whether it was the answer applied. Reload the page to see where things stand.",
"answerSuperseded": "This was already answered somewhere else, so that answer was used instead of yours."
},
"askUnavailable": "The agent is waiting on a step this panel can't show.",
Expand Down
Loading
Loading