Skip to content

fix(talk): bind realtime delegation ownership - #129186

Merged
vincentkoc merged 15 commits into
mainfrom
fix/talk-delegation-owner-pr2
Sep 8, 2026
Merged

vincentkoc merged 15 commits into
mainfrom
fix/talk-delegation-owner-pr2

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

New spoken delegation could start competing embedded work or deliver a late result after the authoritative Talk owner had been cancelled, replaced, or revoked.

Related: #129144, #121894, #118499, #118505

Stack: 2/3. The prerequisite privacy layer has landed. The next layer adds yielded subagent completion reattachment.

Why This Change Was Made

  • Keep one canonical parent run and steer newer spoken requests into its exact active backend.
  • Bind completion and failure delivery to the exact Talk session, requester, run, lifecycle generation, and one-shot claim.
  • Preserve the registered caller tool-authority projection during steering.
  • Reject stale, cancelled, replaced, ownerless, or lifecycle-rotated callbacks before provider output.
  • Keep ordinary Gateway tool consultations non-owning so sequential consultations remain reusable.
  • Fence relay replacement during awaited consult startup before embedded-agent I/O.
  • Add no public SDK, config, environment, protocol, SQLite, catalog, manifest, package, or tool-policy surface.

User Impact

Realtime voice remains responsive while the parent agent works. New speech steers the accepted run, valid completion returns exactly once, and stale work cannot speak through a successor.

Root Cause And Owner

Run correlation was being treated as delivery authority across asynchronous Gateway startup, replacement, and teardown. The canonical owner is the Gateway operational run instance plus its closure-bound Talk owner. This change carries that authority through backend registration and revalidates it synchronously at steering, startup registration, and final provider append.

Evidence

  • Exact head: 1a790bdd2cdd2290ded104285eacbba463dda196
  • Focused matrix: 423 passed across Gateway, embedded-agent, server-method, and provider suites.
  • Targeted ownership coverage includes the two-independent-runner replacement regression, unresolved-readiness steering, and back-to-back provider steering.
  • Formatting and oxlint passed. Native i18n verification reported 3,783 entries with no generated change.
  • Exact-head hosted type, lint, build, dependency, security, and changed-path checks: https://github.com/openclaw/openclaw/actions/runs/34255955052.
  • The focused Android test could not start in the isolated worktree because its generated-assets prerequisite could not resolve a package through the deliberately unreconciled borrowed dependency tree. No product assertion failed and the worktree remained clean.

Sanitized real-socket proof:

connected=true
providerSocketOpen=true
invalidCases=6
invalidProviderSends=0
activeAppendSends=1
startupFailureAppendSends=1
duplicateAppendSends=0
productionActiveCompletions=2
productionActiveBackendCalls=2
productionReplacedProviderSends=0
productionReplacedBackendCalls=0
elapsedMs=7618
result=pass
privacyScanClean=true
rawOutputBytes=0

Invalid owner cases:

replaced-owner: providerSends=0
cancelled-owner: providerSends=0
revoked-owner: providerSends=0
different-requester: providerSends=0
startup-failure-revoked: providerSends=0

Valid owner cases:

active-owner: providerSends=1
startup-failure-active: providerSends=1
production-non-owning-active: completions=2 backendCalls=2
production-non-owning-replaced: providerSends=0 backendCalls=0

Dependency Contract

Direct inspection of openai/codex@9a3af22d01bc9abcafb1e3aa01cb4738a2caf37a confirmed:

  • spawn starts the child and returns without waiting: codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs:207-269
  • wait is explicit: codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs:45-116
  • steering passes and validates the exact active turn: codex-rs/core/src/session/turn_input.rs:424
  • no-active, mismatched, and non-steerable turns reject atomically: codex-rs/core/src/session/turn_input.rs:527-543
  • app-server maps missing or mismatched active turns to invalid requests: codex-rs/app-server/src/request_processors/turn_processor.rs:1006-1074
  • notification coverage preserves non-wait behavior: codex-rs/core/tests/suite/subagent_notifications.rs:928-955

Review Disposition

ClawSweeper findings at prior heads are addressed:

  • Backend readiness waits for exact backend publication.
  • Caller tool authority remains closure-bound and is re-projected at steering.
  • Startup failure speech uses a separate session-fenced one-shot claim.
  • Sequential ordinary consultations retain a reusable non-owning runner.
  • Transcript-admission steering waits for the same invocation's admission.
  • Same-owner retries retarget only after successful exact-turn steering.
  • Reused correlation from another admission fails closed.
  • Stale startup validates the exact owner pointer before any mutation.

