Skip to content

fix(voice-call): native-delegation realtime calls cannot hang up or open cleanly - #165715

Merged
mbelinky merged 1 commit into
mainfrom
fix/voice-call-realtime-call-control
Oct 6, 2026
Merged

mbelinky merged 1 commit into
mainfrom
fix/voice-call-realtime-call-control

Conversation

@mbelinky

@mbelinky mbelinky commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: on realtime phone calls with a voice model that uses native agent delegation (GPT-Live over ChatGPT OAuth), the call cannot hang up and the outbound opening line is spoken over the callee with an improvised prefix, because that model cannot call the end-call or custom tools the voice-call plugin relies on.

User Impact

User impact: operators on the subscription (OAuth) voice route get calls that end on their own after silence, an opening line that is spoken verbatim once the callee has answered, and hang-up through the OpenClaw agent, limited to the current call. In-call key presses (DTMF) are deliberately out of scope here; they will come in a separate PR once delivery to a real IVR is proven.

  • New optional realtime.idleHangupMs (unset keeps today's behaviour). Hold music is not speech, so pick a value longer than expected holds.

  • Outbound realtime calls on native-delegation models now wait for callee speech (3 s silent-pickup fallback) before the opening line. Function-tool providers and inbound calls keep the current greeting behaviour.

  • The realtime consult agent gets voice_call bound to the active call; only end_call for that call is accepted, and the service registration is revalidated at the hang-up effect. Other actions, foreign call ids, ended calls, and retired registrations are rejected before any carrier effect.

  • Config surface: plugin budget 4490 → 4491 for the single optional realtime.idleHangupMs key (off by default); there is no existing setting that expresses a host-side speech-idle limit.

  • Speech-idle activity follows what is actually heard: every audible inbound caller frame, and every audible assistant frame when the pacer plays it out to the carrier (not when the provider delivers it), so neither a long caller nor buffered assistant playback is cut off.

Why This Change Was Made

Native-delegation models expose no tool surface to the voice bridge, so call control has to live on the host (idle timer, verbatim greeting) and in the consult agent (scoped voice_call). Live testing also showed two defects that the same path hit: far-side speech cancelled the consult even when nothing was playing (phone menus repeat their prompt), and a tool run could activate a stale plugin registration, which retired the running voice-call runtime mid-call and left voicecall.initiate failing with "runtime generation was superseded". Both are fixed here.

Evidence

  • Focused suites (--maxWorkers=1): realtime-call-control.test.ts + realtime-handler.test.ts 81 passed; index.lifecycle, index.call-scope, command-service, realtime-call-session-control, telephony-audio, runtime, config, agent-consult-runtime all green (see per-file timings in the diff description).

  • Live calls (Twilio, GPT-Live gpt-live-1-codex via OAuth, test gateway on this branch): opening line spoken verbatim only after the callee spoke; speech-idle hang-up ended a finished call with endReason=timeout 10 s after the last words; after the model-output RMS gate, continuous paced audio no longer counts as speech.

  • Authority proof (index.call-scope.test.ts, through the registered tool and a real CallManager, spying on the carrier provider's hangupCall): bound end_call reaches manager.endCall exactly once; foreign ids, other actions, ended calls, and retired/replaced registrations are rejected with no effect; a hang-up admitted before consult cancellation completes once.

  • Owner phone round on this branch (Twilio, GPT-Live, mobile): opening waited for the callee and was verbatim; silent pickup started after the fallback; speech-idle hang-up ended the call.

  • oxfmt, git diff --check, line-cap and max-lines ratchets pass. tsc -p tsconfig.extensions.json reports no diagnostics in touched files (80 pre-existing elsewhere). Targeted oxlint could not run locally: its prepare-extension-package-boundary-artifacts prerequisite timed out.

  • CI: the only red check, check-test-types-core-4, fails in src/flows/doctor-health.migration-refusal.test.ts, which this PR does not touch (inherited from main). The full voice-call suite on this head passes: 52 files, 632 tests.

Notes for reviewers
  • realtime-call-session-control.ts holds the greeting and speech-idle controllers; tool-call-scope.ts holds the consult-scoped tool guard.
  • Model output below a mu-law RMS of 0.035 is treated as silence for idle tracking; GPT-Live's paced output stream includes silent frames.
  • The consult agent receives the other party's words as the delegated request (that is how native delegation works), so it is prompted to act on the transcript: press the key a menu asks for, and hang up when both sides have said goodbye.

🤖 Generated with Claude Code

https://claude.ai/code/session_017KYf18XrvyNu6uCLG874jq

@clawsweeper

clawsweeper Bot commented Oct 5, 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 channel: voice-call Channel integration: voice-call size: XL labels Oct 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 6, 2026, 3:08 AM ET / 07:08 UTC (Revision 12).

ClawSweeper review

What this changes

The voice-call plugin adds call-scoped delegated hang-up, optional speech-idle termination, delayed verbatim outbound greetings, and service-lifecycle repairs.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR remains useful: current main still lacks delegated hang-up and delayed native-delegation greetings. No blocking code defect was identified, but the previous request for real delegated hang-up evidence remains unresolved.

Priority: P2
Reviewed head: 80f3b82866c0ce551f6922dc2c49354cbd325bfc

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has useful boundary coverage and no identified blocking defect, but real evidence does not yet cover delegated carrier hang-up.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 10 items Pinned introduction: Reviewed the introduced delta from cd060c5 to 80f3b82. The checkout matches the verified original PR head; base drift was not attributed to the contributor.
Still necessary on current main: Fetched main still describes native delegation as unable to invoke end-call controls and triggers initial greetings immediately. Its consult runtime lacks the new active-call tool binding.
Authority and effect boundary: The binding rejects foreign call IDs and every action except end_call, checks cancellation before admission, and verifies the call is active. The command service rechecks service authority after awaited lookup; the initialized manager then invokes the carrier hang-up operation without an intervening await.
Findings None None.
Security None None.

How this fits together

The voice-call plugin connects carrier phone calls to realtime voice providers and delegates selected requests to the OpenClaw agent. It manages audio playback, conversation transcripts, and carrier call termination.

flowchart TD
  A[Carrier phone call] --> B[Realtime voice bridge]
  B --> C[Greeting and speech activity controls]
  B --> D[Delegated OpenClaw agent]
  D --> E[Active call and service authority guard]
  E --> F[Call manager]
  C --> F
  F --> G[Carrier hang-up]
Loading

Before merge

  • Complete next step (P2) - Provide after-fix evidence showing native delegation invoking end_call and terminating the real carrier call. Redacted logs, terminal output, or a recording with diagnostics count; screenshots or video are preferred when they show the behavior. Remove credentials, phone numbers, IP addresses, and private endpoints. Updating the PR body should trigger automatic re-review; otherwise ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

PR surface

Source +354, Tests +901, Docs +13, Generated 0. Total +1268 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 11 724 370 +354
Tests 9 909 8 +901
Docs 2 23 10 +13
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 24 1659 391 +1268

Review metrics

Metric Value Why it matters
Configuration surface 1 optional setting, disabled when unset Speech-idle termination introduces an explicit operator choice while preserving existing configurations.
Production versus regression coverage Production TypeScript net +345 lines; tests net +900 lines Production growth is explained by call-scope enforcement and extracted session controllers, with regression coverage concentrated on lifecycle and audio timing.

Technical review

Best possible solution:

Keep call control with the existing service and CallManager, with delegated authority restricted to ending the active call and silence termination remaining opt-in.

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

Yes, source establishes the affected path: native-delegation providers receive no function tools, and current main supplies no call-scoped hang-up binding. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes, the repair reuses existing tool bindings and the service-owned CallManager rather than creating competing call control. The optional idle setting also preserves the existing default.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 48b40f4909f6.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded realtime phone-call workflow without evidence of an urgent broad regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

  • Pinned introduction: Reviewed the introduced delta from cd060c5 to 80f3b82. The checkout matches the verified original PR head; base drift was not attributed to the contributor. (80f3b82866c0)
  • Still necessary on current main: Fetched main still describes native delegation as unable to invoke end-call controls and triggers initial greetings immediately. Its consult runtime lacks the new active-call tool binding. (extensions/voice-call/src/webhook/realtime-handler.ts:972, 48b40f4909f6)
  • Authority and effect boundary: The binding rejects foreign call IDs and every action except end_call, checks cancellation before admission, and verifies the call is active. The command service rechecks service authority after awaited lookup; the initialized manager then invokes the carrier hang-up operation without an intervening await. (extensions/voice-call/src/tool-call-scope.ts:27, 80f3b82866c0)
  • Meaningful authority regression coverage: The registered-tool tests use a real CallManager with a FakeProvider and cover allowed hang-up, foreign IDs, cancellation, retirement, and service replacement during lookup. This supports the guard's correctness but does not demonstrate native delegation terminating a real carrier call. (extensions/voice-call/index.call-scope.test.ts:168, 80f3b82866c0)
  • Captured live evidence and remaining coverage: The supplied PR body reports after-fix Twilio calls showing verbatim greetings, silent-pickup fallback, and speech-idle termination. Neither that account nor the supplied discussion describes native delegation invoking end_call and observing carrier termination. The previous completed review requested that specific evidence. (80f3b82866c0)
  • Author-association discrepancy: The repository-state header says MEMBER, while both supplied GitHub endpoint context and a live GitHub read report CONTRIBUTOR for the unchanged pinned head. The verified endpoint association was used for the external-contributor proof assessment. (80f3b82866c0)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted runtime trace showing native delegation invoking end_call and the actual carrier call terminating.

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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-05T21:25:46.607Z sha f83dcb9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-05T22:31:57.488Z sha 107aec6a8320b0d15c0b33a5079b4bc3ea03b527 :: needs real behavior proof before merge. :: [P2] [P2] Refresh idle activity throughout sustained caller speech
  • reviewed 2026-10-05T23:24:31.376Z sha eb62f51 :: needs real behavior proof before merge. :: [P2] [P2] Refresh idle activity throughout sustained caller speech
  • reviewed 2026-10-06T00:57:14.470Z sha 56eb6da4a30f7a103a706476cfcc0103a2ce266b :: blocked before merge. :: [P2] Refresh assistant idle activity during paced playback
  • reviewed 2026-10-06T02:34:11.028Z sha ac65199 :: blocked before merge. :: none
  • reviewed 2026-10-06T03:55:51.999Z sha fc73e0b :: needs changes before merge. :: none
  • reviewed 2026-10-06T04:17:22.523Z sha fc73e0b :: needs changes before merge. :: none
  • reviewed 2026-10-06T06:58:50.960Z sha bf0a8d40a8719433e84868dc1aea76a81ba6c4ec :: needs changes before merge. :: none

@mbelinky
mbelinky force-pushed the fix/voice-call-realtime-call-control branch 3 times, most recently from 5a37d55 to f83dcb9 Compare October 5, 2026 21:13
@mbelinky mbelinky changed the title fix(voice-call): realtime calls cannot hang up, press keys, or open cleanly on native-delegation voice models fix(voice-call): native-delegation realtime calls cannot hang up or open cleanly Oct 5, 2026
@mbelinky
mbelinky force-pushed the fix/voice-call-realtime-call-control branch 3 times, most recently from eb62f51 to 56eb6da Compare October 6, 2026 00:50
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 6, 2026
@mbelinky
mbelinky force-pushed the fix/voice-call-realtime-call-control branch from 56eb6da to ac65199 Compare October 6, 2026 02:27
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 6, 2026
@mbelinky
mbelinky force-pushed the fix/voice-call-realtime-call-control branch 2 times, most recently from fc73e0b to bf0a8d4 Compare October 6, 2026 06:52
…pen cleanly

Realtime voice models that use native agent delegation (GPT-Live) cannot
call the end-call tool or any custom tool, so outbound calls could not
hang up, and the opening line was spoken over the callee with an
improvised prefix.

- Add optional realtime.idleHangupMs: the host ends the call when neither
  side has spoken for that long; in-flight consults pause the timer, and
  silent paced model frames do not count as speech.
- Outbound calls speak the initial message verbatim and only after the
  callee first speaks, with a 3 s fallback for silent pickups/voicemail.
- Realtime consults get voice_call bound to the active call through
  trusted tool bindings; only end_call for that call is allowed, and the
  service registration is revalidated at the hang-up effect. Other
  actions, foreign call ids, ended calls, and retired registrations are
  rejected before any carrier effect.
- Far-side speech while no model audio plays no longer cancels an
  in-flight consult, and a stale plugin registration can no longer retire
  the running voice-call runtime mid-call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017KYf18XrvyNu6uCLG874jq
@mbelinky
mbelinky force-pushed the fix/voice-call-realtime-call-control branch from bf0a8d4 to 80f3b82 Compare October 6, 2026 07:02
@mbelinky
mbelinky merged commit e5c50c9 into main Oct 6, 2026
121 checks passed
@mbelinky
mbelinky deleted the fix/voice-call-realtime-call-control branch October 6, 2026 07:21
@mbelinky

mbelinky commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…pen cleanly (openclaw#165715)

Realtime voice models that use native agent delegation (GPT-Live) cannot
call the end-call tool or any custom tool, so outbound calls could not
hang up, and the opening line was spoken over the callee with an
improvised prefix.

- Add optional realtime.idleHangupMs: the host ends the call when neither
  side has spoken for that long; in-flight consults pause the timer, and
  silent paced model frames do not count as speech.
- Outbound calls speak the initial message verbatim and only after the
  callee first speaks, with a 3 s fallback for silent pickups/voicemail.
- Realtime consults get voice_call bound to the active call through
  trusted tool bindings; only end_call for that call is allowed, and the
  service registration is revalidated at the hang-up effect. Other
  actions, foreign call ids, ended calls, and retired registrations are
  rejected before any carrier effect.
- Far-side speech while no model audio plays no longer cancels an
  in-flight consult, and a stale plugin registration can no longer retire
  the running voice-call runtime mid-call.


Claude-Session: https://claude.ai/code/session_017KYf18XrvyNu6uCLG874jq

Co-authored-by: mbelinky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: voice-call Channel integration: voice-call docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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