Skip to content

fix(voice-call): store realtime caller turns in dialogue order - #159143

Closed
mnowrot wants to merge 15 commits into
openclaw:mainfrom
mnowrot:fix/voice-call-transcript-turn-order
Closed

mnowrot wants to merge 15 commits into
openclaw:mainfrom
mnowrot:fix/voice-call-transcript-turn-order

Conversation

@mnowrot

@mnowrot mnowrot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #159138

What Problem This Solves

A realtime voice call's stored transcript read as all of the agent's lines followed by one glued blob of everything the caller said, instead of an alternating conversation.

User Impact

Post-call transcripts can be read and attributed turn by turn: the caller's words appear in the right place in the dialogue rather than being dumped at the end.

Why This Change Was Made

Under the Google realtime provider the caller side arrives only as partials, so the plugin persisted nothing for the caller until the provider's single end-of-call flush.

The handler now commits the pending caller partial as its own call.speech entry immediately before the first assistant entry of each turn, and the end-of-call flush is reduced to the suffix the committed-caller ledger does not already cover.

Getting that order right required changing how the writes are issued. Every transcript write used to be chained onto one transcriptPersistence promise, so a write was only issued after the previous one settled. Writes are now issued immediately and ordered by the manager's keyed mutation queue, and every issued write is accumulated into the tracked promise so shutdown waits for all of them instead of only the most recent.

Consequences of that change, each covered by a test:

  • The caller turn and its paired assistant reply are two independent writes, so a rejected caller write no longer skips the reply.
  • The committed-caller ledger holds one entry per issued turn, kept verbatim so a repeated phrase ("yes", "yes") is not collapsed, and released only if that turn's write fails - which leaves the text for the end-of-call flush instead of losing the turn.
  • The end-of-call flush queues behind any turn write still in flight, so it reduces the transcript against a settled ledger. With nothing in flight it is issued in the same tick, because callers observe the flush write before the next provider turn.

Evidence

28 stored realtime calls showed the bot-block/caller-blob shape (e.g. 9181a17b 21 assistant entries then one user entry; bd9c0eed 15 then one). After the change, entries interleave per turn.

New extensions/voice-call/src/webhook/realtime-handler.transcript-store.test.ts asserts on the persisted transcript rather than the manager mock, covering:

  • stores each caller turn ahead of the reply it answered - a normal multi-turn call.
  • finishes a queued caller turn write before shutdown completes - provider close with a queued turn write.
  • stores the reply paired with a failed caller turn and recovers that turn at flush - a caller-write failure together with its assistant reply.

It opens a real state database, like the already-registered extensions/voice-call/src/manager/store.test.ts, so it is listed in the extension database-worker fork lane.

Commands and results (all from a clean worktree at this head):

  • node scripts/run-vitest.mjs extensions/voice-call/src/webhook/realtime-handler.test.ts extensions/voice-call/src/webhook/realtime-handler.lifecycle.test.ts extensions/voice-call/src/webhook/realtime-handler.persistence.test.ts extensions/voice-call/src/webhook/realtime-handler.transcript-store.test.ts
    -> 111 passed + 3 passed, 0 failed.

  • pnpm test:extensions:batch voice-call -> 76 files, 147 passed (extension-database-workers) and 684 passed / 9 failed (extension-voice-call). All 9 failures are in extensions/voice-call/index.test.ts and extensions/voice-call/index.lifecycle.test.ts, which this PR does not touch; see "Unrelated failures" below.

  • node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/voice-call/src/webhook -> exit 0.
    Measured cost of the new file (pnpm test <file> --maxWorkers=1): 17.3 s wall, 14.7 s Vitest duration, of which 13% (~1.9 s) is test time; the rest is cold transform/import. Peak RSS 538 MB. Under the 5 s test-time target in writing tests. No real timers, sleeps, or polling - it drives the handler through deferreds - and each case gets its own state directory from createManagerHarness. CI seconds to follow once the run exists.

  • node scripts/run-vitest.mjs test/vitest-projects-config.test.ts test/vitest-scoped-config.test.ts test/scripts/extension-test-plan.test.ts -> 3 files / 567 passed (covers the database-worker path registration). A wider run including test/scripts/test-projects.test.ts, test/scripts/test-extension.test.ts and test/scripts/ci-changed-node-test-plan.test.ts also passed 6 files / 2693 passed.

