From 5b6cf0c9231e2cd96fe8ea252e652974d8f22b91 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 13 Nov 2026 03:34:29 -0800 Subject: [PATCH] fix(agent-session): keep a settled send's frame over an older work restatement Subscriber delivery reads current work before the history page, then lets that work restate unanswered sends over the page's rows. When a send's settlement committed between the two reads, the page carried it accepted but the earlier work restated it pending, so the frame at the new cursor published the stale state. Later caught-up frames restate only still unanswered sends, so the client never learned of the acceptance: the Claude echo case kept a "pending" bubble although the journal held it accepted. A restatement only describes sends its read saw unanswered, so an accepted or rejected page row is newer and now wins. structured-agent-session-claude-echo-working (failed once in CI, never reproduced) with an 8 ms SQL reply delay injected locally plus CPU load: before, most repeats stayed pending for 15 s while the stored row was accepted at the subscriber's own cursor; after, 7/7 passed in ~100 ms. --- .../observations/structured-agent-session-observed-work.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/native-chat/agent-session-wire/observations/structured-agent-session-observed-work.ts b/src/main/native-chat/agent-session-wire/observations/structured-agent-session-observed-work.ts index 3da485922fc..56b57859b31 100644 --- a/src/main/native-chat/agent-session-wire/observations/structured-agent-session-observed-work.ts +++ b/src/main/native-chat/agent-session-wire/observations/structured-agent-session-observed-work.ts @@ -7,6 +7,7 @@ import type { JournalObserverResult } from '../../agent-session-journal/journal- import type { JournalSqlWorkResult } from '../../agent-session-journal/journal-work-read' import type { SqlAgentSessionJournal } from '../../agent-session-journal/journal-sql-store' import { currentRequestsProjection } from './agent-session-current-requests' +import { journalDispatchRowApplies } from '../../agent-session-journal/projection/journal-dispatch-settlement' /** Finished observer answers; selection and live-work policy remain in the reader snapshot. */ export class StructuredAgentSessionObservedWork { @@ -38,8 +39,10 @@ export class StructuredAgentSessionObservedWork { actionablePromptIds = () => this.work.actionablePrompts.map((item) => item.itemId) hasActionablePrompt = () => this.work.actionablePrompts.length > 0 publishedLatestTurn = (_latest: AgentSessionLatestTurn | null) => this.work.latestTurn + // Restatements cover sends this read saw unanswered; a page row already settled is newer than it. publishedSubmission = (submission: AgentJournalSubmission) => - this.restated.get(submission.clientMessageId) ?? submission + (journalDispatchRowApplies(submission) && this.restated.get(submission.clientMessageId)) || + submission restatedSubmissions = () => this.work.restatedSubmissions viewKey = () => this.work.viewKey workViewKey = () => this.work.workViewKey