Independent autoreview found and this head fixes one additional P1: generic plain consult runners were incorrectly required to publish completion claims, causing successful delegation output to be dropped. The controller now requires claims only after explicit adoption; lifecycle-bound runners remain fail-closed.

Final review found and this head fixes a second P1: a stale separate runner could revoke the active replacement's completion claim before validating current ownership. Claim installation now follows relay/client registration, and browser ownership is revalidated immediately before global claim mutation. The pre-fix replacement claim failed; the exact-head regression preserves the active claim and rejects the stale runner.

Review Metrics

  • Production: +742/-62 (net +680)
  • Tests and test support: +1799/-71 (net +1728)
  • Public config/default surfaces: 0 added, changed, or removed.

The production growth establishes one cross-layer lifecycle authority boundary. A consumer-only guard cannot safely cover backend publication, exact caller projection, startup failure, relay replacement, retry steering, plain-runner compatibility, and one-shot final delivery.

ClawSweeper Rank-Up Moves

  • Production reusable admission: applied with two successful direct Gateway-owner consultations and replacement rejection before backend I/O; the existing real-socket one-shot delivery and zero-send invalid-owner evidence is retained.
  • Real behavior proof: applied with named allowed/rejected production scenarios and final-send counts.
  • Backend registration ordering: applied with exact backend publication and production-controller tests.
  • Caller authority projection: applied with exact registered authority binding.
  • Startup failure delivery: applied with active/revoked failure-claim proof.
  • Ordinary Gateway consultation ownership: applied with successive successful and failed consultation coverage.
  • Different-requester and revoked-owner risk: applied with zero-send real-socket evidence.
  • Deferred transcript-admission steering race: applied with pre-fix reproduction and exact-head admission, close, and replacement coverage.
  • Sequential-attempt steering: applied with exact same-owner retry retargeting coverage.
  • Reused-correlation admission: applied with a pre-fix reproduction and zero-send distinct-owner regression.
  • Pre-bind stale runtime closure: applied with immutable per-owner runtime coverage.
  • Pre-announcement replacement mutation: applied with early exact-owner validation and separate-runner claim ordering.
  • Plain runner compatibility: applied with a pre-fix reproduction and successful provider-output regression.
  • Exact-head hosted checks passed at https://github.com/openclaw/openclaw/actions/runs/34255955052; the native verifier classified all Testbox workflows as not applicable for this changed-path set.

@clawsweeper

clawsweeper Bot commented Aug 25, 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.

@vincentkoc vincentkoc self-assigned this Aug 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling extensions: openai size: L maintainer Maintainer-authored PR labels Aug 25, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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: 🦪 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 Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 1:55 PM ET / 17:55 UTC (Revision 16).

ClawSweeper review

What this changes

Binds realtime voice tasks to their Talk session and agent run, steers subsequent requests into that run, and permits completion or failure delivery only once.

Merge readiness

✅ Ready for maintainer review

This remains a useful, distinct fix: current main lacks the completion-ownership boundary. The retained prior findings are addressed, supplied production-path proof supports the ownership checks, and no new actionable defect was found.

Priority: P1
Reviewed head: 1a790bdd2cdd2290ded104285eacbba463dda196

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent ownership repair with targeted regression coverage and meaningful allowed/rejected production-path evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured production Gateway and real-provider-socket evidence demonstrates exactly-once active completion, active startup-failure delivery, zero sends for invalid owners, and replacement rejection before backend I/O; it covers the changed authority boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured production Gateway and real-provider-socket evidence demonstrates exactly-once active completion, active startup-failure delivery, zero sends for invalid owners, and replacement rejection before backend I/O; it covers the changed authority boundary.
Evidence reviewed 11 items Pinned PR remains open: The live REST response confirms the reviewed head, open and unmerged state, and assignment to vincentkoc. Supplied context identifies MEMBER authorship and the protected maintainer label.
Current main still needs this boundary: Current main retains abort-and-replace delegation and sends the completed result without the introduced completion claim. The merged privacy prerequisite, #129144, does not implement this remaining ownership work.
Latest-release comparison: The supplied latest release identifies this commit as v2026.9.3. Its consultation runner has the ordinary runArgs/runPrompt implementation without claimAppend; no release containing this PR's ownership implementation was established.
Findings None None.
Security None None.

How this fits together

Talk sends spoken requests through the Gateway to an agent and returns its answer through the realtime provider. This change connects session ownership, backend registration, steering, and final provider delivery.

flowchart LR
  A[Spoken request] --> B[Provider delegation]
  B --> C[Gateway session owner]
  C --> D[Register or steer agent run]
  D --> E[Agent completion or failure]
  E --> F{Current owner and unused claim?}
  F -->|Yes| G[Provider reply]
  F -->|No| H[Suppress stale reply]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +680, Tests +1728. Total +2408 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 9 742 62 +680
