Skip to content

fix(talk): bound WebRTC tool-call lifecycle - #117732

Merged
vincentkoc merged 8 commits into
mainfrom
fix/talk-webrtc-tool-call-bounds-20260802
Aug 2, 2026
Merged

vincentkoc merged 8 commits into
mainfrom
fix/talk-webrtc-tool-call-bounds-20260802

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Related: #116201

What Problem This Solves

Fixes an issue where long or replayed OpenAI WebRTC Talk sessions could retain unbounded provisional tool arguments and terminal call identities, and could execute provisional or duplicate function-call events.

Why This Change Was Made

The WebRTC adapter now treats a successful response.done as the sole executable tool-call boundary, matching the OpenAI Realtime contract. It ignores provisional argument events, accepts optional response/item IDs, bounds authoritative arguments to 256,000 UTF-8 bytes, caps terminal call identities at 1,024 without eviction, and ignores late async results after close.

This remains WebRTC-local. It does not introduce a generic provider state machine or change provider, config, environment-variable, protocol, or public SDK surface.

User Impact

Browser Talk keeps normal control, consult, and camera tool behavior while preventing session-long memory growth and duplicate execution from late terminal replay. Extreme call-cardinality overflow closes visibly instead of weakening dedupe.

Evidence

  • 44/44 focused WebRTC lifecycle, control, and video tests passed.
  • Blacksmith Testbox UI typecheck passed: https://github.com/openclaw/openclaw/actions/runs/30727227174
  • Exact-head live OpenAI gpt-realtime-2.1 browser proof passed at f82d2dde144ff257fb177e6b639169387ded23fe:
    • 52 provisional argument deltas and one provisional done event remained inert.
    • One authoritative completed consult executed and returned one function output.
    • Replaying the terminal response kept consult/output counts at 1/1.
  • P1 autoreview completed with no findings.
  • git diff --check and targeted formatting passed.
  • OpenAI SDK 6.49.0 confirms response.done includes all response output items and requires checking response status; provisional arguments-done may also be emitted for interrupted, incomplete, or cancelled responses.
  • Sibling Codex source was inspected for realtime lifecycle precedent; this browser transport remains an OpenClaw-owned adapter boundary.

AI-assisted: yes. The implementation and proof were reviewed by a maintainer.

@vincentkoc vincentkoc self-assigned this Aug 2, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Aug 2, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 2, 2026 01:37
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 10:01 PM ET / August 2, 2026, 02:01 UTC.

ClawSweeper review

What this changes

The PR makes Control UI WebRTC Talk execute OpenAI function calls only from completed response output, bounds retained call state, and ignores provisional or late duplicate events.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No concrete patch defect was found in the reviewed lifecycle path, but this member-authored, maintainer-labeled PR should remain open for maintainer review because direct inspection of the pinned OpenAI Realtime dependency contract was unavailable in this checkout. The implementation appears to repair the current unbounded provisional-argument path at the WebRTC adapter boundary and has focused plus reported live-browser evidence.

Priority: P1
Reviewed head: 1ffcfdd168c05d33e764ac111cf9f49be1f7fa31
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has a coherent owner-boundary repair and focused coverage, but independent inspection of the pinned OpenAI Realtime contract was unavailable in this checkout.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless reports exact-head live browser evidence with provisional-event and duplicate-replay counts.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless reports exact-head live browser evidence with provisional-event and duplicate-replay counts.
Evidence reviewed 6 items Current-main behavior: Current main accumulates provisional argument deltas in toolBuffers and invokes handleToolCall directly from response.function_call_arguments.done, so its retained arguments have no byte bound and execution is not tied to terminal response status.
Proposed owner-boundary repair: The branch makes provisional argument events inert and routes only response.done through completed-response handling before emitting the normal terminal turn state.
Bounded authoritative state: The completed-response parser validates completed function-call output, deduplicates terminal call IDs, caps identities at 1,024, and rejects arguments over 256,000 UTF-8 bytes before dispatching a supported Talk tool.
Findings None None.
Security None None.

How this fits together

Control UI Talk receives OpenAI Realtime events through a WebRTC data channel and translates allowed function calls into local control, consult, and camera actions. This transport is responsible for deciding which provider events are executable and for ending or suppressing work when the Talk session closes.

flowchart LR
  A[OpenAI Realtime events] --> B[WebRTC Talk transport]
  B --> C[Completed response validation]
  C --> D[Call ID dedupe and argument bounds]
  D --> E[Control, consult, or camera action]
  D --> F[Visible session close at safety limit]
  E --> G[Function output and next response]
Loading

Decision needed

Question Recommendation
Should this PR merge after a maintainer independently verifies that OpenAI Realtime 6.49.0 treats completed response.done output as the authoritative executable function-call boundary and accepts the 1,024-call terminal-close policy? Verify contract and merge: Inspect the pinned OpenAI Realtime types or official contract, confirm the stated terminal-event semantics, then merge once the current head has the required green checks.

