Skip to content

fix(voice-call): honor routed agent credentials for realtime calls - #125144

Merged
steipete merged 3 commits into
mainfrom
steipete/gallant-nightingale-8950c1
Aug 17, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/gallant-nightingale-8950c1

Conversation

@steipete

@steipete steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125111 (comment)

What Problem This Solves

Fixes an issue where realtime phone calls routed by inbound number to a non-default agent could fail before the call arrived, or retain a provider selected for the wrong agent, when realtime credentials were agent-scoped.

Why This Change Was Made

Realtime provider readiness and selection now happen after call registration, at the effective per-call route. The frozen call owner drives provider selection, normalized provider config, bridge authentication, capabilities, instructions, and interruption policy through one canonical registration; there is no fallback across agents. Provider-admission failure ends and hangs up an initial call visibly, while a failed replacement preserves its active predecessor.

The product repair is intentionally limited to the voice-call plugin lifecycle. It does not change config, protocol, SQLite, Plugin SDK, provider contracts, or the separate browser capability finding from #125111.

The branch also includes one behavior-neutral repair for a red main gate encountered during landing: a generated Node-version expression was exported with an OPENCLAW_-prefixed constant name and was therefore miscounted as a new environment variable. Renaming that internal export restores the 501/501 env-var budget without changing its generated bootstrap expression or raising a baseline.

User Impact

Operators can route different phone numbers to agents that own different OpenAI or xAI realtime credentials. The plugin can start even when the top-level default agent has no realtime credentials, and a misconfigured routed agent now fails only its call instead of blocking the whole voice-call runtime or using another agent's provider selection.

Evidence

Pre-fix regression:

  • node scripts/run-vitest.mjs extensions/voice-call/src/runtime.test.ts -t "selects realtime provider readiness from the routed call owner" failed during runtime startup because readiness resolved agentId: main, producing OpenAI realtime is not configured for main before the routed call existed.

Post-fix proof:

  • node scripts/run-vitest.mjs extensions/voice-call/src/runtime.realtime-routing.test.ts extensions/voice-call/src/runtime.test.ts extensions/voice-call/src/webhook/realtime-handler.test.ts extensions/voice-call/src/webhook/realtime-handler.lifecycle.test.ts extensions/voice-call/src/manager/events.inbound.test.ts src/talk/provider-resolver.test.ts — 93 tests passed across 2 shards.
  • pnpm test extensions/voice-call — 649 tests passed across 61 files.
  • node scripts/check-changed.mjs -- <10 changed paths> — passed the fail-safe all-lanes plan: env-var/max-lines/assertion ratchets, formatting, doctor/plugin boundaries, dead exports, temp-dir ownership, script erasability, database-first and sidecar guards, full core/UI/extension/script/root-test typechecks, full lint, and import cycles.
  • pnpm ui:build on the rebased head — passed at 337,983 startup-JS gzip bytes, 584 bytes below the unchanged 338,567-byte limit. No UI or performance-baseline edit was needed.
  • node scripts/run-vitest.mjs src/gateway/worker-environments/bootstrap.test.ts test/openclaw-launcher-version.e2e.test.ts src/infra/runtime-guard.test.ts — 72 tests passed; the E2E lane rebuilt the current dist successfully.
  • node --import tsx scripts/check-env-var-count.mts --base origin/main — 501/501 after the internal export rename; before the repair, current main reported 502/501.
  • Source-blind behavior run: pnpm test extensions/voice-call/src/runtime.realtime-routing.test.ts -- --reporter=verbose — runtime started with no default-agent resolution, then two real loopback carrier WebSocket streams created the sales/OpenAI and support/xAI bridges and closed with no active calls.
  • Fresh Codex autoreviews (--max-priority P1) — clean for both the voice owner-boundary repair and the final main-gate/test-cleanup changes; no accepted/actionable findings.

Proof gap: no external carrier number or live OpenAI/xAI credentials were available for this task, so no real telephone call was placed. The regression uses real runtime, manager, call registration, stream tokens, loopback WebSockets, and bridge connections with simulated agent-scoped credentials.

Production LOC: +93/-89 (net +4). Tests: +480/-57 (net +423).

