mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
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.
This commit is contained in:
+4
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user