Skip to content

fix(xai): preserve terminal realtime voice outcomes - #117600

Merged
vincentkoc merged 6 commits into
mainfrom
fix/xai-terminal-realtime-outcomes-20260801
Aug 1, 2026
Merged

vincentkoc merged 6 commits into
mainfrom
fix/xai-terminal-realtime-outcomes-20260801

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Related: #116201

Supersedes the uneditable contributor branch in #117186 while preserving its commit and authorship in this PR's ancestry.

AI-assisted maintainer preparation; the implementation, provider contract, and live proof were reviewed directly.

What Problem This Solves

Fixes an issue where users using xAI realtime voice could lose assistant transcripts present only in the terminal response, receive no actionable explanation for failed or incomplete turns, or silently miss a completed tool call carried by the terminal response.

Why This Change Was Made

The xAI event owner now consumes terminal response status and output as the authoritative outcome, reports failed and incomplete responses, and recovers completed terminal tool calls exactly once. Documented response.function_call_arguments.done execution remains immediate so tool results can continue the response.

The original PR cannot be amended because maintainerCanModify=false. Its completedResponseToolItems fallback also retained every full response.output_item.done tool item, including arbitrary argument bytes, until terminal/reset; if the terminal event never arrived, retained count and bytes were unbounded. This maintainer branch preserves the contributor commit as an ancestor, removes that cache, ignores non-authoritative output-item completion, and relies on response.done.output, which the provider contract and live xAI trace confirm contains the completed function call.

User Impact

  • Final-only xAI assistant transcripts remain visible.
  • Failed and incomplete turns report their terminal provider outcome.
  • Completed terminal tool calls execute once without accumulating output-item payloads.
  • Existing immediate tool execution, resumed replay, cancellation, reconnect, and audio behavior remain unchanged.

Evidence

  • Current-main package:
    • Base: 81e392b7ff43bcdb7a3be50a99adf65c3b0141b5.
    • Head: 78abe81a0bbae44d5d41fbb2913f3a1c03b17e51.
    • Head parents: repaired branch 186f2df134677d5e9e1dabaf4d39e7faf5ac3326, current main 81e392b7ff43bcdb7a3be50a99adf65c3b0141b5.
    • Original contributor head a02cc5c8495316bc1b05df9d24d836edbca74917 is an ancestor.
    • Signed maintainer merge and repair commits verified.
  • Zero-overlap proof:
    • Current main changed none of the four xAI paths since frozen base 1e9a1405206d31a68c40c5517f1974eb3bef93cb.
    • The three existing source blobs are byte-identical between that frozen base and current main; the new test is absent from both.
    • All four repaired blobs are byte-identical between repaired head 186f2df134677d5e9e1dabaf4d39e7faf5ac3326 and final head 78abe81a0bbae44d5d41fbb2913f3a1c03b17e51.
  • Patch identity:
    • Stable patch id: 7ee4aef6a1d572d7fea0bd580eddf23b019b4049.
    • Full-index binary diff SHA-256: 9f4908ad4a1519fdcfe3ca83852cee240e0a8a88584e431223b5c7da153f65be.
  • Live xAI proof:
  • Exact-head focused validation:
    • extensions/xai/realtime-voice-terminal-outcomes.test.ts: 15/15 passed.
    • extensions/xai/realtime-voice-provider.test.ts: 56/56 passed.
    • Extension production typecheck passed.
    • Extension test typecheck passed.
    • Scoped owner lint and git diff --check passed.
  • P1 autoreview reported no actionable findings, with 0.91 patch-correctness confidence. The current-main refresh had zero touched-path overlap and retained the exact reviewed patch.
  • ClawSweeper's durable review found no code or security findings; its sole merge blocker was real-provider proof. The live xAI run and terminal payload capture above satisfy that rank-up move.
  • Production delta: +56/-24, net +32; tests: +234. The production growth is the typed terminal outcome contract and owner logic. No provider, config, environment-variable, public SDK, protocol, storage, dependency, or docs surface changed.

ClawSweeper Disposition

  • Confirmed the deployed xAI terminal event shape with the sanitized live trace: completed function calls are present in response.done.output.

  • Preserved the documented immediate response.function_call_arguments.done path for response continuation; terminal output is recovery plus deduplication, not delayed primary dispatch.

  • Accepted the provider-local terminal owner as the narrow fix. The unbounded output-item cache from the source PR remains removed.

  • Hosted Opengrep flagged the local WebSocket test harness without maxPayload; the repaired signed head adds a 1 MiB cap. Its 15/15 terminal-outcome assertions and formatting/diff checks pass.

Peter Steinberger and others added 4 commits July 31, 2026 19:26
* origin/main: (325 commits)
  fix(skills): preserve profile in ClawHub command hints (#117555)
  fix(cli): explain filtered plugin policy without unsafe recovery (#117556)
  fix(irc): strip markdown from outbound text (#112961)
  refactor(plugins): consolidate registry snapshots (#117561)
  fix(plugins): fail blocked enable commands (#117536)
  test(secrets): dedupe runtime state fixtures (#117563)
  feat(gateway): advertise chat attachment limits on hello-ok (#116188)
  fix(ui): preserve full graphemes in session owner initials (#117350)
  refactor(tui): consolidate runtime ownership (#117368)
  fix(update): return failure when dirty checkout blocks update (#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (#117542)
  refactor(ui): unify channel status and setup controls (#117499)
  fix(doctor): preserve surviving lint selections (#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464)
  refactor(channels): consolidate lightweight plugin discovery (#117541)
  fix(imessage): prevent duplicate messages after delayed sends (#110853)
  refactor(memory): unify authoritative dreaming state and presentation (#117538)
  refactor(agents): consolidate main-session recovery ownership (#117383)
  fix(proxy-capture): make path-based session cleanup atomic (#98852)
  refactor(agents): consolidate compaction and context-engine ownership (#117482)
  ...

# Conflicts:
#	extensions/xai/realtime-voice-bridge.ts
* origin/main: (22 commits)
  refactor(ui): consolidate cron form control rendering (#117576)
  fix(memory): recover restored session freshness (#117548)
  fix(whatsapp): normalize future-proof QA poll and video note ingress (#117579)
  fix(perf): separate warm and first-device health probes (#117525)
  fix(ci): repair plugin prerelease validation (#117562)
  fix(tasks): sanitize every human task and flow detail (#117568)
  fix(feishu): cancel unread streaming-card error bodies before release (#117312)
  fix(status): honor explicit local RPC fallback timeouts (#117519)
  fix(ui): preserve Talk transcript surrogate bounds
  fix(tasks): validate notification policy before persistence (#117554)
  refactor: consolidate full release child workflows (#117385)
  refactor(policy): centralize doctor health-check descriptors (#117578)
  perf(gateway): mark recovery before model preparation (#117544)
  fix(ui): harden Talk transcript marker bounds
  test(openai): parse realtime websocket frames safely
  fix(openai): keep embedding identity stable across upgrades (#117557)
  fix(googlechat): drop invalid thread resource names before send (#108324)
  test(ui): cover bounded realtime Talk entries
  fix(ui): bound realtime Talk conversation text
  test(ui): cover reentrant Talk meter cleanup
  ...
@vincentkoc vincentkoc self-assigned this Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 4:07 PM ET / 20:07 UTC.

ClawSweeper review

What this changes

The PR updates xAI realtime voice so terminal provider responses supply final assistant transcripts, failed or incomplete outcomes, and completed tool calls without retaining output-item payloads.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This maintainer-authored PR remains necessary: current main still discards terminal xAI response output and status, while the branch adds the missing transcript, terminal-error, and recovered tool-call handling. The patch is coherent and proof-positive; it needs the normal maintainer merge decision after the current-base checks finish.

Priority: P1
Reviewed head: 78abe81a0bbae44d5d41fbb2913f3a1c03b17e51
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused provider-local repair with strong stated live-provider proof, exact-head focused validation, and no concrete correctness or security finding in this review.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides two linked real xAI runs and a sanitized terminal-response capture showing a completed function call in response.done.output, with a successful tool-result continuation; the supplied context marks that proof sufficient.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides two linked real xAI runs and a sanitized terminal-response capture showing a completed function call in response.done.output, with a successful tool-result continuation; the supplied context marks that proof sufficient.
Evidence reviewed 7 items Current-main gap: Current main handles response.done only by flushing the incremental transcript buffer and clearing response state; it does not inspect terminal status, status details, or terminal output items.
Proposed terminal owner: The PR reads terminal status and output, recovers completed function calls from terminal output, finalizes an assistant transcript from terminal message content, and reports failed or incomplete terminal outcomes.
Ordering and duplicate coverage: The added harness explicitly distinguishes non-authoritative output-item completion, resumed conversation replay, immediate function-call argument completion, and terminal-output recovery.
Findings None None.
Security None None.

How this fits together

The xAI realtime-voice plugin receives provider WebSocket events and turns them into voice-session transcripts, errors, audio, and tool calls. A terminal response.done event closes each provider turn and should carry the final outcome that the bridge exposes to the rest of OpenClaw.

flowchart LR
  A[xAI realtime WebSocket] --> B[Voice event adapter]
  B --> C[Immediate function-call completion]
  B --> D[Terminal response outcome]
  C --> E[Deduplicated tool dispatch]
  D --> F[Final transcript and error handling]
  E --> G[Voice session]
  F --> G
Loading

Decision needed

Question Recommendation
Should this maintainer-authored xAI realtime delivery repair be merged once the exact current-main merge result has completed its pending required checks? Merge after current-head checks: Rebase or refresh the clean merge result and merge when the pending required checks confirm the exact head.

Why: The implementation and supplied live-provider proof support the change, but the PR is maintainer-authored and carries the protected maintainer label, so automated cleanup must not make the final merge decision.

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; although the xAI paths did not change after its base and a local three-way check found no conflicts, the final merge ref still needs the pending current-head checks.
Agent review details

Security

None.

PR surface

Source +32, Tests +234. Total +266 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 56 24 +32
Tests 1 234 0 +234
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 290 24 +266

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/xai/realtime-voice-terminal-outcomes.test.ts, serialized state: extensions/xai/realtime-voice-terminal-outcomes.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #116201
Summary: This PR is a bounded candidate repair for the xAI provider-retention portion of the broader realtime-voice ownership report.

Members:

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

Merge-risk options

Maintainer options:

  1. Refresh the exact merge result (recommended)
    Rebase or merge-refresh against current main, then require the pending current-head checks before landing the transcript and tool-call delivery change.
  2. Accept provider-event coverage
    Maintainers may merge with the supplied real xAI capture and focused regression coverage if the exact merge-result checks pass.

Technical review

Best possible solution:

Land the provider-local terminal-outcome repair after refreshing the exact merge result and its required checks; retain immediate streamed function-call dispatch and use terminal output only as authoritative recovery plus deduplication.

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

Yes—source-reproducible with high confidence: current main ignores response.done.response.status, status_details, and output, while the focused PR harness supplies those terminal-only outcomes. The supplied PR context also records live xAI terminal-output evidence, though this read-only host could not retrieve GitHub Actions over DNS.

Is this the best way to solve the issue?

Yes—the terminal event owner is the narrowest maintainable fix because it records the provider’s authoritative end-of-turn facts where they occur while preserving the existing immediate function-call completion path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

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

Label justifications:

  • P1: This repair addresses a realtime voice path where final assistant output, a terminal failure explanation, or a completed tool call can otherwise be silently absent.
  • merge-risk: 🚨 message-delivery: The patch changes the authoritative terminal event used to emit assistant transcripts and recover tool calls, so an event-shape or ordering error could affect delivery.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides two linked real xAI runs and a sanitized terminal-response capture showing a completed function call in response.done.output, with a successful tool-result continuation; the supplied context marks that proof sufficient.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides two linked real xAI runs and a sanitized terminal-response capture showing a completed function call in response.done.output, with a successful tool-result continuation; the supplied context marks that proof sufficient.

Evidence

What I checked:

  • Current-main gap: Current main handles response.done only by flushing the incremental transcript buffer and clearing response state; it does not inspect terminal status, status details, or terminal output items. (extensions/xai/realtime-voice-events.ts:136, ebb301c32d9e)
  • Proposed terminal owner: The PR reads terminal status and output, recovers completed function calls from terminal output, finalizes an assistant transcript from terminal message content, and reports failed or incomplete terminal outcomes. (extensions/xai/realtime-voice-events.ts:129, 78abe81a0bba)
  • Ordering and duplicate coverage: The added harness explicitly distinguishes non-authoritative output-item completion, resumed conversation replay, immediate function-call argument completion, and terminal-output recovery. (extensions/xai/realtime-voice-terminal-outcomes.test.ts:143, 78abe81a0bba)
  • Current-main isolation: The three changed xAI production files are byte-identical between the PR base and current main, so the branch is behind main but has no touched-path drift requiring a different xAI repair. (extensions/xai/realtime-voice-events.ts:136, ebb301c32d9e)
  • Feature provenance: The existing realtime event lifecycle, including the immediate streamed-function-call path, appears to originate with the xAI connection-lifecycle commit; the proposed repair builds on that owner boundary rather than moving provider policy into core. (extensions/xai/realtime-voice-events.ts:14, b4ec765e00cc)
  • Supersession provenance: The original contributor commit is an ancestor of this branch, matching the PR discussion that this branch preserves the earlier work while replacing its unbounded cache approach. (extensions/xai/realtime-voice-events.ts:129, 78abe81a0bba)

Likely related people:

  • vincentkoc: Current-main realtime voice lifecycle code is attributed to this person, and the repair commits continue in the same xAI owner boundary. (role: feature owner and recent area contributor; confidence: high; commits: b4ec765e00cc, 186f2df13467, 78abe81a0bba; files: extensions/xai/realtime-voice-events.ts, extensions/xai/realtime-voice-bridge.ts, extensions/xai/realtime-voice-config.ts)

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-01T19:47:36.681Z sha 8c7f578 :: needs maintainer review before merge. :: none

* commit '81e392b7ff43bcdb7a3be50a99adf65c3b0141b5':
  fix(channels): preserve filters in offline status diagnostics (#117570)
  perf(gateway): separate startup maintenance timing (#117577)
  refactor(tests): deduplicate database-first guard fixtures (#117594)
  fix(cli): align sessions cleanup label summary by visible width (#117459)
  perf(gateway): skip empty session reconciliation (#117589)
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 1, 2026
@vincentkoc
vincentkoc merged commit 80c187b into main Aug 1, 2026
96 of 98 checks passed
@vincentkoc
vincentkoc deleted the fix/xai-terminal-realtime-outcomes-20260801 branch August 1, 2026 20:14
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 1, 2026
* commit '78abe81a0bbae44d5d41fbb2913f3a1c03b17e51':
  test(xai): bound realtime outcome harness payloads
  fix(xai): bound terminal tool outcome state
  fix(xai): preserve canonical realtime terminal outcomes
@vincentkoc

Copy link
Copy Markdown
Member Author

History preservation follow-up:

The repository merge helper used the enabled squash path for this PR. Because this PR was explicitly required to preserve its signed commit series, main now also contains signed two-parent merge d334de8452f24b8b87fc7b9ec15b5232ee32f98a.

Parents:

  • 80c187b8667dd8643e1c60057411a8558d26f8a9 - the already-landed tree
  • 78abe81a0bbae44d5d41fbb2913f3a1c03b17e51 - the exact reviewed PR head

The follow-up merge is tree-identical to its first parent and makes the full PR head and original contributor commit a02cc5c8495316bc1b05df9d24d836edbca74917 reachable from main without rewriting published history.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* fix(xai): preserve canonical realtime terminal outcomes

* fix(xai): bound terminal tool outcome state

* test(xai): bound realtime outcome harness payloads

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* commit '7a7c74aae06b78b0f3d3db86cf27d678ae92e954':
  test(xai): bound realtime outcome harness payloads
  fix(xai): bound terminal tool outcome state
  fix(xai): preserve canonical realtime terminal outcomes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: xai maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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