AI-assisted: yes. The implementation was independently reviewed and the observable route behavior was validated against the contract above.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call size: L maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 07:27
@steipete steipete closed this Aug 17, 2026
@steipete steipete reopened this Aug 17, 2026
@steipete
steipete marked this pull request as draft August 17, 2026 07:36
@steipete
steipete marked this pull request as ready for review August 17, 2026 07:36
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 4:33 AM ET / 08:33 UTC.

ClawSweeper review

What this changes

Moves voice-call realtime provider selection from plugin startup to per-call registration so inbound number routes use their selected agent’s credentials, plus renames an internal Node-version export.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No blocking source defect found. Current main still resolves realtime credentials at plugin startup before an inbound route exists; this branch moves that decision to the frozen call owner. The protected maintainer label and incomplete exact-head checks require maintainer handling before merge.

Priority: P1
Reviewed head: 6c685a2590007e62fb65bcc56edbc13b69ee034e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is a focused owner-boundary repair with substantial lifecycle coverage, while live carrier/provider confirmation remains unavailable.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This is a maintainer-authored and maintainer-labeled PR, so the external-contributor proof gate does not apply; its body nonetheless supplies loopback runtime evidence and states the missing live carrier/provider proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored and maintainer-labeled PR, so the external-contributor proof gate does not apply; its body nonetheless supplies loopback runtime evidence and states the missing live carrier/provider proof.
Evidence reviewed 8 items Current-main failure point: Current main resolves the realtime provider during runtime construction with config.agentId, before an inbound call can carry its routed agent.
Proposed owner-boundary repair: The branch resolves the effective route, preserves the call’s agentId, and passes that agent to the shared realtime provider resolver at registration time.
Frozen-agent invariant: The call helper explicitly prefers the stored call agent over configuration, preserving one owner for the full call.
Findings None None.
Security None None.

How this fits together

The voice-call plugin receives a carrier stream, creates a call record from its inbound route, then opens a realtime provider bridge. Agent identity, provider readiness, credentials, instructions, and bridge behavior must all use that same call owner.

flowchart LR
  Carrier[Carrier stream] --> Route[Inbound number route]
  Route --> Call[Register call]
  Call --> Owner[Freeze routed agent]
  Owner --> Provider[Resolve realtime provider and credentials]
  Provider --> Bridge[Create voice bridge]
  Bridge --> Result[Connected call or visible hangup]
Loading

Decision needed

Question Recommendation
After exact-head checks are green, should this maintainer-owned voice-call repair be accepted with its loopback owner-boundary proof despite the stated absence of live carrier and provider credentials? Accept bounded proof after CI: Accept the focused runtime, lifecycle, and loopback coverage once exact-head required checks are green.

Why: The protected maintainer label requires explicit handling, and only a maintainer can decide whether the documented external-service proof gap is acceptable for this credential-routing change.

Before merge

  • Resolve merge risk (P1) - Provider admission now occurs per carrier stream rather than at startup; exact-head checks should confirm default-agent and routed-agent configurations both retain their intended behavior.
  • Resolve merge risk (P1) - The bug fix has a production delta of +92/-88 (net +4); the remaining growth is the explicit per-call registration and admission-failure transition, with no evident net-neutral absorption that preserves that ownership boundary.
  • Resolve merge risk (P1) - No live carrier/OpenAI/xAI call is supplied; the PR’s loopback runtime proof covers the owner boundary but cannot prove external carrier/provider behavior.
Agent review details

Security

None.

PR surface

Source +4, Tests +423, Other 0. Total +427 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 3 91 87 +4
Tests 5 480 57 +423
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 2 0
Total 10 573 146 +427

Review metrics

Metric Value Why it matters
Production versus test LOC production +92/-88 (net +4); tests +480/-57 (net +423) The small production increase consolidates per-call provider admission and failure handling; most change is regression and lifecycle coverage.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/voice-call/src/webhook/realtime-handler.lifecycle.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm exact-head route coverage (recommended)
    Wait for exact-head checks, then accept the focused owner-boundary evidence for existing default-agent and routed-agent setups.
  2. Require live carrier validation
    Require a redacted real carrier/provider call if maintainers want external-service confirmation beyond the loopback stream harness.

Technical review

Best possible solution:

