Skip to content

fix(apple): a realtime Talk failure no longer cancels the agent answer in progress - #180571

Merged
steipete merged 4 commits into
openclaw:mainfrom
kybrcore:fix/apple-talk-relay-failure-detach
Oct 24, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
kybrcore:fix/apple-talk-relay-failure-detach

Conversation

@kybrcore

@kybrcore kybrcore commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Part of #180426
Related: #171310, #172275

What Problem This Solves

Fixes: on iOS and macOS, when Gateway-relay realtime Talk fails (microphone stall, playback failure, or a failed output
cancellation), the accepted agent consult is cancelled and its answer never reaches the conversation.

User Impact

User impact: after a Talk failure on iPhone, iPad, or Mac, the agent request already in progress finishes and its answer
appears in chat. Explicit Stop still cancels it. This needs a Gateway that advertises talk-session-close-disposition;
older Gateways keep today's aborting close.

Why This Change Was Made

The shared Apple kit closed every relay with talk.session.close { sessionId }, so the Gateway applied the default
abort. Control UI (#171377) and the Android phone app (#172276) already detach on failure. The kit's three failure
paths now send disposition: "detach" when the socket that owns the relay advertises the capability; stop() keeps the
aborting close. The macOS runtime also ends the relay itself when the microphone cannot restart (after a pause, an
input device change, or an audio failure it detects); that close now goes through the kit's new stopAfterFailure()
and detaches as well. The capability comes from the hello snapshot of that route (iOS) or server lease (macOS), so a
replacement socket never receives a field its Gateway would reject.

Accepted edge case: a detach close that times out was already sent and still applies once the Gateway recovers, and a
dropped socket detaches through the Gateway's disconnect cleanup. Only a close that never reaches a still-open socket
leaves the relay to its TTL, which aborts, as the legacy close did; the Apple connection layer has no owning-socket
reconnect hook like the ones Control UI and Android use. Closes that abandon startup keep the default; no consult can
be accepted before the relay is ready.

Not in this PR: Apple cleanup that is not a failure still aborts, as before. That covers leaving the iOS app without
"Talk in the background" (or during push-to-talk), switching conversation, a remote push-to-talk start, Gateway
connection resets, changing the macOS realtime relay setting, and stale startup attempts. Moving those to detach, so
that only an explicit Stop aborts as on Android, changes when answers are cancelled and belongs in a follow-up PR.

Evidence

Maintainer validation

  • Current-main source/history confirmed the defect at beginServerClose: omitting disposition still selects Gateway abort. The merged microphone-budget repair does not change that owner.
  • Consolidated the existing microphone-failure regression to cover capable and older Gateways; retained the explicit-Stop negative control and the macOS recovery test covering audio failure, selected-microphone restart, and unpause. All failure callers use the same stopAfterFailure owner.
  • Pinned SwiftFormat 0.63.1 checked all seven changed Swift files with no changes. Pinned SwiftLint 0.65.1 (--strict) checked all seven with zero violations. Diff checks pass; no localized strings changed.
  • macos-swift is deferred in PR CI; focused suites (41 tests) passed locally under sandbox-exec on the final head; a local revert probe could not be built (toolchain macro-plugin error); the contributor's earlier macOS run included negative controls.
  • Scoped Codex autoreview through P2: scoped-clean, no actionable findings. Exact-head CI run 40091602347 and its required checks are green. The skipped macos-swift execution remains the limitation described above.
  • Final head ec39b6629e7fd42a01f935c743c321c930e13a06 integrates main 21f0262a8883e02054ca05e9509a7249e470cb64; its diff matches the reviewed patch exactly.
  • Compared with main: production +37/-13 (net +24), tests +47/-5 (net +42), docs +1/-1. This removes 9 production and 57 test lines from the contributor proposal while preserving the capability, failure, and explicit-Stop boundaries.

Contributor evidence at original head 5d96d87cabcd9383a097c4c71704f87f869e661c

The following is the contributor's original evidence, not a new live run from this pass. Main subsequently landed #180572, which raises microphone-stall tolerance; that changes the historical six-second fault trigger but does not change failure-close disposition. This PR retains that input-budget repair and fixes the still-existing abort on actual relay failure.

  • End to end on macOS, with debug builds of the macOS app at this PR's head (5d96d87) and, for comparison, at its
    base (5a9fa92), connected as a remote Gateway to the official ghcr.io/openclaw/openclaw:2026.10.10-beta.3
    image, which advertises talk-session-close-disposition. Talk used the Gateway relay with an agent consult. Each run asked the agent for a 1500-word article (about 30 s of
    agent work). In the failure runs, the Gateway container was paused for 6 s starting 1 s after the consult began; the
    app reported Realtime audio input fell behind and closed the relay through the kit's failure path.

    Build Relay close Accepted consult after the close Answer in chat
    This PR failure (audioInputFailed) kept running for about 23 s, then completed with aborted=false yes (1943-character article)
    This PR explicit Stop Talk Mode agent run aborted about 70 ms after the close reached the Gateway no
    Base failure (audioInputFailed) agent run aborted about 70 ms after the close reached the Gateway no

    The Gateway does not log the close disposition; the tests below pin what the kit sends, and only the PR binary
    contains the detach literal. iOS was not run end to end; it uses the same kit failure close.

    Gateway debug log and macOS unified log excerpts (trimmed; seconds from the end of the spoken request; the close arrival is the response time minus its duration)
    # This PR, failure close (Gateway paused +2.741 to +8.919)
    +0.000  gateway talk              talk event transcript.done
    +0.075  gateway diagnostic        lane enqueue: lane=talk queueSize=1
    +0.511  gateway diagnostic        run registered: totalActive=1
    +7.699  macOS   RealtimeTalkRelay talk realtime microphone failed: Realtime audio input fell behind. Reconnecting…
    +7.953  macOS   talk.runtime      talk realtime terminated=audioInputFailed(…)
    +9.953  gateway talk              talk event session.closed
    +9.981  gateway ws                res ✓ talk.session.close 906ms
    +31.983 gateway diagnostic        session state: prev=processing new=idle reason="run_completed"
    +31.998 gateway agent             embedded run done: durationMs=31906 aborted=false
    # chat.history: assistant article (1943 characters) at +32 s
    
    # This PR, explicit Stop
    +0.000  gateway talk              talk event transcript.done
    +0.107  gateway diagnostic        lane enqueue: lane=talk queueSize=1
    +1.033  gateway diagnostic        run registered: totalActive=1
    +1.797  macOS   talk.controller   talk enabled=false
    +2.747  gateway agent             codex app-server model call diagnostic ended with error: codex app-server attempt interrupted
    +2.768  gateway diagnostic        lane task error: lane=talk durationMs=2661 error="agent run aborted"
    +3.631  gateway talk              talk event session.closed
    +3.668  gateway ws                res ✓ talk.session.close 987ms
    # chat.history: only the realtime voice line "Mm, sure. I'll check that request."
    
    # Base, failure close (Gateway paused +2.854 to +9.061)
    +0.000  gateway talk              talk event transcript.done
    +0.078  gateway diagnostic        lane enqueue: lane=talk queueSize=1
    +1.152  gateway diagnostic        run registered: totalActive=1
    +7.904  macOS   RealtimeTalkRelay talk realtime microphone failed: Realtime audio input fell behind. Reconnecting…
    +8.159  macOS   talk.runtime      talk realtime terminated=audioInputFailed(…)
    +9.312  gateway agent             codex app-server model call diagnostic ended with error: codex app-server attempt interrupted
    +9.400  gateway diagnostic        lane task error: lane=talk durationMs=9322 error="agent run aborted"
    +10.126 gateway talk              talk event session.closed
    +10.149 gateway ws                res ✓ talk.session.close 903ms
    # chat.history: only the realtime voice line "Sure, I'll check that request."
    
  • New kit tests: relay failure detaches accepted work when the Gateway supports it (both capability states),
    explicit stop keeps the aborting close, and a failure detected by the owner detaches accepted work.
    swift test --filter RealtimeTalkRelaySession on macOS (Swift 6.4, Xcode 27): 65 tests in 7 suites passed (62 on the base).

  • macOS: capture failures close the old relay and start a replacement microphone (audio failure, selected
    microphone, unpause) now also asserts that the close carries disposition: "detach";
    swift test --package-path apps/macos --filter TalkModeRuntimeSpeechTests: 23 tests passed.

  • Negative controls: without the line that writes disposition, both kit detach tests fail and the macOS test fails for all three sources; with the macOS runtime back on stop(),
    the macOS test fails for all three sources. The pinned SwiftFormat and SwiftLint (--strict) report no issues in the changed Swift files.

  • pnpm native:i18n:verify, pnpm native:i18n:check, pnpm apple:i18n:check, pnpm format:docs:check, and
    git diff --check pass.

  • With PR-2 also applied: the macOS app (swift build --package-path apps/macos --product OpenClaw) and the iOS app
    (scheme OpenClaw, iOS 27 simulator, including the project's SwiftFormat lint and strict SwiftLint phases) build;
    the focused iOS Talk suites pass.

  • End to end on macOS against a 2026.10.5 Gateway (no talk-session-close-disposition): the failure close passed the
    old Gateway's strict schema (the reply was Unknown Talk session, not INVALID_REQUEST), so no unknown field is
    sent to older Gateways.

  • Both macOS end-to-end setups used the debug binary with the microphone and speech usage strings embedded at
    link time (plain swift build output has no Info.plist) and a local one-word workaround for an unrelated
    crash when Speech Recognition permission is first requested; that crash will be reported separately.

Thanks @kybrcore for the repair, regression tests, and original macOS investigation. The original contributor commits are preserved.

Relay failure cleanup in the shared Apple kit closed with only a session id, so the
Gateway applied its default abort and cancelled the accepted consult. The audio-input,
playback and output-cancellation failure paths now send disposition "detach" when the
owning socket advertises talk-session-close-disposition; an explicit stop keeps the
aborting close, and older Gateways keep the legacy close.

Part of openclaw#180426
@clawsweeper

clawsweeper Bot commented Oct 22, 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 docs Improvements or additions to documentation app: ios App: ios app: macos App: macos gateway Gateway runtime size: S labels Oct 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Apple realtime Talk failure cleanup preserves accepted agent work on capable Gateways while explicit Stop continues to cancel it.

Example: A macOS Talk microphone failure occurs while the agent writes a requested 1500-word article.

  • Before: Failure cleanup aborts the consult and no article reaches chat.
  • After: The relay closes with detach and the article reaches chat; explicit Stop still aborts.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong live regression evidence supports a focused shared-owner repair; required current-head CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The contributor exercised the macOS app against an official capable Gateway image: failure cleanup preserved the accepted answer, explicit Stop aborted, and the base failure aborted. Older-Gateway output showed schema acceptance. Source comparison preserves the demonstrated close behavior after consolidation and the separately merged input-budget repair; iOS live detachment is not claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A realtime audio failure cancels an accepted question instead of allowing its answer to appear in chat.
Reason: The patch addresses the remaining failure-close defect using the established detach protocol; the separate stall repair is already on main.

Merge readiness

✅ Ready for maintainer review

Keep this PR: current main still cancels accepted agent answers during Apple relay failure cleanup, and this focused repair addresses that defect without actionable findings.

Priority: P1
Reviewed head: ec39b6629e7fd42a01f935c743c321c930e13a06

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared Apple relay manages microphone, playback, and Talk lifecycle events; platform transports bind its RPCs and capability checks to the originating Gateway connection.

flowchart LR
  A[Apple Talk app] --> B[Shared relay session]
  B --> C[Route bound transport]
  C --> D[Gateway Talk close]
  D --> E[Accepted agent consult]
  E --> F[Conversation history]
Loading

Technical review

Best possible solution:

Land the shared capability-gated failure close after required CI completes, preserving explicit Stop and older-Gateway behavior.

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

Current-main source establishes the failure-close-to-abort path, and the contributor supplied a real macOS base/head comparison; this review executed no target code.

Is this the best way to solve the issue?

The patch fixes disposition at the existing shared teardown owner, retains connection-bound capability checks, and avoids duplicating platform policy.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared Apple failure teardown changes intended behavior with a stated reason (057ed79: Centralize bounded Apple relay cleanup and retire stale microphone and playback work.)
  • Acknowledged server close keeps the original intent (c4a6c17: Voice replacement waits for finalized transcripts and the source close acknowledgement.)
  • macOS runtime termination changes intended behavior with a stated reason (000db97: Close runtime-owned failed relays before bounded recovery starts a replacement.)
  • Documented failure-close contract keeps the original intent (420ea0b: Document capability-gated detach for accepted work while retaining default abort and older-Gateway compatibility.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 000db97 adds apps/macos/Sources/OpenClaw/TalkModeRuntime+Realtime.swift:566 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 000db97c8252; files: apps/macos/Sources/OpenClaw/TalkModeRuntime+Realtime.swift)

PR surface

Source +24, Tests +42, Docs 0. Total +66 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 37 13 +24
Tests 2 47 5 +42
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 85 19 +66

Review metrics

Metric Value Why it matters
Production versus test changes Production +37/-13; tests +47/-5 Growth supports the existing close owner, connection-scoped capability negotiation, and distinct failure, legacy-Gateway, and explicit-Stop contracts.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #180426
Summary: This PR repairs failure-close cancellation remaining after the separate microphone-budget repair.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: An actual Apple Talk failure can cancel an accepted agent workflow and prevent its answer from reaching the conversation.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-22T12:01:34.887Z sha 492bad4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-23T01:53:23.464Z sha 5d96d87 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-23T03:48:20.117Z sha 5d96d87 :: needs maintainer review before merge. :: none

Reviewed October 24, 2026, 7:59 AM ET / 11:59 UTC (Revision 4).

…start

The macOS Talk runtime ends the relay itself when the microphone cannot restart after a
pause, an input device change, or an audio failure it detects, and that close still
aborted accepted agent work. It now calls the kit's new stopAfterFailure(), which closes
with disposition "detach" on capable Gateways like the session's own failure cleanup.
Also corrects the close comment: a failed detach close is covered by the Gateway only
once the socket drops.
@kybrcore

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@kybrcore

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Oct 23, 2026
@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 23, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 24, 2026
@steipete
steipete merged commit 70e203e into openclaw:main Oct 24, 2026
101 of 102 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…r in progress (openclaw#180571)

Detach supported Apple realtime Talk sessions after failure so accepted agent answers can finish. Read the close-disposition capability from the owning route or lease and retain the existing abort behavior for explicit Stop and older Gateways.

Share the failure-close owner across microphone, playback, and output-cancellation failures; cover capability states, explicit Stop, and macOS microphone recovery.

Related: openclaw#180426, openclaw#171310, openclaw#172275

Co-authored-by: kybrcore <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
* fix(apple): keep realtime Talk through a slow Gateway

The shared Apple kit ended relay Talk once 48 microphone appends were waiting (about
2 s) or any append took longer than 8 s. Bound in-flight audio by time (3 s) instead,
admit frames before their send task starts, drop frames over the budget with one
notice and one recovery notice, and treat an append unanswered for 30 s as the
liveness failure, matching browser relay Talk. The kit sends the notices as status
keys; iOS localizes them and keeps the call in the listening phase.

Closes #180426

* test(apple): pin the realtime append deadline instead of simulating a stall

Release adaptation: stable's realtime-sessions doc lacks the browser relay paragraph, so only an Apple-specific paragraph was added. The later #180571 (detach Talk failures from agent answers) is a separate capability-gated feature, not a regression fix, and was not included.

(cherry picked from commit f85897e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: macos App: macos docs Improvements or additions to documentation gateway Gateway runtime 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: S 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.

2 participants