Why: The code and focused tests support the local repair, but repository policy requires direct dependency-contract evidence that this read-only checkout could not access.

Before merge

  • Resolve merge risk (P1) - The patch changes live Talk session-state semantics: an unusually high number of distinct terminal calls now visibly closes the session rather than evicting dedupe state; maintainers should accept that operator-visible safety policy.
  • Resolve merge risk (P1) - The direct OpenAI 6.49.0 Realtime type/source inspection required by repository policy could not be completed from this checkout, so the claimed terminal-event contract needs a maintainer-visible verification before merge.
  • Complete next step (P2) - A maintainer must verify the dependency contract and accept the long-session terminal-close policy; the PR is member-authored and already has a focused implementation branch.
Agent review details

Security

None.

PR surface

Source +45, Tests +271, Docs +1. Total +317 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 1 80 35 +45
Tests 4 334 63 +271
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 415 98 +317

Review metrics

Metric Value Why it matters
Session-safety bounds 2 added: 256,000-byte argument cap and 1,024 terminal call-ID cap These limits bound memory and replay protection but make long-session behavior an explicit merge-time policy choice.

Stored data model

Persistent data-model change detected: serialized state: ui/src/pages/chat/realtime-talk-webrtc-control.test.ts, serialized state: ui/src/pages/chat/realtime-talk-webrtc-video.test.ts, serialized state: ui/src/pages/chat/realtime-talk-webrtc.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #116201
Summary: This PR is a focused candidate repair for the WebRTC tool-call retention and duplicate-execution portion of the broader realtime resource-bound issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Verify the Realtime boundary before merge (recommended)
    Confirm the pinned OpenAI contract and preserve the added terminal-event and overflow regression coverage before accepting the changed Talk session lifecycle.
  2. Accept the terminal-close policy
    Merge with the explicit understanding that sessions close after 1,024 distinct completed call IDs to avoid reopening duplicate-execution risk.
  3. Pause for a different long-session policy
    Hold the PR if maintainers want a product-level alternative to visible close on terminal call-cardinality overflow.

Technical review

Best possible solution:

Keep execution ownership in the WebRTC adapter, retain the bounded terminal-response design, and complete an exact OpenAI Realtime contract check plus current-head CI before merging.

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

Yes, from source: current main buffers every provisional argument delta and executes on the provisional arguments-done event, while the branch provides focused tests for the corrected terminal-response path. This review did not run a live reproduction locally.

Is this the best way to solve the issue?

Unclear pending direct OpenAI dependency inspection: the WebRTC adapter is the appropriate owner and the branch removes the provisional buffer rather than adding a parallel state machine, but the provider event contract could not be independently read in this environment.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Duplicate tool execution and unbounded retained arguments affect active browser Talk workflows and can disrupt real sessions.
  • merge-risk: 🚨 session-state: Merging changes which Realtime events are executable and how an active Talk session behaves at its retained-call limit.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless reports exact-head live browser evidence with provisional-event and duplicate-replay counts.

Evidence

What I checked:

  • Current-main behavior: Current main accumulates provisional argument deltas in toolBuffers and invokes handleToolCall directly from response.function_call_arguments.done, so its retained arguments have no byte bound and execution is not tied to terminal response status. (ui/src/pages/chat/realtime-talk-webrtc.ts:372, b2da7aa106dc)
  • Proposed owner-boundary repair: The branch makes provisional argument events inert and routes only response.done through completed-response handling before emitting the normal terminal turn state. (ui/src/pages/chat/realtime-talk-webrtc.ts:379, 1ffcfdd168c0)
  • Bounded authoritative state: The completed-response parser validates completed function-call output, deduplicates terminal call IDs, caps identities at 1,024, and rejects arguments over 256,000 UTF-8 bytes before dispatching a supported Talk tool. (ui/src/pages/chat/realtime-talk-webrtc.ts:498, 1ffcfdd168c0)
  • Focused regression coverage: The branch adds cases for provisional events, duplicate completed calls, optional IDs, non-completed status, UTF-8 argument overflow, and terminal identity overflow; the browser E2E fixture now sends a completed response with authoritative output. (ui/src/pages/chat/realtime-talk-webrtc-control.test.ts:198, 1ffcfdd168c0)
  • Feature-history provenance: The current transport event-handler lines blame to a recent main commit, while nearby Talk lifecycle work in the same file includes commits by Vincent Koc; this makes Vincent Koc the strongest routing candidate and Peter Steinberger an adjacent current-main contributor. (ui/src/pages/chat/realtime-talk-webrtc.ts:372, 107e116bfd98)
  • Dependency-contract gap: The repository pins openai 6.49.0, but this read-only checkout has no installed OpenAI package source and the partial clone could not fetch missing objects because GitHub DNS resolution failed. The PR body and owner comment describe the Realtime contract, but this review could not independently inspect the dependency types. (package.json:1981, b2da7aa106dc)