Correcting the previous evidence in this PR

An earlier revision of this description claimed that assigns unique event IDs to finalized chunks received in the same millisecond and waits for shutdown transcript durability (failure=false|true) "also fail on unmodified upstream main". That was wrong. Those tests pass on main; they were regressions introduced by this branch's deferred persistence chain, which delayed call.assistant-speech past the tick those tests observe. They pass now.

check-test-types

The full-graph extension test type check (pnpm tsgo:extensions:test) cannot run on the machine used here - it OOM-kills at ~6 GB RSS on 7.7 GB of RAM without producing a tsbuildinfo - so the lane itself is left to CI. Instead the same compiler was run over a scoped project containing only extensions/voice-call/**/*.test.ts plus the repository's .d.ts inputs, through node scripts/run-tsgo.mjs -p <scoped tsconfig>: exit 0 in ~35 s at ~3.9 GB peak RSS.

That scoped check reproduces the lane failure. The red check-test-types lane was caused by this branch, not by upstream. The previous head added

processEvent.mock.calls
  .filter(([event]) => event.type === "call.assistant-speech")
  .map(([event]) => event.transcript);

Destructuring inside the predicate gives no type-guard narrowing, and transcript exists on only two of NormalizedEvent's union members, so .transcript is a TS2339. Both occurrences are rewritten as map-then-filter, which narrows. No suppression was added.

Verified in both directions on the scoped project: restoring the previous head's version of that one file reproduces the lane failure exactly -

extensions/voice-call/src/webhook/realtime-handler.persistence.test.ts(274,35): error TS2339: Property 'transcript' does not exist on type 'NormalizedEvent'.
extensions/voice-call/src/webhook/realtime-handler.persistence.test.ts(312,35): error TS2339: Property 'transcript' does not exist on type 'NormalizedEvent'.
  • and the fixed version compiles clean.

Unrelated failures

extensions/voice-call/index.test.ts (3 tests) and extensions/voice-call/index.lifecycle.test.ts (6 tests) fail in the extension-voice-call project. They are about plugin registration and runtime-generation lifecycle, not transcripts, and this PR does not modify them or index.ts.

Attribution check: reverting extensions/voice-call/src/webhook/realtime-handler.ts - the only production file this PR changes - to its merge-base content and re-running those two files reproduces the same failures. The symptoms (expected "vi.fn()" to be called 1 times, but got 0 times for the mocked createVoiceCallRuntime, and expected '' to contain 'Runtime not started: setup incomplete') point at the plugin registration fixture, and the reproduction host was a source-only worktree with no built artifacts. Left to CI; not addressed here.

🤖 Generated with Claude Code

Round 2 — ClawSweeper Revision 4 findings resolved (a54c0c2c)

[P2] Retain the caller ledger until the final flush has drained. The committed-caller
ledger was handler state keyed by call ID, and the provider close callback deleted it. Google
Live flushes its accumulated caller transcript and only then notifies close, so with a caller
turn write still in flight the deferred flush read an already-deleted ledger and re-stored the
whole caller transcript. The ledger now belongs to the bridge that wrote those turns, so it
outlives the close callback and a replacement connection starts its own; no call-keyed state
and no close-time cleanup remain.

[P2] Preserve repeated per-utterance final transcripts. Reduction let any committed text
consume an incoming final (compactCommitted.includes(compact)), so a provider that finalizes
each utterance lost a repeated later utterance — a final "yes" counted as old speech because an
earlier turn already contained the word. A final now claims only the turns it restates from the
start, which is the cumulative-flush contract, and each claimed turn is released, so repeated
finals are stored once and a caller who repeats a phrase keeps both turns.