Keep one registration closure at the call-lifecycle owner, accept its narrow net +4 production growth for explicit admission handling, and merge only after exact-head CI and maintainer acceptance of the stated live-proof gap.

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

Yes, source-reproducible with high confidence: current main resolves credentials from the configured default before an inbound call has a routed agent, while the focused loopback test models two routed owners. This read-only review did not run the test.

Is this the best way to solve the issue?

Yes. Resolving the shared provider contract at the frozen call-registration boundary is preferable to retaining startup-time default-agent selection or adding a fallback across agents.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: A routed agent can fail to connect a realtime phone call when credentials are selected from the default agent.
  • merge-risk: 🚨 compatibility: Existing voice-call configurations move provider readiness from runtime startup to carrier-stream admission.
  • merge-risk: 🚨 auth-provider: The branch changes the agent scope used for realtime provider configuration and credential readiness.
  • 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: This is a maintainer-authored and maintainer-labeled PR, so the external-contributor proof gate does not apply; its body nonetheless supplies loopback runtime evidence and states the missing live carrier/provider proof.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged routed-agent realtime work and the current follow-up; history shows repeated ownership of the voice-call and realtime paths. (role: recent area contributor; confidence: high; commits: 73ab74ecccdc, eb76bf499b39; files: extensions/voice-call/src/runtime.ts, extensions/voice-call/src/webhook/realtime-handler.ts)
  • Vincent Koc: Recent handler history contains the replacement-bridge and transcript-ownership lifecycle work this patch preserves. (role: historical lifecycle contributor; confidence: high; commits: b65d010408f2, b738c6e2d946; files: extensions/voice-call/src/webhook/realtime-handler.ts)

Rank-up moves

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

  • Let exact-head required checks complete.
  • Have a maintainer decide whether the documented loopback proof is sufficient for this carrier/provider integration.

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 (1 earlier review cycle)
  • reviewed 2026-08-17T07:45:00.823Z sha 7aa5ca4 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/gallant-nightingale-8950c1 branch from 7aa5ca4 to 6c685a2 Compare August 17, 2026 08:26
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 6c685a2590007e62fb65bcc56edbc13b69ee034e:

  • Exact-head CI run 32010422800, attempt 2 is green. Attempt 1 failed only while GitHub codeload returned HTTP 429 during Set up job; the failed jobs were safely rerun on the same head. scripts/watch-pr-ci.mjs reports GREEN.
  • Native review artifacts validate as READY FOR /prepare-pr with zero findings. OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125144 passed using verified hosted exact-head/Testbox evidence (hosted_exact_or_recent_parent), and the prep, local, remote PR, and verified gate SHAs all equal the head above.
  • Focused post-rebase voice proof: 70 passed. Full owner/sibling proof: 93 passed. Full voice-call plugin: 649 passed.
  • Gateway/Node-version/bootstrap/launcher/runtime proof: 72 passed. Focused final bootstrap+routing proof: 37 passed.
  • node scripts/check-changed.mjs -- <10 paths> passed its fail-safe all-lanes plan, including environment count 501/501 and canonical temp-directory cleanup with no warnings. pnpm ui:build passed at 337,983 startup-JS gzip bytes, 584 bytes below the unchanged limit.
  • Source-blind loopback behavior passed: two carrier WebSocket streams routed sales to OpenAI and support to xAI, created the correct bridges, and closed with no active calls. Fresh P0/P1 autoreviews were clean; the exact-head ClawSweeper review found no actionable source defect.
  • Cumulative LOC: production +93/-89 (net +4); tests +480/-57 (net +423). The final env-count repair only renames an internal generated Node-version export and does not change its bootstrap expression or any baseline.

Known gap: no external carrier number or live OpenAI/xAI credentials were available, so no real telephone call was placed. The loopback proof covers the runtime, manager, call registration, stream-token, and bridge ownership boundary; it is not external-live proof.

@steipete
steipete merged commit 5275eae into main Aug 17, 2026
364 of 384 checks passed
@steipete
steipete deleted the steipete/gallant-nightingale-8950c1 branch August 17, 2026 08:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
…penclaw#125144)

* fix(voice-call): select realtime provider per routed call

* test(voice-call): track routing temp directory

* fix(ci): stop counting node check as environment variable
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 maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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