Skip to content

fix(amazon-bedrock): lift tool-result images for GPT-6/6.1 Sol and Kimi K3 - #186835

Closed
wr-web wants to merge 1 commit into
openclaw:mainfrom
wr-web:fix/bedrock-tool-image-relocation-routes
Closed

wr-web wants to merge 1 commit into
openclaw:mainfrom
wr-web:fix/bedrock-tool-image-relocation-routes

Conversation

@wr-web

@wr-web wr-web commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #186753.

What Problem This Solves

Amazon Bedrock rejects images nested in toolResult.content on some image-capable routes, and the run fails with:

Validation error: This model doesn't support the image field for user messages. Remove image and try again.

#149336 added a relocation for this case, but its selector only matches openai.gpt-5.6-sol. The reporter's controlled Converse comparison shows the same rejection on openai.gpt-6-sol, openai.gpt-6.1-sol and moonshotai.kimi-k3. On each of those, the sibling-image layout is accepted and the image is described correctly. Those three routes still get the nested layout, so any image-returning tool breaks the turn on them.

User Impact

Image-reading tools (for example read on an image) work on Bedrock GPT-6 Sol, GPT-6.1 Sol and Kimi K3, just as they already do on GPT-5.6 Sol. Claude and other routes keep the nested layout unchanged.

Why This Change Was Made

  • The existing relocation is reused unchanged. Every tool output stays contiguous, images move into labeled sibling user blocks, and a placeholder points at them. The only change is the route list: openai.gpt-5.6-sol, openai.gpt-6-sol, openai.gpt-6.1-sol and moonshotai.kimi-k3, matched with the same model.id.includes(...) rule as before.
  • stream.runtime.ts is over its 700-line cap and the ratchet forbids growth. The relocation therefore moves verbatim into stream.tool-result-images.ts (buildBedrockToolResultUserContent), and stream.runtime.ts shrinks by 26 lines.
  • No public capability flag or config knob is added, as ClawSweeper recommended. The list contains only routes with demonstrated rejections.

Evidence

Tests

The existing "lifts tool images into user content … while preserving result associations" test is now parameterized over the four routes. It captures the real ConverseStream payload and checks the placement of the images, the placeholders, the error status of the tool result, and that stored history is not mutated. The unaffected default-model half still expects the nested layout.

route main this branch
us.openai.gpt-5.6-sol pass pass
global.openai.gpt-6-sol fail (nested image) pass
global.openai.gpt-6.1-sol fail pass
global.moonshotai.kimi-k3 fail pass

stream.runtime.test.ts and stream.runtime.tool-replay.test.ts pass 63/63. oxfmt, oxlint and pnpm check:line-cap-ratchet are clean.

Live run (Windows 11, Node 26.12.1)

This is a real openclaw gateway run with Telegram (local Bot API stand-in) and the amazon-bedrock provider (bedrock-converse-stream, auth: "aws-sdk"). The provider's baseUrl points at a local ConverseStream stand-in, which speaks the AWS event-stream wire format. AWS_BEDROCK_SKIP_AUTH=1 and AWS_BEDROCK_FORCE_HTTP1=1 are set.

  • Flow: the DM "What is in shape.png?" leads the model's first turn to call read(<workspace>\shape.png), and the Gateway then sends that tool result back to Bedrock.
  • Validation rule: the stand-in applies the rule from this issue. The four routes return 400 ValidationException ("This model doesn't support the image field for user messages. Remove image and try again.") whenever an image is nested in toolResult.content. Every other request is answered.
  • Logging: each line below is one ConverseStream request as the stand-in received it.

live run

route main 903394cceb1 this branch 5691b44e02e
global.openai.gpt-6.1-sol image nested in toolResult → 400 ValidationException ×4 (retries). Telegram gets "⚠️ OpenClaw couldn't finish this reply…" toolResult without an image plus a sibling user image → answered. Telegram gets "shape.png shows a red square with a color gradient."
global.moonshotai.kimi-k3 not run on main sibling user image → answered
global.anthropic.claude-sonnet-4-6 (control) not run on main nested layout unchanged → answered

The stand-in only encodes the reporter's measured validation rule; it is not real Bedrock. The real-service comparison is the reporter's 24 live Converse requests in #186753.

Not covered

There is no output from real AWS ConverseStream on the three added routes. This environment has no AWS account or Bedrock credentials. The real-service evidence for these routes is the reporter's 24 live Converse requests in #186753: the nested layout is rejected and the sibling layout is accepted and interpreted on all four OpenAI/Kimi routes. This PR only selects the existing #149336 relocation for those routes, and the payload test plus the live Gateway run show the exact wire layout the fix sends. A maintainer with Bedrock access can confirm with one read of a PNG on global.openai.gpt-6.1-sol.

…mi K3

These Bedrock routes reject images nested in toolResult content like GPT-5.6 Sol does. Reuse the existing relocation for them, moved to a sibling module because stream.runtime.ts is over its line cap.

Fixes openclaw#186753
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Extends Bedrock’s existing tool-image relocation to GPT-6 Sol, GPT-6.1 Sol, and Kimi K3.

Example: The read tool returns shape.png while using global.openai.gpt-6.1-sol.

  • Before: The image remains inside toolResult.content, producing the reported validation failure.
  • After: The request carries the image in a labeled sibling block while preserving its tool-result association.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation appears correct, but useful transport-boundary evidence still leaves the external-PR behavior-proof gate unmet.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An image-returning tool makes the next Bedrock request fail on GPT-6 Sol, GPT-6.1 Sol, and Kimi K3.
Reason: The report establishes an official-release defect, and the patch extends an already accepted repair only to demonstrated affected routes.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR repairs a concrete Bedrock serialization bug still present on current main, and no introduced correctness defect was found; the competing PR does not yet safely supersede it.

Priority: P2
Reviewed head: 5691b44e02e293ccb378dc7759d969e2e82182d3

Before merge

  • Add real behavior proof - The inspected screenshot exercises the patched serializer through a real Gateway and AWS transport client against local Telegram and ConverseStream stand-ins, showing the corrected wire layout and scripted completion. It does not establish actual AWS ConverseStream acceptance or image interpretation on the added routes; the reporter’s live comparison used Converse, while the predecessor’s streaming proof covered GPT-5.6 only. Supply redacted after-fix service output, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Provide after-fix output from actual AWS ConverseStream on the added routes, showing synthetic tool images accepted and interpreted through the patched provider with a completed turn.
Agent review details

How this fits together

The Amazon Bedrock plugin converts conversation history and tool results into AWS ConverseStream requests and converts streamed responses into assistant events.

flowchart TD
  A[Conversation and tool results] --> B[Bedrock serializer]
  B --> C[Model route selector]
  C --> D[Labeled sibling images]
  C --> E[Nested tool images]
  D --> F[AWS ConverseStream]
  E --> F
  F --> G[Assistant response]
Loading

Technical review

Best possible solution:

Keep the demonstrated route additions in the existing Bedrock serialization owner while preserving image bytes, contiguous tool results, associations, status, and stored history.

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

Current-main source deterministically emits the reported nested layout for the additional routes, corroborated by the official-release report and controlled service comparisons; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch reuses the accepted provider-local repair without adding configuration or public APIs, and its small extraction is justified by the existing line-cap ratchet.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3e1e3652ff25.

Provenance checked

  • Tool-result image relocation keeps the original intent (115522a: Repair affected concrete routes while keeping tool results contiguous, labeling image associations, and preserving original history.)
  • Image-preservation regression keeps the original intent (b22db9c: Consolidate Bedrock accounting and replay coverage into the existing runtime suite without another overlapping test layer.)
  • Tool-free history replay keeps the original intent (79c67a0: Replay completed tool evidence as text when settled-turn finalization intentionally disables tools and omits toolConfig.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +21, Tests +5. Total +26 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 48 27 +21
Tests 1 49 44 +5
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 97 71 +26

Root-cause cluster

Relationship: same_root_cause
Canonical: #186753
Summary: Both open PRs repair the same missing Bedrock route selection tracked by the canonical issue.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Image-returning tool continuations fail on three specific Bedrock routes, giving this repair concrete value with limited provider scope.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 28, 2026, 11:23 AM ET / 15:23 UTC.

@wr-web

wr-web commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Closing this to stay within the repository's limit of 20 active PRs per author, because it is waiting on a live Amazon Bedrock run that I cannot provide here. The branch stays available, and I can reopen it if someone can supply that.

@wr-web wr-web closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: amazon-bedrock P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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.

Bedrock tool-returned images fail on GPT-6/6.1 Sol and Kimi K3; workaround only covers GPT-5.6 Sol

1 participant