Likely related people:

  • vincentkoc: Authored the current PR and recent merged WebRTC Talk lifecycle changes in the same transport, including transactional startup and active-versus-pending transport separation. (role: recent Talk lifecycle contributor; confidence: high; commits: b7b37847c867, 0a58b58666a3, 1ffcfdd168c0; files: ui/src/pages/chat/realtime-talk-webrtc.ts, ui/src/pages/chat/realtime-talk-webrtc-control.test.ts)
  • steipete: Current-main blame attributes the event-dispatch region to this recent commit, so this person is a useful secondary reviewer for interaction with the present transport baseline. (role: adjacent current-main contributor; confidence: medium; commits: 107e116bfd98; files: ui/src/pages/chat/realtime-talk-webrtc.ts)

Rank-up moves

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

  • Provide or perform a maintainer-visible inspection of the pinned OpenAI 6.49.0 Realtime event types or official contract.
  • Let the in-progress current-head CI complete before merge.

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-02T01:52:04.702Z sha 9fc0611 :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

Talk-owner confirmation: confirmed.

For this adapter, a successful response.done is the sole executable boundary for OpenAI Realtime function calls. response.function_call_arguments.delta and .done are observational only: the SDK contract allows argument completion events around interrupted/incomplete/cancelled responses, while response.done carries the terminal response status and authoritative output items. The adapter therefore:

  • executes only when the response status is completed;
  • accepts missing optional response/item IDs and item status;
  • ignores an explicit non-completed item status;
  • requires call_id, name, and authoritative final arguments;
  • rejects arguments above 256,000 UTF-8 bytes;
  • visibly closes after 1,024 distinct terminal call IDs rather than evicting replay protection.

The 1,024-call close is an accepted session-safety policy. It is intentionally terminal because evicting old IDs would allow duplicate execution in an unusually long session.

Evidence checked on this exact head:

  • OpenAI SDK Realtime types and event contract (openai 6.49.0).
  • Codex sibling Realtime handling at codex-rs/core/src/realtime_conversation.rs:1584.
  • Adapter implementation at ui/src/pages/chat/realtime-talk-webrtc.ts:398 and ui/src/pages/chat/realtime-talk-webrtc.ts:525.
  • Focused valid/late/duplicate/overflow tests: 43/43 passing.
  • Exact-head live OpenAI WebRTC/tool roundtrip passed with duplicate replay remaining 1/1.

ClawSweeper rank-up move applied; no code change needed.

@vincentkoc

Copy link
Copy Markdown
Member Author

Exact-head merge-risk disposition for 1ffcfdd168c05d33e764ac111cf9f49be1f7fa31:

  • ClawSweeper found no correctness or security findings.
  • The pinned openai 6.49.0 Realtime types were inspected directly: response.done carries terminal response status and authoritative output, while argument completion events are not a sufficient successful-response boundary.
  • The sibling Codex Realtime implementation was inspected directly at codex-rs/core/src/realtime_conversation.rs:1584.
  • Talk-owner acceptance of the 1,024 terminal call-ID visible-close policy is recorded in fix(talk): bound WebRTC tool-call lifecycle #117732 (comment).
  • The current-head browser E2E repair is test-only and does not alter that production contract.
  • The unrelated MCP timing failure passed on the single failed-job rerun; checks-node-compact-large-7 and openclaw/ci-gate are now green.

Both ClawSweeper rank-up moves are applied. No further code change is needed.

@vincentkoc
vincentkoc merged commit 31e03bc into main Aug 2, 2026
170 of 174 checks passed
@vincentkoc
vincentkoc deleted the fix/talk-webrtc-tool-call-bounds-20260802 branch August 2, 2026 02:17
@vincentkoc

Copy link
Copy Markdown
Member Author

Landed on main without squash as signed two-parent merge 31e03bc3d1e6d7e467b56d325b8e4e928a393943.

Parents:

  • live main: c8796064acba75d30fbca0c37cab4bfe920586e0
  • reviewed PR head: 1ffcfdd168c05d33e764ac111cf9f49be1f7fa31

Merged-tree verification:

  • expected git merge-tree result matched tree d9a0784ba583d54696b378fd112580be8b96d300;
  • browser Talk E2E passed 8/8;
  • WebRTC lifecycle/control/video tests passed 43/43;
  • fresh live OpenAI gpt-realtime-2.1 audio/WebRTC QA passed at exact merge SHA 31e03bc3d1e6d7e467b56d325b8e4e928a393943;
  • GitHub reports the merge signature as verified and valid.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* commit 'aaeedab833398417cf422b2de96a9b1d10f4287b':
  test(talk): align browser E2E tool completion
  docs(changelog): note bounded WebRTC tool calls
  test(talk): split WebRTC tool lifecycle coverage
  test(talk): align WebRTC tool-call fixtures
  fix(talk): accept optional realtime item ids
  fix(talk): narrow completed response payload
  test(talk): cover WebRTC terminal tool calls
  fix(talk): bound WebRTC tool-call lifecycle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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