Verification

Check Result
node scripts/run-vitest.mjs extensions/voice-call/src/webhook/ 12 files / 180 tests passed
Scoped test typecheck (tsgo -p .artifacts/tsconfig.voice-call-test.json) exit 0
oxlint + oxfmt --check on the changed files exit 0
Negative control: the 3 new tests on 4c6ed3e3 3 failed — duplicated flush ("yes goodbye"), dropped repeat (missing "yes"), duplicated repeat (extra "yes")

New tests cost: the whole realtime-handler.transcript-store.test.ts file is 6 tests in
23.7 s wall / 20.5 s duration, 534 MB peak RSS at --maxWorkers=1 (3 tests were 17.3 s /
538 MB), so the 3 added cases reuse an existing fixture rather than paying a new setup.


Superseding note. The section that stood here previously was the round-2 harness: synthetic
LiveServerMessage frames with a mocked @google/genai transport. ClawSweeper correctly declined
to accept it as proof for that reason. It is replaced by the real-transport proof below.

Real Google Live proof (after fix, real transport)

A real multi-turn Google Live call ran through the PR's handler (realtime-handler.ts blob 13e2b1b4, head
7832d952), the real Google realtime provider, and the real SQLite call store. I read the stored transcript
back after close.

The transport was not mocked. No vi.mock, no network stubbing, and no synthetic LiveServerMessage
frames were used. The provider's real createGoogleGenAI() → @google/genai Live.connect() opened a TLS
websocket to generativelanguage.googleapis.com. The round-2 mock of google-genai-runtime.js is removed.
The caller audio is real speech: Google TTS (gemini-3.1-flash-tts-preview, 24 kHz PCM) → ffmpeg →
G.711 μ-law 8 kHz. It was streamed as Twilio media frames (160 B every 20 ms, in real time) into the
handler's carrier websocket, and Google's own ASR produced the caller transcripts.

The close window. On caller turn 3, I called bridge.close() on the Google bridge in the same synchronous
tick as the assistant's final reply transcript. At that moment the turn-3 caller write had just been issued
and was still in flight. close() then flushed Google's accumulated caller text for the whole call as one
final, before onClose. This is the path ClawSweeper flagged. Limitation: this is the client-side close
(the hang-up path), not a close initiated by Google's server.

evidence
Endpoint wss://generativelanguage.googleapis.com//ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent?key=<redacted>
TLS TLSv1.3, authorized=true, SNI generativelanguage.googleapis.com, issuer Google Trust Services
Server setupComplete provider onReady fired; SDK session.setupComplete={} (set only from a server frame)
Raw server frames 120 after setup; raw inputTranscription frames match the provider callbacks (e.g. " ca", "pital")
Model gemini-2.5-flash-native-audio-preview-12-2025 (partial caller text + cumulative flush on close); sibling gemini-3.1-flash-live-preview (default)
Close-time flush 92 chars (the whole call) → residualChars=0 after fix; residualChars=71 on 4c6ed3e3
Stored entries after fix: 6, user/bot alternating, no duplicates, no missing text; 4c6ed3e3: 7 (whole caller transcript re-stored)

Stored transcript after close (after fix, 2.5 native audio)

user: Hi, can you hear me okay?
bot: Yes, I can hear you perfectly.
user: What is the ca pital of France?
bot: The capital of France is Paris.
user: Great. Thanks. So, goodbye. <noise>
bot: You're welcome, have a good day!

Same harness on 4c6ed3e3's handler (before)

user: Hi, can you hear me okay?
bot: Yes, I can hear you clearly.
user: What is the ca pital of France?
bot: The capital of France is Paris.
user: Great. Thanks.
bot: You're welcome! Is there anything
user: Hi, can you hear me okay? What is the capital of France? Great. Thanks.

Default model gemini-3.1-flash-live-preview (after fix)

user: Hi. Can you hear me okay?
bot: Yes, I can hear you perfectly. How can I help?
user: What is the capital of France?
bot: The capital of France is Paris.
user: Great, thanks. That's all. Goodbye.
bot: You're very welcome, have a great day!

3.1 emits each caller utterance as one complete final, so at close it has no pending caller text to flush.

Redacted after-fix runtime trace (2.5 native audio, abridged: caller partials 1–2 and assistant deltas omitted)

[proof + 11301ms] provider onReady (server setupComplete received and session open)
[proof + 11304ms] transport ws protocol=wss: host=generativelanguage.googleapis.com path=//ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent query=?key=<redacted>
[proof + 11304ms] transport tls protocol=TLSv1.3 authorized=true servername=generativelanguage.googleapis.com issuerO=Google Trust Services remotePort=443
[proof + 12105ms] caller turn 1: streaming 18880B (2.36s) text="Hi, can you hear me okay?"
[proof + 15114ms] wire server frame inputTranscription={"text":" you hear me okay?"}
[proof + 17114ms] provider onTranscript role=assistant final=true text="Yes, I can hear you perfectly."
[proof + 17915ms] caller turn 2: streaming 23040B (2.88s) text="What is the capital of France?"
[proof + 20889ms] wire server frame inputTranscription={"text":" ca"}
[proof + 21028ms] wire server frame inputTranscription={"text":"pital"}
[proof + 22648ms] provider onTranscript role=assistant final=true text="The capital of France is Paris."
[proof + 25955ms] caller turn 3: streaming 26240B (3.28s) text="Great, thanks. That's all, goodbye."
[proof + 27926ms] wire server frame inputTranscription={"text":" Great. Thanks."}
[proof + 29970ms] wire server frame inputTranscription={"text":" So, goodbye. <noise>"}
[proof + 31409ms] provider onTranscript role=assistant final=true text="You're welcome, have a good day!"
[proof + 31409ms] CLOSE: bridge.close() in the same tick as assistant final #3 (caller turn-3 write just issued)
[proof + 31410ms] provider onTranscript role=user final=true text="Hi, can you hear me okay? What is the capital of France? Great. Thanks. So, goodbye. <noise>"
[proof + 31411ms] provider onClose reason=completed
[voice-call] realtime input transcript callId=<call-id> providerCallId=request-uuid final=true chars=92 aggregateChars=92 residualChars=0
[voice-call] Realtime call ended callId=<call-id> providerCallId=request-uuid reason=completed
[proof + 31475ms] stored transcript after close (6 entries)

Observed on the real transport: "ca pital"

Google 2.5 splits words across inputTranscription frames (" ca", "pital"). The committed caller turn
comes from the handler's smart-joined partial buffer (appendTranscriptText), which puts a space between the
fragments. Google's own final and the raw concatenation both read "capital". Base main stored the provider
final and never committed partials, so this PR introduced the spacing. It affects stored text only;
ordering, deduplication, and the close-time reduction are unaffected (the reduction compares
whitespace-insensitively). Recorded as a follow-up and not fixed in this revision.

The harness was a temporary vitest file driven by node scripts/run-vitest.mjs in the
extension-database-workers project, with GEMINI_API_KEY taken from the environment. It was removed after
capture and is not part of this diff.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call size: S labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 1:46 PM ET / 17:46 UTC (Revision 20).

ClawSweeper review

What this changes

The voice-call plugin stores realtime caller speech before the corresponding assistant reply, avoids duplicate final transcripts, and adds SQLite-backed regression coverage.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still has the reported ordering defect. The latest commit resolves the previous continuity-reset finding, and no blocking defect remains in the reviewed patch.

Priority: P2
Reviewed head: e22c8de5acf80ff0186b5fdf288cf763d9cd1352

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, source-consistent repair with real transport evidence and meaningful storage regressions; the previous blocking finding is resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The snapshot-matched body records the real handler, Google Live transport, carrier audio entrypoint, and SQLite readback showing alternating turns and removal of the duplicated close-time aggregate. Historical real proof remains applicable to the central repair; later text and generation fixes have supplemental persisted-transcript regressions. The existing stored record format is unchanged, so no data-model migration is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The snapshot-matched body records the real handler, Google Live transport, carrier audio entrypoint, and SQLite readback showing alternating turns and removal of the duplicated close-time aggregate. Historical real proof remains applicable to the central repair; later text and generation fixes have supplemental persisted-transcript regressions. The existing stored record format is unchanged, so no data-model migration is required.
Evidence reviewed 10 items Introduced production changes: Read the pinned merge-base-to-head production diff and original transcript-state code. Caller turns are issued before assistant writes, persistence tracks all issued writes, and final reduction accounts for failed caller writes.
Previous finding resolved: The exact-head GitHub commit patch verifies that continuity reset replaces the ledger, while each previously received final captures its original ledger. The new persisted-transcript regression covers committed caller turns before and after a non-resumable reset.
Provider lifecycle contract: Google forwards raw transcription fragments, flushes accumulated caller text before assistant text at close, and clears pending transcripts before emitting a non-resumable continuity reset. These contracts match the handler's generation-scoped ledger.
Findings None None.
Security None None.

How this fits together

The voice-call plugin receives speech transcripts from realtime providers while handling telephony audio. Its handler sends transcript events through the call manager to the stored call record used for post-call review.

flowchart TD
  A[Telephony audio] --> B[Realtime voice provider]
  B --> C[Caller partials and finalized replies]
  C --> D[Voice-call transcript handler]
  D --> E[Turn ordering and final deduplication]
  E --> F[Call manager write queue]
  F --> G[SQLite call transcript]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +214, Tests +471. Total +685 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 259 45 +214
Tests 2 471 0 +471
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 730 45 +685

Review metrics

Metric Value Why it matters
Persistence complexity Production net +214 LOC; regression tests +470 LOC The growth supports explicitly described ordering, failure recovery, and provider-generation accounting using the existing write queue.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #159138
Summary: This PR is the implementation candidate for the same author's concrete transcript-ordering report; the issue should remain open until the repair merges.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep one call-manager persistence owner and preserve complete, ordered caller turns across final flushes, consultations, and provider generations.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the path: run a multi-turn Google Live call using partial caller transcription, then inspect its stored transcript after close; current main persists assistant turns before the cumulative caller final. This review did not execute that path.

Is this the best way to solve the issue?

Yes, the patch repairs transcript sequencing at the existing handler and manager boundary, and the latest generation-scoping change resolves the prior finding without adding configuration or a competing storage owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c88dd9375fe8.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The snapshot-matched body records the real handler, Google Live transport, carrier audio entrypoint, and SQLite readback showing alternating turns and removal of the duplicated close-time aggregate. Historical real proof remains applicable to the central repair; later text and generation fixes have supplemental persisted-transcript regressions. The existing stored record format is unchanged, so no data-model migration is required.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs post-call transcript ordering with limited impact on the voice-call plugin.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The snapshot-matched body records the real handler, Google Live transport, carrier audio entrypoint, and SQLite readback showing alternating turns and removal of the duplicated close-time aggregate. Historical real proof remains applicable to the central repair; later text and generation fixes have supplemental persisted-transcript regressions. The existing stored record format is unchanged, so no data-model migration is required.
  • proof: sufficient: Contributor real behavior proof is sufficient. The snapshot-matched body records the real handler, Google Live transport, carrier audio entrypoint, and SQLite readback showing alternating turns and removal of the duplicated close-time aggregate. Historical real proof remains applicable to the central repair; later text and generation fixes have supplemental persisted-transcript regressions. The existing stored record format is unchanged, so no data-model migration is required.

Evidence

What I checked:

  • Introduced production changes: Read the pinned merge-base-to-head production diff and original transcript-state code. Caller turns are issued before assistant writes, persistence tracks all issued writes, and final reduction accounts for failed caller writes. (extensions/voice-call/src/webhook/realtime-handler.ts:1304, e22c8de5acf8)
  • Previous finding resolved: The exact-head GitHub commit patch verifies that continuity reset replaces the ledger, while each previously received final captures its original ledger. The new persisted-transcript regression covers committed caller turns before and after a non-resumable reset. (extensions/voice-call/src/webhook/realtime-handler.ts:1389, e22c8de5acf8)
  • Provider lifecycle contract: Google forwards raw transcription fragments, flushes accumulated caller text before assistant text at close, and clears pending transcripts before emitting a non-resumable continuity reset. These contracts match the handler's generation-scoped ledger. (extensions/google/realtime-voice-provider.ts:1137, e22c8de5acf8)
  • Authoritative persistence ordering: The call manager queues events under one state key, appends nonempty finalized caller and assistant entries, and persists the prepared record before publishing mutations. The PR uses this existing ordering owner without changing the stored format. (extensions/voice-call/src/manager/events.ts:168, e22c8de5acf8)
  • Current main still needs the repair: Current main buffers caller partials without persisting them and writes assistant finals immediately; caller storage waits for a provider final. The proposed assistant-boundary caller commit and ledger are absent. (extensions/voice-call/src/webhook/realtime-handler.ts:1080, c88dd9375fe8)
  • Latest-release check: Inspected the handler at v2026.9.8 through the GitHub contents API; it retains the partial buffer and has neither the caller-turn commit nor committed-caller ledger. No released implementation of this repair was established. (extensions/voice-call/src/webhook/realtime-handler.ts, fc23bc864e45)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (19 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-27T18:41:38.231Z sha a643a5cc9a3cb42711e05a16e03380c41a6e6c40 :: blocked before merge. :: [P2] Preserve an exact repeated caller utterance
  • reviewed 2026-09-27T19:40:30.689Z sha 5694b4b6320eb6cd0785f377784bb4f70a328530 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-04T11:16:55.696Z sha a5e633d7a7d83ef19a95f91a41dfa8348edfed60 :: blocked before merge. :: [P2] [P2] Preserve omitted caller text before claiming the whole turn
  • reviewed 2026-10-04T11:42:57.741Z sha e3591a15663e96463c04bf1bfabbcd1f748c5285 :: blocked before merge. :: [P2] [P2] Preserve omitted caller text before claiming the whole turn
  • reviewed 2026-10-04T11:53:11.473Z sha 893eabbea4f0f3461b057b39274d6230d8b54ddc :: blocked before merge. :: [P2] [P2] Preserve omitted caller text before claiming the whole turn
  • reviewed 2026-10-04T13:50:54.797Z sha 4e1f3fd37c919cf47d438f1b782157b360f359d4 :: blocked before merge. :: [P2] Preserve pending persistence text when a consult consumes its context
  • reviewed 2026-10-04T15:12:32.489Z sha 89214f68d5396926470320cbfc165739e6d9b6d9 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-04T16:04:56.113Z sha 8e8e857 :: blocked before merge. :: [P2] [P2] Reset the caller ledger when provider continuity resets

@mnowrot

mnowrot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The findings from the last review have been addressed on the current head; the PR body now carries a "Review response" section with the reworked behaviour and the after-fix regression tests (names + exact command + observed result). passes on the branch.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@mnowrot
mnowrot force-pushed the fix/voice-call-transcript-turn-order branch from a54c0c2 to 7832d95 Compare September 27, 2026 13:48
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 27, 2026
@mnowrot

mnowrot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Verification evidence — revision 7 (f8ffedf50)

Revision 7 is pushed and now verified locally. Both required lanes green, with a negative control proving the two new regression cases actually exercise the fix.

Commit

f8ffedf50  fix(voice-call): preserve caller transcript text fidelity
7832d9521  fix(voice-call): scope the realtime caller ledger to its bridge   (parent)

2 files changed, 63 insertions(+), 11 deletions(-) — extensions/voice-call/src/webhook/realtime-handler.ts and …realtime-handler.transcript-store.test.ts. No changes to shared test infrastructure.

Vitest — 4 files, EXIT 0, 79 s wall

node scripts/run-vitest.mjs \
  extensions/voice-call/src/webhook/realtime-handler.test.ts \
  extensions/voice-call/src/webhook/realtime-handler.lifecycle.test.ts \
  extensions/voice-call/src/webhook/realtime-handler.persistence.test.ts \
  extensions/voice-call/src/webhook/realtime-handler.transcript-store.test.ts
shard vitest.extension-database-workers.config.ts  → transcript-store   8/8 passed   (47.7 s)
shard vitest.extension-voice-call.config.ts        → handler/lifecycle/persistence  111/111 passed  (27.7 s)
[test] passed 2 Vitest shards in 78.38s

Negative control — the two new cases fail on the reviewed handler

With realtime-handler.ts reverted to 7832d9521 (tests kept at revision 7), the transcript-store file gives 2 failed | 6 passed:

  • does not store a long caller turn again… — the whole ~2.8 kB caller prefix was re-stored as the final turn instead of Goodbye.
  • preserves words split across provider input transcription frames — stored "What is the ca pital of France?"

Restoring the patched handler returns 8 passed (8) (EXIT 0), and the tree diff stays byte-identical to the reviewed change.

Oxlint lane — EXIT 0

node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/voice-call/src/webhook
[plugin-sdk boundary dts] emitted 11282 files
Found 0 warnings and 0 errors.
Finished in 33.0s on 19 files with 263 rules using 1 threads.

Note for anyone reproducing: this lane first failed in a stale worktree whose node_modules held @openclaw/fs-safe 0.20.0 while package.json/pnpm-lock.yaml pin 0.21.0 — the failure surfaced as a TS2322 in unrelated src/claws/src/skills files during the boundary-dts prerequisite, not in this diff. After aligning the install, the lane is clean.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 27, 2026
@mnowrot

mnowrot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

CI: openclaw/ci-gate is red, but not from this diff.

  • Failing check: checks-node-compact-small-11
  • Test: test/vitest-scoped-config.test.ts → discovers current and new src/agents watch files once across database owners
  • Assertion at test/vitest-scoped-config.test.ts:1201: expected [ …(1537) ] to include 'src/agents/tools/subagents-tool.acp-c…'

This PR touches extensions/voice-call/src/webhook/realtime-handler.ts (plus its transcript-store test) and adds one line to test/vitest/vitest.extension-database-workers-paths.mjs. The failing expectation reads the core list (test/vitest/vitest.database-worker-core-paths.mjs) for paths under src/agents/ — neither file is touched here.

Locally, on the head commit 5694b4b63, test/vitest-scoped-config.test.ts passes 105/105 (exit 0, ~30 s). The same self-test family also failed a different shard on the previous head, so this reads as a declared-list vs. discovered-files mismatch in the core tooling lane rather than a regression from this change.

Worth a job re-run before treating it as a merge blocker.

@mnowrot
mnowrot force-pushed the fix/voice-call-transcript-turn-order branch from 5694b4b to a5e633d Compare October 4, 2026 11:09
@clawsweeper clawsweeper Bot removed the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Oct 4, 2026
mnowrot and others added 7 commits October 4, 2026 17:56
…whole

A committed caller turn was claimed by a compact prefix match with no word
boundary, so a per-utterance final "high" after a stored "hi" was reduced to
"gh". A claim now also requires the match to end where the final ends or where
the source skips whitespace; otherwise the final is kept whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A per-utterance final such as "hello again" after a stored "hello" matched
the committed prefix and was reduced to "again", dropping "hello" from the
stored transcript. A committed turn is now claimed only when the text after
the claimed turns is exactly what the provider streamed since the last
commit, which is what a cumulative flush carries; otherwise the final is
kept whole.

The cumulative-flush fixtures now stream their tail as a partial before the
flush, matching Google Live input transcription traffic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts text

Every realtime provider finalizes the caller speech it streamed as partials
since its previous final, and the handler already records that stream. Use
it to decide how much of a final restates committed turns: only the length
beyond the stream since the last commit. A final no longer than that stream
is one new utterance, so a caller who repeats a stored "yes" keeps both
turns. Text matching now only verifies the accounting and returns the final
whole on any mismatch, which retires the word-boundary heuristic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ialogue test

main keeps the lifecycle harness's no-op StreamDisconnectLifecycle
module-private, so the named import no longer exists (TS2459), leaving the
handler's stream-disconnect lifecycle undefined at runtime.
The 1,200-char partial cap also bounded the raw buffer that caller turns are
persisted from, and the final's reduction skipped the dropped prefix as if it
had been stored. Bound only the consult buffer and keep the raw stream whole.
…ontext

A completed consultation consumed the caller's raw persistence deltas along
with its own bounded context, so a partial-only provider's turn was never
committed at the assistant boundary and the cumulative close final was stored
whole, duplicating the earlier turns. The consult path now spends only its
context; the storage path alone consumes the deltas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mnowrot
mnowrot force-pushed the fix/voice-call-transcript-turn-order branch from 89214f6 to 8e8e857 Compare October 4, 2026 15:58
@mnowrot

mnowrot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
A non-resumable reconnect drops the provider's accumulated input
transcript and emits session.continuity.reset, but the committed-caller
ledger lived for the whole bridge. The replacement session's cumulative
flush was then reduced against turns the previous session committed,
failed to align, and stored its already-committed text a second time.

Rebind the ledger on the continuity reset, alongside the generation
bump. A caller final captures the ledger when it is created, so a flush
deferred behind an in-flight turn write still reduces against the
generation it belongs to.
@mnowrot

mnowrot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 4, 2026
roboclaw-bot added a commit that referenced this pull request Nov 3, 2026
Fixes realtime voice-call transcripts recording a late-finalized caller turn after its assistant reply. Carry observed turn starts into the existing transcript-append owner and retain repeated utterances.

Supersedes #159143, thanks @mnowrot.
Related: #159138

The 65-line regression allocation covers real carrier WebSocket ingress through persisted SQLite dialogue order, including partial-text and speech-start paths and repeated caller phrases. Both cases failed on main; 132 focused tests and touched-file lint/format pass remotely. Independent Codex autoreview P0-P2 was scoped-clean.

Co-authored-by: Marcin Nowrot <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @mnowrot for tracking this down. The core dialogue-ordering fix is now merged in #191602 (a5a98d5), with your authorship credited. The regression fails on main and passes with the repair through real carrier ingress and persisted transcripts. Closing this in favor of the merged replacement.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…law#191602)

Fixes realtime voice-call transcripts recording a late-finalized caller turn after its assistant reply. Carry observed turn starts into the existing transcript-append owner and retain repeated utterances.

Supersedes openclaw#159143, thanks @mnowrot.
Related: openclaw#159138

The 65-line regression allocation covers real carrier WebSocket ingress through persisted SQLite dialogue order, including partial-text and speech-start paths and repeated caller phrases. Both cases failed on main; 132 focused tests and touched-file lint/format pass remotely. Independent Codex autoreview P0-P2 was scoped-clean.

Co-authored-by: Marcin Nowrot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: voice-call Channel integration: voice-call P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: realtime voice-call transcripts store all agent lines first and the caller as one glued blob

2 participants