Skip to content

fix(reply): preserve streamed voice message order - #128558

Merged
steipete merged 1 commit into
mainfrom
codex/reply-audio-stream-order-owner-20260824
Aug 24, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/reply-audio-stream-order-owner-20260824

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users receiving streamed replies containing voice or audio attachments would see later text or images delivered before the audio. Text from opposite sides of an audio attachment could also be incorrectly combined into a single message.

Why This Change Was Made

The shared streaming reply pipeline buffered audio separately to preserve late-arriving voice presentation metadata, but did not treat that deferred audio as an ordering boundary. Flush earlier coalesced text when audio enters the buffer, then place buffered audio on the same ordered delivery chain before processing the next non-audio block. Late voice markers continue to apply before the audio is finalized.

User Impact

Streamed text, voice attachments, and images now arrive in the order the agent produced them across all channel implementations using the shared reply pipeline. Text is no longer merged across an intervening audio attachment, and late voice presentation metadata remains intact.

Evidence

  • Added three real-pipeline regressions covering text/audio/text ordering, audio/image ordering through both attachment URL shapes, and late-arriving voice metadata. All three fail against current main before the owner-boundary repair.
  • Run node scripts/run-vitest.mjs src/auto-reply/reply/block-reply-pipeline.test.ts src/auto-reply/reply/reply-utils.test.ts src/auto-reply/reply/reply-delivery.test.ts src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts: 227 tests passed across four owner, sibling, delivery, and real-runner suites.
  • Run node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile /private/tmp/openclaw-audio-core.tsbuildinfo and node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.messaging.json --builders 1: core production and messaging-test types both pass.
  • Run node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/auto-reply/reply/block-reply-pipeline.test.ts src/auto-reply/reply/block-reply-pipeline.ts.
  • Run ./node_modules/.bin/oxfmt --check src/auto-reply/reply/block-reply-pipeline.ts src/auto-reply/reply/block-reply-pipeline.test.ts and git diff --check.
  • Independent read-only local review inspected the pipeline owner, actual agent-runner caller, sibling coalescer, delayed voice metadata, ordering, and duplicate handling: CLEAN, with no actionable findings.
  • Production delta: +3 lines, required to enforce both sides of the audio ordering boundary while documenting the late-metadata invariant. No channel-specific policy, external API, configuration, persistent state, or protocol changes.
  • Live-channel evidence was not captured because this isolated checkout has no disposable configured channel and sending test messages to an operator-owned live channel would create unsolicited external side effects. The real shared delivery owner, its delivery boundary, and the actual agent-runner integration are exercised by the focused suites instead.

@clawsweeper

clawsweeper Bot commented Aug 24, 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 size: S maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 06:17
@steipete
steipete merged commit 3cb7f63 into main Aug 24, 2026
291 checks passed
@steipete
steipete deleted the codex/reply-audio-stream-order-owner-20260824 branch August 24, 2026 06:38
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 24, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 2:25 AM ET / 06:25 UTC.

ClawSweeper review

What this changes

The PR makes deferred streamed audio flush surrounding text and itself before later reply blocks, preserving agent-produced delivery order.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness finding in this focused owner-boundary repair. This PR remains open because its protected maintainer label requires an explicit maintainer landing decision after a current-main refresh and exact-head checks.

Priority: P2
Reviewed head: d494f73512b9b88e276a32fb1f9b0251a99dee53
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused shared-owner repair with targeted behavioral regressions and no supported correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This repository-member PR is exempt from the external-contributor proof gate; its body supplies focused owner-boundary regression commands, while live-channel proof was explicitly infeasible in the isolated checkout.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This repository-member PR is exempt from the external-contributor proof gate; its body supplies focused owner-boundary regression commands, while live-channel proof was explicitly infeasible in the isolated checkout.
Evidence reviewed 4 items Ordering owner: The pipeline buffers audio to preserve late voice presentation metadata, then the changed enqueue path flushes coalesced text when audio enters and flushes buffered audio before the next non-audio block.
Caller and delivery boundary: The agent runner creates this shared pipeline with the audio predicate, while the reply delivery handler routes normalized streamed blocks into it.
Regression coverage: The added table cases exercise text/audio/text, audio/image, and late voice-marker ordering at the pipeline boundary.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/auto-reply/reply/block-reply-pipeline.test.ts

Result: FAIL (partial) — step 2 expect_output preserves streamed delivery order: expected terminal output was not visible within 30 seconds: "preserves streamed delivery order"

node scripts/run-vitest.mjs src/auto-reply/reply/block-reply-pipeline.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128558-vwyThh/target$ node scripts/run-vitest.mjs src/auto-reply/reply/block-reply-pipeline.test.ts
node scripts/run-vitest.mjs src/auto-reply/reply/block-reply-pipeline.test.ts
[test] starting test/vitest/vitest.auto-reply.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128558-vwyThh/target

 ✓  auto-reply  src/auto-reply/reply/block-reply-pipeline.test.ts (25 tests) 92ms

 Test Files  1 passed (1)
      Tests  25 passed (25)
   Start at  06:26:02
   Duration  1.29s (transform 1.00s, setup 794ms, import 120ms, tests 92ms, environment 0ms)

[test] passed 1 Vitest shard in 5.77s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128558-vwyThh/target$ node scripts/run-vitest.mjs src/auto-reply/reply/block-reply-pipeline.test.ts
[test] starting test/vitest/vitest.auto-reply.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128558-vwyThh/target

 ✓  auto-reply  src/auto-reply/reply/block-reply-pipeline.test.ts (25 tests) 56ms

 Test Files  1 passed (1)
      Tests  25 passed (25)
   Start at  06:26:08
   Duration  657ms (transform 324ms, setup 367ms, import 50ms, tests 56ms, environment 0ms)

[test] passed 1 Vitest shard in 5.07s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128558-vwyThh/target$






















Assertions:

  • FAIL expect_output: preserves streamed delivery order

How this fits together

The shared reply pipeline receives streamed agent blocks, coalesces text, and holds audio until late voice metadata can be applied. It serializes resulting payloads to channel delivery handlers used by streamed replies.

flowchart LR
  A[Agent streamed blocks] --> B[Reply delivery handler]
  B --> C[Shared reply pipeline]
  C --> D[Text coalescing]
  C --> E[Deferred audio buffer]
  D --> F[Ordered delivery chain]
  E --> F
  F --> G[Channel delivery]
Loading

Decision needed

Question Recommendation
Should this maintainer-labeled shared reply-delivery fix land after a current-main refresh and exact-head checks are green? Land after refresh: Rebase onto current main, confirm exact-head checks, and land the focused shared-pipeline repair.

Why: The protected maintainer label requires an explicit human landing decision even though the source review found no blocking defect.

Before merge

  • Resolve merge risk (P1) - The fix adds three production lines; retain both flush boundaries only with the focused ordering regressions and exact-head validation, since each represents a distinct side of the audio boundary.
Agent review details

Security

None.

PR surface

Source +3, Tests +61. Total +64 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 0 +3
Tests 1 62 1 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 65 1 +64

Review metrics

Metric Value Why it matters
Production versus regression LOC production +3/-0; tests +62/-1 The small production increase establishes two ordering boundaries, while the test growth covers three observable ordering scenarios.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep ordering policy in the shared reply pipeline rather than channel adapters; rebase onto current main and verify the exact head before a maintainer lands it.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep ordering policy in the shared reply pipeline rather than channel adapters; rebase onto current main and verify the exact head before a maintainer lands it.

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

Yes, from source: enqueue text, an audio payload recognized by the audio buffer, then text or image; the prior path deferred audio without making it an ordering boundary.

Is this the best way to solve the issue?

Yes. The shared pipeline owns both deferred-audio finalization and serialized delivery, so fixing it there prevents channel-specific ordering policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This fixes a bounded streamed-reply ordering regression in a shared delivery path.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This repository-member PR is exempt from the external-contributor proof gate; its body supplies focused owner-boundary regression commands, while live-channel proof was explicitly infeasible in the isolated checkout.

Label justifications:

  • P2: This fixes a bounded streamed-reply ordering regression in a shared delivery path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 repository-member PR is exempt from the external-contributor proof gate; its body supplies focused owner-boundary regression commands, while live-channel proof was explicitly infeasible in the isolated checkout.

Evidence

What I checked:

Likely related people:

  • steipete: The available checked-out feature history attributes the current repair commit to Peter Steinberger; the supplied PR context identifies the author as a repository member. (role: current feature contributor and repository member; confidence: medium; commits: d494f73512b9; files: src/auto-reply/reply/block-reply-pipeline.ts, src/auto-reply/reply/block-reply-pipeline.test.ts)

Rank-up moves

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

  • Rebase onto current main and confirm exact-head checks before landing.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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