Skip to content

fix(bedrock): reject truncated streams and normalize audio tool results - #116743

Merged
steipete merged 1 commit into
mainfrom
codex/auto-qa-bedrock
Jul 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/auto-qa-bedrock

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Reject truncated Bedrock streams consistently when the provider never emits its required terminal messageStop event, including non-Claude models.
  • Preserve audio-bearing tool results as a safe canonical placeholder instead of misclassifying unsupported audio as an image.

Verification

  • Focused Bedrock owner suite: 53 tests passed.
  • Independent whole-owner manual review inspected the AWS SDK event/tool-result contracts, sibling stream paths, callers, and regressions; no blockers.
  • Automated autoreview could not start because the required TruffleHog executable is unavailable; equivalent independent manual diff and secret review completed.

Root causes fixed

2 distinct provider/runtime defects.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 31, 2026, 5:39 AM ET / 09:39 UTC.

ClawSweeper review

What this changes

The PR rejects Amazon Bedrock streams that end without messageStop and converts audio-only tool results to a text placeholder instead of treating them as images.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 6 items remain

Keep this protected Bedrock PR open for maintainer review. The stream-completion change introduces a concrete cancellation-ordering regression: it checks for a missing terminal event before honoring an already-aborted request, so a normal cancelled stream can be reported as provider truncation instead of cancellation.

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

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has focused tests and a narrow goal, but a cancellation regression and absent inspectable real-behavior proof prevent a merge-ready rating.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports a focused test suite and manual review, but it provides no inspectable redacted after-fix Bedrock runtime output; attach a terminal transcript or runtime log showing the truncated-stream error and audio-only placeholder behavior, with private endpoints and credentials removed. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports a focused test suite and manual review, but it provides no inspectable redacted after-fix Bedrock runtime output; attach a terminal transcript or runtime log showing the truncated-stream error and audio-only placeholder behavior, with private endpoints and credentials removed. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Proposed completion ordering: The patch changes the unconditional missing-messageStop error check to run before the existing aborted-signal check. That makes cancellation unable to take its intended cancellation path when an aborted stream ends without the terminal event.
Existing abort path follows terminal validation: The adjacent implementation checks options.signal?.aborted after the terminal-event branch, so broadening that branch from refusal-only to every stream also broadens the possibility of masking cancellation as truncation.
Focused tests omit cancellation precedence: The added tests cover missing terminal events and tool-result media conversion, but the supplied diff does not add a case where the signal is aborted and messageStop is absent.
Findings 1 actionable finding [P2] Preserve cancellation before rejecting a terminal-less stream
Security None None.

How this fits together

The Amazon Bedrock extension maps OpenClaw tool output into Bedrock Converse content blocks and consumes Bedrock’s streamed response events. Its completion logic determines whether an agent run finishes, fails, or is cancelled; its tool-result conversion determines what the model receives on the next provider request.

flowchart LR
  A[Agent tool result] --> B[Bedrock request converter]
  B --> C[Bedrock content blocks]
  D[Bedrock stream events] --> E[Stream completion checker]
  F[Cancellation signal] --> E
  E --> G[Agent run outcome]
  C --> H[Bedrock Converse API]
Loading

Decision needed

Question Recommendation
Should this protected Bedrock fix preserve cancellation as a distinct terminal outcome before enforcing the missing-messageStop provider error? Preserve cancellation first: Handle an aborted signal before missing-terminal-event validation and add focused coverage for an aborted stream without messageStop.

Why: The mechanical ordering fix is clear, but the protected maintainer label requires an explicit owner decision on the expected provider cancellation contract before this PR lands.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports a focused test suite and manual review, but it provides no inspectable redacted after-fix Bedrock runtime output; attach a terminal transcript or runtime log showing the truncated-stream error and audio-only placeholder behavior, with private endpoints and credentials removed. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve cancellation before rejecting a terminal-less stream (P2) - Handle options.signal.aborted before this new unconditional terminal-event error. A cancellation can end the stream without messageStop; with this order it is reported as provider truncation instead of following the cancellation path. Add an aborted/no-terminal-event regression case.
  • Resolve merge risk (P1) - Merging as written can turn an operator-requested cancellation into Bedrock stream ended before messageStop, changing cancellation handling into a provider failure for affected Bedrock runs.
  • Resolve merge risk (P1) - The PR body reports focused tests and manual inspection but supplies no inspectable after-fix runtime transcript or redacted log demonstrating both the rejected truncated stream and preserved audio-only tool result.
  • Complete next step (P2) - A narrow code repair is apparent, but the protected maintainer label and cancellation-contract choice require owner review before automated repair or merge.

Findings

  • [P2] Preserve cancellation before rejecting a terminal-less stream — extensions/amazon-bedrock/stream.runtime.ts:335-337
