Repository navigation
fix(apple): a realtime Talk failure no longer cancels the agent answer in progress - #180571
Conversation
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
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesApple 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +24, Tests +42, Docs 0. Total +66 across 8 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)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.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…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]>
* 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)
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 defaultabort. Control UI (#171377) and the Android phone app (#172276) already detach on failure. The kit's three failurepaths now send
disposition: "detach"when the socket that owns the relay advertises the capability;stop()keeps theaborting 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
beginServerClose: omittingdispositionstill selects Gateway abort. The merged microphone-budget repair does not change that owner.stopAfterFailureowner.--strict) checked all seven with zero violations. Diff checks pass; no localized strings changed.macos-swiftexecution remains the limitation described above.ec39b6629e7fd42a01f935c743c321c930e13a06integrates main21f0262a8883e02054ca05e9509a7249e470cb64; its diff matches the reviewed patch exactly.Contributor evidence at original head
5d96d87cabcd9383a097c4c71704f87f869e661cThe 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.3image, 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 ofagent 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 behindand closed the relay through the kit's failure path.audioInputFailed)aborted=falseagent run abortedabout 70 ms after the close reached the GatewayaudioInputFailed)agent run abortedabout 70 ms after the close reached the GatewayThe Gateway does not log the close disposition; the tests below pin what the kit sends, and only the PR binary
contains the
detachliteral. 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)
New kit tests:
relay failure detaches accepted work when the Gateway supports it(both capability states),explicit stop keeps the aborting close, anda failure detected by the owner detaches accepted work.swift test --filter RealtimeTalkRelaySessionon 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, selectedmicrophone, 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 onstop(),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, andgit diff --checkpass.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 theold Gateway's strict schema (the reply was
Unknown Talk session, notINVALID_REQUEST), so no unknown field issent 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 buildoutput has no Info.plist) and a local one-word workaround for an unrelatedcrash 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.