Tests 14 1799 71 +1728
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 2541 133 +2408

Review metrics

Metric Value Why it matters
Lifecycle implementation and regression coverage Production net +680 lines; tests and support net +1728 lines The stated growth implements and exercises one ownership boundary across admission, backend registration, steering, and final delivery.

Technical review

Best possible solution:

Keep authorization in the existing Gateway and run lifecycle owners, with provider delivery consuming their final claim and ordinary consultations remaining reusable.

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

Yes, source identifies the late-completion and replacement paths, and the supplied evidence exercises valid and invalid owners. This review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes. The patch extends existing admission and run-control owners, preserves ordinary callback compatibility, and checks authority immediately before steering and provider output.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Competing voice work and stale spoken completion affect the existing realtime agent workflow.
  • 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 (live_output): The captured production Gateway and real-provider-socket evidence demonstrates exactly-once active completion, active startup-failure delivery, zero sends for invalid owners, and replacement rejection before backend I/O; it covers the changed authority boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured production Gateway and real-provider-socket evidence demonstrates exactly-once active completion, active startup-failure delivery, zero sends for invalid owners, and replacement rejection before backend I/O; it covers the changed authority boundary.

Evidence

What I checked:

  • Pinned PR remains open: The live REST response confirms the reviewed head, open and unmerged state, and assignment to vincentkoc. Supplied context identifies MEMBER authorship and the protected maintainer label. (1a790bdd2cdd)
  • Current main still needs this boundary: Current main retains abort-and-replace delegation and sends the completed result without the introduced completion claim. The merged privacy prerequisite, fix(talk): keep opaque realtime routes out of public config #129144, does not implement this remaining ownership work. (extensions/openai/realtime-quicksilver-delegation-controller.ts:256, 746e53f21fe9)
  • Latest-release comparison: The supplied latest release identifies this commit as v2026.9.3. Its consultation runner has the ordinary runArgs/runPrompt implementation without claimAppend; no release containing this PR's ownership implementation was established. (src/gateway/talk-client-agent-consult.ts:183, 1391f7cd2d40)
  • Admission and steering authority: The runner rechecks ownership after readiness and before embedded admission, installs completion claims after session registration, and resolves the current backend's exact operational instance and caller authority before steering. (src/gateway/talk-client-agent-consult.ts:299, 1a790bdd2cdd)
  • Completion lifecycle and final output: The introduced registry claims are revoked on replacement, cancellation, and lifecycle rotation. Provider completion waits for steering, consumes the matching claim, and then checks the active socket before sending; ordinary callbacks retain explicit opt-in compatibility. (src/agents/embedded-agent-runner/runs.ts:988, 1a790bdd2cdd)
  • Re-review continuity: The latest completed review covers this same head with no findings. Inspected regressions cover retry authority, reused correlation from another admission, stale separate runners, deferred readiness, and reusable consultations; these match the retained prior findings and current dispositions. (src/gateway/talk-client-gateway-control.agent-consult.test.ts:707, 1a790bdd2cdd)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-07T12:41:52.767Z sha 99c9bc0 :: blocked before merge. :: [P1] Preserve reuse of the provider consult callback
  • reviewed 2026-09-07T12:50:08.730Z sha 99c9bc0 :: blocked before merge. :: [P1] Preserve reuse of the provider consult callback
  • reviewed 2026-09-07T15:52:49.691Z sha f17d933 :: needs real behavior proof before merge. :: [P1] Recheck the browser owner immediately before consult admission
  • reviewed 2026-09-08T04:40:12.537Z sha f17d933 :: needs real behavior proof before merge. :: [P1] Recheck the browser owner immediately before consult admission
  • reviewed 2026-09-08T06:15:47.965Z sha 01dfffe :: needs real behavior proof before merge. :: [P1] Fence non-owning consultations after readiness
  • reviewed 2026-09-08T11:47:15.573Z sha d4b8958 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-08T16:20:30.228Z sha 68b95a6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-08T17:21:55.239Z sha 1a790bd :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 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 exact_review_queue).
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 25, 2026
@vincentkoc
vincentkoc force-pushed the fix/talk-opaque-realtime-admission branch 10 times, most recently from 8aac70e to abee880 Compare September 5, 2026 13:51
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact-head evidence and review disposition are refreshed in the PR body for 1a790bdd2cdd2290ded104285eacbba463dda196, including the repaired separate-runner completion-claim ordering regression.

@clawsweeper

clawsweeper Bot commented Sep 8, 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 exact_review_queue).
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

Copy link
Copy Markdown
Member Author

Merged via squash.

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

Labels

agents Agent runtime and tooling extensions: openai gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant