Skip to content

fix(talk): cancel realtime output without aborting the turn - #119211

Closed
vincentkoc wants to merge 4 commits into
refactor/talk-harness-event-resultsfrom
stack/talk-output-cancel
Closed

vincentkoc wants to merge 4 commits into
refactor/talk-harness-event-resultsfrom
stack/talk-output-cancel

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

talk.realtime.cancelOutput used the full turn-cancellation path. Barge-in or playback stop could abort the active agent consult and destroy turn state instead of only stopping assistant audio. A delayed provider completion could also clear playback belonging to a newer output generation.

Why This Change Was Made

Output cancellation now owns only provider response truncation and client playback clearing. cancelTurn remains the explicit destructive operation for the whole turn. The UI sends the authoritative playback turnId, and the relay fences delayed clears by both turn and monotonic output generation.

User Impact

Users can interrupt spoken output and continue the same realtime conversation without losing active agent or tool work. Stale cancellation and completion events cannot clear newer playback.

Evidence

Stack

Depends on #112818.

Punchcard-Session: calm-cedar-river-aa

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 4, 2026
@vincentkoc vincentkoc self-assigned this Aug 4, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 7, 2026, 8:43 PM ET / August 8, 2026, 00:43 UTC.

ClawSweeper review

What this changes

The PR separates realtime audio-output cancellation from destructive Talk-turn cancellation and attempts to fence stale playback clears.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked by patch quality or review findings - 9 items remain

Keep open: this maintainer-owned stacked PR addresses a real current-main Talk bug, but two previously reported P1 cancellation races remain on its exact head.

Priority: P1
Reviewed head: aa5d5838f609b56d1dc8b943b0bca17a969e4653

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The intended lifecycle split is sound, but the exact head retains two P1 playback-correlation failures.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR author is a repository member; the supplied focused Control UI and Blacksmith claims were not independently inspectable in this environment.
Patch quality 🧂 unranked krab (1/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR author is a repository member; the supplied focused Control UI and Blacksmith claims were not independently inspectable in this environment.
Evidence reviewed 5 items Current main still has the reported destructive behavior: Current main routes cancelOutput to whole-turn relay cancellation, which aborts the turn rather than only playback.
Delayed provider clears share mutable correlation: The PR head stores one pending generation for all cancellations; a later delayed clear consumes that shared value, so two delayed clears can clear newer playback.
Native relay clients lack cancellation identity: The new optional turn-ID guard accepts missing IDs, while the iOS and Android relay clients do not retain the audio event turn ID for cancellation.
Findings 2 actionable findings [P1] Retain identity for every delayed provider clear
[P1] Require playback identity from native relay clients
Security None None.

How this fits together

Control UI and native relay clients send Talk cancellation requests to the Gateway relay, which controls provider audio and preserves or aborts agent work. The relay must clear only the playback generation that originated the cancellation.

flowchart LR
  Client[Web and native relay clients]
  Gateway[Gateway Talk handler]
  Relay[Realtime relay session]
  Identity[Turn and output identity]
  Provider[Voice provider clear callback]
  Playback[Current audio playback]
  Agent[Agent consult]
  Client --> Gateway --> Relay --> Identity
  Identity --> Provider
  Identity --> Playback
  Relay --> Agent
Loading

Before merge

  • Retain identity for every delayed provider clear (P1) - pendingProviderClearGeneration is a single session slot. With two cancellations pending, the first callback consumes the second callback’s generation and the second can fall back to the current generation, clearing fresh playback; retain one identity per callback and cover the two-cancel/two-clear order.
  • Require playback identity from native relay clients (P1) - An absent turnId is accepted as current, but both native relay clients omit it. A delayed native cancellation can therefore target a later active turn; capture and forward the playback identity in iOS and Android, then test a stale cancellation after replacement output.
  • Resolve merge risk (P1) - A scalar pending-clear slot can let two delayed provider callbacks clear a newer output generation.
  • Resolve merge risk (P1) - Existing iOS and Android relay clients omit cancellation identity, so a stale native cancellation can affect a later active turn.
  • Resolve merge risk (P1) - The draft stack is dirty against its base and conflicts with current main, so the repaired behavior needs an exact-head rebase and regression proof before merge.
  • Complete next step (P2) - The two code-level repairs are clear, but this protected maintainer-owned draft is a dirty stacked branch that needs its author or stack owner to rebase and validate the exact head.
  • Improve patch quality - Retain one immutable correlation record for each delayed provider clear and add the two-cancel/two-clear regression.
  • Improve patch quality - Capture and send playback identity from iOS and Android relay clients, with stale-cancellation coverage.
  • Improve patch quality - Rebase the repaired stack and attach exact-head, redacted Control UI or relay-boundary proof.

Findings

  • [P1] Retain identity for every delayed provider clear — src/gateway/talk-realtime-relay-session-create.ts:237-238
  • [P1] Require playback identity from native relay clients — src/gateway/talk-realtime-relay-operations.ts:553-555
Agent review details

Security

None.

PR surface

Source +70, Tests +208. Total +278 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 81 11 +70
Tests 3 210 2 +208
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 291 13 +278

Review metrics

Metric Value Why it matters
Production versus test delta production +81/-11 (net +70); tests +210/-2 (net +208) The lifecycle boundary justifies the production growth in principle, but the new correlation state remains incomplete.

Merge-risk options

Maintainer options:

  1. Repair cancellation correlation before merge (recommended)
    Retain callback-local playback identity, add web and native stale-cancellation regressions, then rebase the stack and obtain exact-head proof.
  2. Pause the stacked branch
    Pause this branch if the dependent realtime-session refactor cannot be rebased without redefining the cancellation contract.

Technical review

Best possible solution:

Carry immutable playback identity from every client through cancellation, retain one correlation record per delayed provider clear, and cover the two-cancel/two-delayed-clear sequence before rebasing the stack.

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

Yes — source establishes the two-cancel/two-delayed-clear order that corrupts playback correlation, although this read-only review did not execute it.

Is this the best way to solve the issue?

No — separating output cancellation from turn cancellation is the right owner boundary, but the patch must preserve identity per delayed callback and for every relay client.

Full review comments:

  • [P1] Retain identity for every delayed provider clear — src/gateway/talk-realtime-relay-session-create.ts:237-238
    pendingProviderClearGeneration is a single session slot. With two cancellations pending, the first callback consumes the second callback’s generation and the second can fall back to the current generation, clearing fresh playback; retain one identity per callback and cover the two-cancel/two-clear order.
    Confidence: 0.99
  • [P1] Require playback identity from native relay clients — src/gateway/talk-realtime-relay-operations.ts:553-555
    An absent turnId is accepted as current, but both native relay clients omit it. A delayed native cancellation can therefore target a later active turn; capture and forward the playback identity in iOS and Android, then test a stale cancellation after replacement output.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 480e0c006067.

Labels

Label justifications:

  • P1: The patch targets active realtime conversations, but remaining races can stop or clear user output incorrectly.
  • merge-risk: 🚨 compatibility: The PR changes cancelOutput from whole-turn cancellation to output-only behavior across existing clients.
  • merge-risk: 🚨 session-state: Stale cancellation and delayed clear callbacks can affect a later active turn or playback generation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The PR author is a repository member; the supplied focused Control UI and Blacksmith claims were not independently inspectable in this environment.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the current stacked relay-generation work and the exact PR head. (role: recent relay-generation contributor; confidence: high; commits: 65f56927e9b8, aa5d5838f609; files: src/gateway/talk-realtime-relay-operations.ts, src/gateway/talk-realtime-relay-session-create.ts)
  • steipete: History attributes the earlier Gateway relay owner split to this contributor. (role: gateway relay feature introducer; confidence: medium; commits: dc60a9442d5c; files: src/gateway/talk-realtime-relay-operations.ts, src/gateway/server-methods/talk-session.ts)

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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-04T20:06:32.356Z sha 560fb4e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T20:15:55.097Z sha 560fb4e :: needs changes before merge. :: [P1] Propagate the output turn ID from the relay client | [P2] Deduplicate delayed provider clear callbacks | [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-04T22:12:37.502Z sha 560fb4e :: found issues before merge. :: [P1] Propagate the output turn ID from the relay client | [P2] Deduplicate delayed provider clear callbacks | [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-05T01:16:37.307Z sha 0f6dc93 :: found issues before merge. :: [P1] Retain a generation for each delayed provider clear | [P1] Fence output cancellation for every bundled relay client
  • reviewed 2026-08-05T02:04:38.579Z sha e6a6030 :: found issues before merge. :: [P1] Correlate each delayed provider clear | [P1] Fence cancellation with the captured output generation | [P1] Forward cancellation correlation from mobile relay clients
  • reviewed 2026-08-05T03:25:48.679Z sha aa5d583 :: found issues before merge. :: [P1] Correlate every delayed provider clear | [P1] Capture the output generation before the cancellation reaches the relay | [P1] Propagate cancellation identity from native relay clients
  • reviewed 2026-08-05T03:32:46.892Z sha aa5d583 :: found issues before merge. :: [P1] Retain identity for every delayed provider clear | [P1] Carry the captured output generation in cancellation | [P1] Fence native relay cancellation with playback identity
  • reviewed 2026-08-06T05:52:32.631Z sha aa5d583 :: found issues before merge. :: [P1] Retain identity for every delayed provider clear | [P1] Fence native relay cancellation with playback identity

@vincentkoc
vincentkoc force-pushed the refactor/talk-harness-event-results branch from 7fc2084 to 61521c6 Compare August 4, 2026 12:15
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from aa406c2 to 2ccdbbc Compare August 4, 2026 12:16
@vincentkoc
vincentkoc force-pushed the refactor/talk-harness-event-results branch from 61521c6 to 5c943f5 Compare August 4, 2026 12:22
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from 2ccdbbc to c2cf34a Compare August 4, 2026 12:22
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 4, 2026
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from c2cf34a to 560fb4e Compare August 4, 2026 19:37
@vincentkoc
vincentkoc force-pushed the refactor/talk-harness-event-results branch from 5c943f5 to 297c5a0 Compare August 4, 2026 19:37
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from bd4fae7 to 0f6dc93 Compare August 5, 2026 01:08
@vincentkoc
vincentkoc force-pushed the refactor/talk-harness-event-results branch from 1053f88 to 0627843 Compare August 5, 2026 01:08
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc force-pushed the refactor/talk-harness-event-results branch from 0627843 to 40d01a2 Compare August 5, 2026 01:22
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from 0f6dc93 to e6a6030 Compare August 5, 2026 01:22
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 5, 2026
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from e6a6030 to 069f48f Compare August 5, 2026 02:29
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Punchcard-Session: cobalt-cedar-timber-04
Punchcard-Session: calm-cedar-river-aa
Punchcard-Session: cobalt-cedar-timber-04
Punchcard-Session: calm-cedar-river-aa
Punchcard-Session: cobalt-cedar-timber-04
Punchcard-Session: calm-cedar-river-aa
Punchcard-Session: calm-cedar-river-aa
@vincentkoc
vincentkoc force-pushed the refactor/talk-harness-event-results branch from 49632fe to 8bae3a8 Compare August 5, 2026 03:16
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from 069f48f to aa5d583 Compare August 5, 2026 03:16
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 5, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Superseded by the consolidated draft #121894. The replacement keeps output cancellation generation-scoped while combining it with the authoritative relay-event and durable consult-ownership fixes, with current focused, SDK, build, Android, and mock-Gateway proof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant