Skip to content

fix(talk): preserve agent consults when relay disconnects - #119212

Closed
vincentkoc wants to merge 3 commits into
stack/talk-output-cancelfrom
stack/talk-consult-lifecycle
Closed

vincentkoc wants to merge 3 commits into
stack/talk-output-cancelfrom
stack/talk-consult-lifecycle

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Normal relay teardown or provider disconnect aborted durable agent consults already launched for the voice turn. A transient transport boundary could cancel useful work even though the user never requested cancellation.

Why This Change Was Made

Relay teardown now uses a non-destructive detach path that drops relay-local correlation state without aborting durable agent runs. Direct session abort, explicit stop, supersession, and exact provider tool-call cancellation remain destructive. Late completion cannot append into a closed sideband.

User Impact

Accepted agent and tool work survives normal voice relay teardown and can finish durably, while explicit user or provider cancellation still stops the intended run.

Evidence

Stack

Depends on #119211.

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. 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:42 PM ET / August 8, 2026, 00:42 UTC.

ClawSweeper review

What this changes

This PR separates realtime Talk relay teardown from explicit cancellation so accepted OpenAI sideband consults can continue after a transport disconnect.

Merge readiness

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

Keep open: the unchanged head still aborts an accepted consult when relay removal races the later run-registration acknowledgement.

Priority: P1
Reviewed head: cad6aa8920627c7cb2a40f914a12bf9c02afcf8a

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has a concrete P1 lifecycle race at the durable-registration boundary.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR; its supplied focused tests and CI are supplemental, while the remaining source-proven P1 blocks merge.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR; its supplied focused tests and CI are supplemental, while the remaining source-proven P1 blocks merge.
Evidence reviewed 5 items Unfixed late-registration race: The changed provider-close path deletes the relay before detaching local maps; a delayed onRunStarted callback then cannot find the relay to register the durable voice binding.
Caller permits the ordering: Consult startup awaits admission, workspace, and session setup before invoking onRunStarted, allowing relay closure in that interval.
Durable owner already supports late binding: Client voice-session registration deliberately binds a run even after its voice record closes, but the relay-map lookup prevents this code from being reached.
Findings 1 actionable finding [P1] Retain durable registration after relay detach
Security None None.

How this fits together

Talk’s Gateway relay carries realtime provider traffic, while the durable voice-session owner records consult runs and their effects. Relay closure should remove transport correlation without cancelling or losing registration for already admitted work.

flowchart LR
  Client[Voice client] --> Relay[Gateway realtime relay]
  Relay --> Provider[Realtime provider sideband]
  Provider --> Admission[Consult admission]
  Admission --> Registration[Durable voice-run registration]
  Relay --> Close{Relay closes}
  Close --> Detach[Release relay correlation]
  Registration --> Completion[Durable consult completion]
  Detach --> Completion
Loading

Before merge

  • Retain durable registration after relay detach (P1) - The relay is deleted before this changed close path detaches it. A consult admitted before disconnect can reach its later registration callback only after removal, where the required relay lookup fails and the catch aborts the accepted run as a voice-session binding failure. Keep the durable binding accessible outside relay-local state and cover admission → disconnect → acknowledgement.
  • Complete next step (P2) - The protected, maintainer-authored draft needs a focused lifecycle repair and exact-head re-review before merge.
  • Improve patch quality - Preserve durable binding ownership across relay removal.
  • Improve patch quality - Add the admission → disconnect → delayed-registration regression and request one exact-head re-review.

Findings

  • [P1] Retain durable registration after relay detach — src/gateway/talk-realtime-relay-session-create.ts:503
Agent review details

Security

None.

PR surface

Source +34, Tests +157. Total +191 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 46 12 +34
Tests 3 169 12 +157
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 215 24 +191

Review metrics

Metric Value Why it matters
Production versus test delta production +46/-12; tests +169/-12 The production growth implements an ownership split, but the new tests omit the admission-to-disconnect ordering that the split must protect.

Technical review

Best possible solution:

Move accepted-run identity and durable voice-session binding to the admission owner, independent of the removable relay map, while retaining destructive behavior for explicit user and provider cancellation.

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

Yes, from source: admit a consult, close or disconnect the relay during async startup, then allow onRunStarted to register; the deleted relay lookup causes the accepted run to be aborted.

Is this the best way to solve the issue?

No: transport detachment is the right direction, but leaving durable registration dependent on the removed relay map preserves the cancellation race.

Full review comments:

  • [P1] Retain durable registration after relay detach — src/gateway/talk-realtime-relay-session-create.ts:503
    The relay is deleted before this changed close path detaches it. A consult admitted before disconnect can reach its later registration callback only after removal, where the required relay lookup fails and the catch aborts the accepted run as a voice-session binding failure. Keep the durable binding accessible outside relay-local state and cover admission → disconnect → acknowledgement.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: An ordinary realtime relay disconnect can still cancel agent work that the PR intends to preserve.
  • merge-risk: 🚨 session-state: The branch changes ownership and cancellation of active voice-session consults across teardown.
  • 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: This is a maintainer-authored PR; its supplied focused tests and CI are supplemental, while the remaining source-proven P1 blocks merge.

Evidence

What I checked:

  • Unfixed late-registration race: The changed provider-close path deletes the relay before detaching local maps; a delayed onRunStarted callback then cannot find the relay to register the durable voice binding. (src/gateway/talk-realtime-relay-session-create.ts:503, cad6aa892062)
  • Caller permits the ordering: Consult startup awaits admission, workspace, and session setup before invoking onRunStarted, allowing relay closure in that interval. (src/talk/agent-consult-runtime.ts:375, cad6aa892062)
  • Durable owner already supports late binding: Client voice-session registration deliberately binds a run even after its voice record closes, but the relay-map lookup prevents this code from being reached. (src/talk/client-voice-session.ts:280, cad6aa892062)
  • Existing coverage misses the race: The new relay tests register a run before closing the relay; they do not cover admission, disconnect, then delayed acknowledgement/registration. (src/gateway/talk-realtime-relay.test.ts:4246, cad6aa892062)
  • Current-main and release check: The PR head is not an ancestor of the checked-out main and no local release tag contains it, so this behavior is neither on current main nor shipped. (cad6aa892062)

Likely related people:

  • vincentkoc: The branch’s three lifecycle commits and local history concentration connect this author to the affected Talk relay boundary. (role: recent relay and consult-lifecycle contributor; confidence: high; commits: 20d815e60efb, 783a76563826, cad6aa892062; files: extensions/openai/realtime-quicksilver-delegation-controller.ts, src/gateway/talk-realtime-relay-session-create.ts)
  • steipete: The current relay ownership structure dates to the Talk relay refactor in commit 17ccfc4. (role: major relay refactor contributor; confidence: medium; commits: 17ccfc4b98a; files: src/gateway/talk-realtime-relay-operations.ts, src/gateway/talk-realtime-relay-session-create.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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-04T22:11:34.011Z sha d1d38f9 :: found issues before merge. :: [P1] Decouple bridge teardown from durable consult cancellation
  • reviewed 2026-08-05T01:06:40.046Z sha a5bc302dec14d1f95012123611bed6d23203c1e2 :: needs changes before merge. :: [P1] Register durable consults before allowing relay detach
  • reviewed 2026-08-05T01:15:42.251Z sha 3fb3668 :: found issues before merge. :: [P1] Register durable consults before allowing relay detach
  • reviewed 2026-08-05T02:08:57.773Z sha cb51356 :: needs changes before merge. :: [P1] Preserve durable registration across relay close
  • reviewed 2026-08-05T03:08:32.746Z sha f59272ddc626ec2ce983f1d9bf7ce3ac0829e1b1 :: found issues before merge. :: [P1] Preserve durable registration after relay detach
  • reviewed 2026-08-05T03:25:01.715Z sha cad6aa8 :: found issues before merge. :: [P1] Preserve durable registration after relay detach
  • reviewed 2026-08-05T03:30:06.890Z sha cad6aa8 :: found issues before merge. :: [P1] Preserve durable registration after relay detach
  • reviewed 2026-08-06T05:52:29.474Z sha cad6aa8 :: found issues before merge. :: [P1] Retain registration ownership after relay detach

@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 stack/talk-consult-lifecycle branch from 7b73d96 to 9f2cfec Compare August 4, 2026 12:16
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from 2ccdbbc to c2cf34a Compare August 4, 2026 12:22
@vincentkoc
vincentkoc force-pushed the stack/talk-consult-lifecycle branch from 9f2cfec to b2510b6 Compare August 4, 2026 12:22
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Aug 4, 2026
@vincentkoc
vincentkoc force-pushed the stack/talk-consult-lifecycle branch from b2510b6 to d1d38f9 Compare August 4, 2026 19:37
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from c2cf34a to 560fb4e 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: 🦪 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 4, 2026
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from 560fb4e to bd4fae7 Compare August 5, 2026 00:52
@vincentkoc
vincentkoc force-pushed the stack/talk-consult-lifecycle branch from d1d38f9 to a5bc302 Compare August 5, 2026 00:52
@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.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 5, 2026
@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 stack/talk-consult-lifecycle branch from a5bc302 to 3fb3668 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:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 5, 2026
@vincentkoc
vincentkoc force-pushed the stack/talk-output-cancel branch from 0f6dc93 to e6a6030 Compare August 5, 2026 01:22
@vincentkoc
vincentkoc force-pushed the stack/talk-consult-lifecycle branch from 3fb3668 to cb51356 Compare August 5, 2026 01:22
@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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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
vincentkoc force-pushed the stack/talk-consult-lifecycle branch from cb51356 to f59272d 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: calm-cedar-river-aa
Punchcard-Session: calm-cedar-river-aa
@vincentkoc
vincentkoc force-pushed the stack/talk-consult-lifecycle branch from f59272d to cad6aa8 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 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

Copy link
Copy Markdown
Member Author

Superseded by the consolidated draft #121894. The replacement preserves admitted consult ownership across ordinary relay detach, retains explicit destructive cancellation, and folds the dependent output-identity work into one reviewable lifecycle change.

@vincentkoc vincentkoc closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: openai gateway Gateway runtime maintainer Maintainer-authored PR 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