Agent review details

Security

None.

PR surface

Source +3, Tests +123. Total +126 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 3 +3
Tests 1 123 0 +123
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 129 3 +126

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Restore cancellation precedence (recommended)
    Move the aborted-signal handling ahead of the terminal-event error and cover the aborted/no-messageStop stream case before merging.
  2. Accept altered cancellation semantics
    Merge the current ordering only with explicit owner confirmation that cancelled Bedrock streams should surface as truncation failures.
  3. Pause for provider contract review
    Pause this PR if the owner cannot confirm whether the Bedrock stream iterator guarantees a terminal event after client cancellation.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve the aborted-stream outcome before terminal-event validation, add a focused regression test for an aborted stream without messageStop, and attach redacted after-fix runtime evidence.

Technical review

Best possible solution:

Check and preserve the aborted-request outcome before rejecting a non-terminal stream, add a regression test for that precedence, and attach redacted runtime evidence for the two corrected Bedrock paths before merge.

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

Yes, from source with medium confidence: arrange an aborted Bedrock stream that ends before messageStop; the new ordering throws the truncation error before the aborted-signal branch can run. A current-main live or focused test reproduction was not available in this read-only review environment.

Is this the best way to solve the issue?

No. Rejecting genuinely truncated streams is appropriate, but the check must not override the existing cancellation outcome; cancellation should be handled first and tested as a separate terminal condition.

Full review comments:

  • [P2] Preserve cancellation before rejecting a terminal-less stream — extensions/amazon-bedrock/stream.runtime.ts:335-337
    Handle options.signal.aborted before this new unconditional terminal-event error. A cancellation can end the stream without messageStop; with this order it is reported as provider truncation instead of following the cancellation path. Add an aborted/no-terminal-event regression case.
    Confidence: 0.83

Overall correctness: patch is incorrect
Overall confidence: 0.83

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label changes:

  • add P2: This is a bounded provider-runtime regression risk in an optional Bedrock extension rather than a demonstrated core-runtime outage.
  • add merge-risk: 🚨 availability: The changed completion ordering can misclassify a cancelled provider stream as an error, affecting whether an agent run terminates cleanly.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a focused test suite and manual review, but it provides no inspectable redacted after-fix Bedrock runtime output; attach a terminal transcript or runtime log showing the truncated-stream error and audio-only placeholder behavior, with private endpoints and credentials removed. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a bounded provider-runtime regression risk in an optional Bedrock extension rather than a demonstrated core-runtime outage.
  • merge-risk: 🚨 availability: The changed completion ordering can misclassify a cancelled provider stream as an error, affecting whether an agent run terminates cleanly.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a focused test suite and manual review, but it provides no inspectable redacted after-fix Bedrock runtime output; attach a terminal transcript or runtime log showing the truncated-stream error and audio-only placeholder behavior, with private endpoints and credentials removed. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Proposed completion ordering: The patch changes the unconditional missing-messageStop error check to run before the existing aborted-signal check. That makes cancellation unable to take its intended cancellation path when an aborted stream ends without the terminal event. (extensions/amazon-bedrock/stream.runtime.ts:335, b4bfb7f0886d)
  • Existing abort path follows terminal validation: The adjacent implementation checks options.signal?.aborted after the terminal-event branch, so broadening that branch from refusal-only to every stream also broadens the possibility of masking cancellation as truncation. (extensions/amazon-bedrock/stream.runtime.ts:335, b4bfb7f0886d)
  • Focused tests omit cancellation precedence: The added tests cover missing terminal events and tool-result media conversion, but the supplied diff does not add a case where the signal is aborted and messageStop is absent. (extensions/amazon-bedrock/stream.runtime.test.ts:123, b4bfb7f0886d)
  • Protected maintainer handling: The GitHub context marks this PR with the protected maintainer label, so it must remain open for explicit maintainer handling even though the repair is narrow.

Likely related people:

  • steipete: The supplied PR context identifies this contributor as the author of the current Bedrock stream and tool-result repair; local history inspection was unavailable in the read-only sandbox. (role: recent Bedrock contributor; confidence: low; commits: b4bfb7f0886d; files: extensions/amazon-bedrock/stream.runtime.ts, extensions/amazon-bedrock/stream.runtime.test.ts)

Rank-up moves

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

  • Handle aborts before validating the required terminal event and add a focused cancellation-precedence test.
  • Add redacted after-fix Bedrock runtime evidence for both stream truncation and audio-only tool-result conversion.

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.

@steipete
steipete merged commit f9207db into main Jul 31, 2026
98 of 107 checks passed
@steipete
steipete deleted the codex/auto-qa-bedrock branch July 31, 2026 10:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 31, 2026
* commit 'refs/frozen/talk-pcm-output-main-refresh':
  fix(skills): allow autonomous sweep sync (#116755)
  fix(irc): recognize punctuation in nickname mentions (#116758)
  fix(plugins): require explicit source external startup (#116759)
  fix(whatsapp): keep sends running when typing presence fails (#116739)
  fix(cli): reject dangling config path escapes (#116738)
  fix(qa): authenticate summaries and bound native scenario commands (#116748)
  fix(bedrock): reject truncated streams and preserve audio results (#116743)
  docs(skill): isolate autonomous issue sweep worktrees
  fix(ci): retire Kova runtime deps coverage (#116760)
  chore(i18n): refresh native locales (#116640)
  fix(ollama): resolve web search secret refs (#104829)
  fix(ollama): honor stop sequences and async payload hooks (#116737)
  fix(ollama): stop oversized stream records from growing memory (#107473)
  fix(agents): preserve thinking for runtime-selected Ollama models (#116584)
vincentkoc added a commit that referenced this pull request Jul 31, 2026
* origin/main: (23 commits)
  fix(agents): preserve resumed turns after stale terminal events (#116777)
  fix(browser): preserve tab-bound browser authorization (#116778)
  fix(doctor): correct SQLite-backed automation warnings (#116769)
  fix(release): skip unavailable Buzz QA runner (#116753)
  feat(plugins): externalize DuckDuckGo search (#116740)
  refactor(reply): simplify task-owned typing refresh (#116770)
  fix(chat): explain chat-only model limits
  feat(models): expose tool support to clients
  docs(skill): require independent proof before issue closure
  fix(skills): allow autonomous sweep sync (#116755)
  fix(irc): recognize punctuation in nickname mentions (#116758)
  fix(plugins): require explicit source external startup (#116759)
  fix(whatsapp): keep sends running when typing presence fails (#116739)
  fix(cli): reject dangling config path escapes (#116738)
  fix(qa): authenticate summaries and bound native scenario commands (#116748)
  fix(bedrock): reject truncated streams and preserve audio results (#116743)
  docs(skill): isolate autonomous issue sweep worktrees
  fix(ci): retire Kova runtime deps coverage (#116760)
  chore(i18n): refresh native locales (#116640)
  fix(ollama): resolve web search secret refs (#104829)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
* commit 'refs/frozen/talk-pcm-output-main-refresh':
  fix(skills): allow autonomous sweep sync (openclaw#116755)
  fix(irc): recognize punctuation in nickname mentions (openclaw#116758)
  fix(plugins): require explicit source external startup (openclaw#116759)
  fix(whatsapp): keep sends running when typing presence fails (openclaw#116739)
  fix(cli): reject dangling config path escapes (openclaw#116738)
  fix(qa): authenticate summaries and bound native scenario commands (openclaw#116748)
  fix(bedrock): reject truncated streams and preserve audio results (openclaw#116743)
  docs(skill): isolate autonomous issue sweep worktrees
  fix(ci): retire Kova runtime deps coverage (openclaw#116760)
  chore(i18n): refresh native locales (openclaw#116640)
  fix(ollama): resolve web search secret refs (openclaw#104829)
  fix(ollama): honor stop sequences and async payload hooks (openclaw#116737)
  fix(ollama): stop oversized stream records from growing memory (openclaw#107473)
  fix(agents): preserve thinking for runtime-selected Ollama models (openclaw#116584)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
* origin/main: (23 commits)
  fix(agents): preserve resumed turns after stale terminal events (openclaw#116777)
  fix(browser): preserve tab-bound browser authorization (openclaw#116778)
  fix(doctor): correct SQLite-backed automation warnings (openclaw#116769)
  fix(release): skip unavailable Buzz QA runner (openclaw#116753)
  feat(plugins): externalize DuckDuckGo search (openclaw#116740)
  refactor(reply): simplify task-owned typing refresh (openclaw#116770)
  fix(chat): explain chat-only model limits
  feat(models): expose tool support to clients
  docs(skill): require independent proof before issue closure
  fix(skills): allow autonomous sweep sync (openclaw#116755)
  fix(irc): recognize punctuation in nickname mentions (openclaw#116758)
  fix(plugins): require explicit source external startup (openclaw#116759)
  fix(whatsapp): keep sends running when typing presence fails (openclaw#116739)
  fix(cli): reject dangling config path escapes (openclaw#116738)
  fix(qa): authenticate summaries and bound native scenario commands (openclaw#116748)
  fix(bedrock): reject truncated streams and preserve audio results (openclaw#116743)
  docs(skill): isolate autonomous issue sweep worktrees
  fix(ci): retire Kova runtime deps coverage (openclaw#116760)
  chore(i18n): refresh native locales (openclaw#116640)
  fix(ollama): resolve web search secret refs (openclaw#104829)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: amazon-bedrock maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant