Skip to content

fix(amazon-bedrock): tool-returned images fail on GPT-6/6.1 Sol and Kimi K3 - #187159

Closed
beezly wants to merge 2 commits into
openclaw:mainfrom
beezly:fix/bedrock-tool-result-image-allowlist
Closed

beezly wants to merge 2 commits into
openclaw:mainfrom
beezly:fix/bedrock-tool-result-image-allowlist

Conversation

@beezly

@beezly beezly commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #186753

What Problem This Solves

Fixes: image-reading tools fail with Validation error: This model doesn't support the image field for user messages on Amazon Bedrock GPT-6 Sol, GPT-6.1 Sol and Kimi K3 (and any other non-Nova/non-Claude route), because OpenClaw nests tool-returned images inside toolResult.content.

User Impact

User impact: agents on any Bedrock route can read images returned by tools; Nova and Claude keep today's nested layout unchanged.

Why This Change Was Made

AWS documents ToolResultContentBlock.image as supported only by Amazon Nova and Anthropic Claude. The previous fix (#149336) special-cased openai.gpt-5.6-sol, so every new route needed another name match (as #186834 / #186835 propose). This change inverts the selector: Nova and Claude keep nested images, and every other route, including unknown routes and opaque application-inference-profile ARNs, uses the existing labeled sibling-image relocation, which was accepted by every route tested, Nova and Claude included. Claude detection reuses the existing isAnthropicClaudeModel, so Claude behind an application profile with a Claude name/canonical id stays nested.

The relocation body moved unchanged into tool-result-images.ts. stream.runtime.ts was already over its line cap, and the line-cap ratchet rejects any growth there.

Route policy: why unknown routes default to sibling images

The earlier fix (#149336) kept unknown and opaque routes on the nested layout. This PR deliberately reverses that default, for three reasons:

  1. AWS only documents nested tool-result images for Nova and Claude. Nesting them on any other route relies on behaviour AWS doesn't document. Plain user image blocks are the documented Converse/ConverseStream input for every image-capable model.
  2. When the guess is wrong, the costs are very different.
    • Nested on a route that doesn't support it: the request is rejected with ValidationException, retries hit the same error, and the user's turn fails. That is the bug in Bedrock tool-returned images fail on GPT-6/6.1 Sol and Kimi K3; workaround only covers GPT-5.6 Sol #186753, and it has now been reported for four routes.
    • Sibling on a route that would have accepted nested: the request still succeeds. Each image stays tied to its tool call through the Images from tool result <id> label and the placeholder text. This layout was accepted on every route tested: Nova Pro and Claude Sonnet/Opus 5.5 in this PR's ConverseStream runs, and eight Claude routes in the issue's Converse comparison.
  3. Matching by name never finishes. Every new non-Nova, non-Claude model on Bedrock would need another selector patch (fix(bedrock): tool-returned images fail on non-Claude routes such as GPT-6/6.1 Sol and Kimi K3 #186834 and fix(amazon-bedrock): lift tool-result images for GPT-6/6.1 Sol and Kimi K3 #186835 each add one). The documented allowlist stays fixed.

Opaque inference profiles: Claude behind an application profile is still recognised by its name or canonical model id (the existing isAnthropicClaudeModel), so it keeps the nested layout. Nova behind an opaque ARN gets the sibling layout. Nova accepts that, so the only cost is losing nested placement, not the request.

The change is limited to the Bedrock provider, adds no config option, and can be reverted in one line if a maintainer prefers the old default.

Evidence

Regression test (stream.runtime.test.ts: the existing relocation test is now a route table. GPT-6.1 Sol, Kimi K3 and an opaque profile ARN are lifted; Nova and Claude stay nested. Net zero test lines, to satisfy the test-lines ratchet): red on origin/main (global.openai.gpt-6.1-sol assertion), green with the fix.

node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-providers.config.ts extensions/amazon-bedrock
 Test Files  13 passed (13)
      Tests  160 passed (160)

Live Bedrock ConverseStream through streamSimpleBedrock (us-east-1, synthetic 64×64 PNG with a red square and a blue circle; one assistant turn with two parallel tool calls, one returning the image and one returning status: GREEN-42):

Route main This PR
global.openai.gpt-6-sol ❌ ValidationException (image field) ✅ "a red square and a blue circle … GREEN-42"
global.openai.gpt-6.1-sol ❌ ValidationException (image field) ✅
global.moonshotai.kimi-k3 ❌ ValidationException (image field) ✅
global.openai.gpt-5.6-sol ✅ ✅
us.amazon.nova-pro-v1:0 (nested) ✅ ✅
global.anthropic.claude-sonnet-5-5 (nested) ✅ ✅
global.anthropic.claude-opus-5-5 (nested) — ✅

The input context was byte-identical after every request, so stored history is not rewritten.

Real agent turn (openclaw agent exec --config <pinned bedrock config> --cwd <dir with shapes.png + status.txt>, prompt asks for both files to be read with the read tool in one step):

  • main, GPT-6.1 Sol: status: "error", Validation error: This model doesn't support the image field for user messages. Remove image and try again. after 5 retried model requests.
  • This PR, GPT-6.1 Sol: ok, "The image shows a red square on the left and a blue circle on the right. “status: GREEN-42”"
  • This PR, Kimi K3: ok, "…a red square on the left and a blue circle on the right. Status line: status: GREEN-42"
  • This PR, Claude Sonnet 5.5: ok, "…a red square on the left and a blue circle on the right, on a white background. The status line reads: "status: GREEN-42""

Gates: pnpm check:changed: all lanes green (typecheck extensions/tests, lint, format, line-cap ratchet, plugin boundaries) except dead export scan. That lane reports 86 existing unused exports, all under src/ (gateway, infra, agents, sessions), and none in extensions/amazon-bedrock. git diff --check clean.

Gap: the live agent proof used the embedded agent exec path rather than a separate Gateway process. The provider stream path exercised is the same.

…imi K3

Only Amazon Nova and Anthropic Claude accept images nested in
toolResult.content (per the AWS ToolResultContentBlock docs). Invert the
selector so those routes keep the nested layout and every other route,
including unknown and opaque inference-profile routes, gets the existing
labeled sibling-image relocation instead of a GPT-5.6-only special case.

The relocation moves into tool-result-images.ts to keep stream.runtime.ts
within the line-cap ratchet.

Closes openclaw#186753
@clawsweeper

clawsweeper Bot commented Oct 29, 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: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR keeps tool-returned images nested for recognized Nova and Claude models and relocates them into labeled sibling blocks for other Bedrock routes.

Example: An agent using global.openai.gpt-6.1-sol reads shapes.png and status.txt.

  • Before: The image continuation fails with a Bedrock validation error after repeated requests.
  • After: The agent identifies the red square and blue circle and returns status: GREEN-42.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Concrete live behavior and passing current-head checks support the implementation; readiness remains capped by the unresolved route-default decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The body supplies real Bedrock ConverseStream results and shipped agent exec output: GPT-6.1 and Kimi identify the synthetic image and return GREEN-42, with Claude as a control; the subsequent commit changes only test organization, so that production proof remains applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Image-reading tools cause Bedrock agent turns to fail on GPT-6 Sol, GPT-6.1 Sol, and Kimi K3.
Reason: The demonstrated failure warrants repair, but changing unknown-route behavior beyond the verified models reverses an explicitly approved compatibility choice.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR repairs a demonstrated Bedrock failure without an identified code defect; replacing the previously approved default for unknown routes still needs an owner decision.

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

Decision needed

  • Question: Should unrecognized and opaque Bedrock routes default to labeled sibling images instead of preserving nested tool-result images?
  • Recommendation: Approve the Nova and Claude allowlist: Accept this PR's default: preserve nesting for recognized Nova and Claude models and use the existing sibling layout elsewhere.
  • Why: The original merged repair explicitly preserved opaque layouts; this PR supplies a documented and tested rationale for changing that policy, but no maintainer has approved the broader direction.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

The Amazon Bedrock provider converts agent conversation and tool results into ConverseStream requests, then converts streamed responses into agent events.

flowchart LR
  A[Agent conversation] --> B[Bedrock serializer]
  B --> C[Recognized Nova or Claude]
  B --> D[Other or opaque route]
  C --> E[Nested tool images]
  D --> F[Labeled sibling images]
  E --> G[Bedrock ConverseStream]
  F --> G
Loading

Technical review

Best possible solution:

Keep one provider-local serializer and its existing relocation algorithm, with an owner-approved rule for unknown and opaque routes.

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

Current-main source selects relocation only for GPT-5.6 Sol, matching the official-release report and supplied before-fix validation errors on the other affected routes; no target code was executed during this review.

Is this the best way to solve the issue?

The existing relocation is reused without a competing path, and its small extraction is justified by the runtime file's enforced size limit; the broader route default is a defensible owner choice rather than an established defect.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 00125bb5bbc0.

Provenance checked

  • Bedrock tool-image placement and opaque-route default changes intended behavior with a stated reason (115522a: Repair the observed GPT-5.6 rejection while preserving opaque layouts, tool ordering, image association, status, and stored history.)
  • Consolidated image-placement regression keeps the original intent (b22db9c: Consolidate Bedrock owner-boundary coverage in the existing runtime suite while removing overlapping test scaffolding.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

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

View PR surface stats
Area Files Added Removed Net
Source 2 48 27 +21
Tests 1 26 26 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 74 53 +21

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #186753
Summary: These candidates address the same missing tool-image relocation, while this PR additionally changes the policy for unknown routes.

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 specific Bedrock routes; the repair has concrete value within a limited provider surface.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-29T01:58:05.475Z sha 9a6f648 :: blocked before merge. :: none

Reviewed October 29, 2026, 3:57 AM ET / 07:57 UTC (Revision 2).

Table the nested-vs-lifted expectations per route so the regression adds
no net test lines (test-lines ratchet).
@beezly

beezly commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 29, 2026
@beezly

beezly commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@obviyus: you merged #149336, which scoped Bedrock tool-result image relocation to GPT-5.6 Sol and kept unknown routes nested. This PR (fixing #186753) reverses that default: only Nova and Claude stay nested, which matches the AWS ToolResultContentBlock docs, and every other route gets the sibling layout. The reasoning and the live before/after ConverseStream and agent evidence are in the PR body under "Route policy". CI is green and ClawSweeper found no code issues. It's blocked only on whether you're OK changing the unknown-route default. #186834 and #186835 fix the same issue by adding more model-name matches, so whichever approach is chosen, the others can probably be closed.

obviyus added a commit that referenced this pull request Nov 27, 2026
…GPT-6/6.1 Sol and Kimi K3 (#186834)

Root cause: `extensions/amazon-bedrock/stream.runtime.ts:970` moved tool-returned images out of `toolResult.content` only when `model.id.includes("openai.gpt-5.6-sol")`, so every other route sent them nested, a layout AWS documents only for Claude and Nova and that GPT-6/6.1 Sol and Kimi K3 reject with `ValidationException`.

Fixes #186753

## What Problem This Solves

Fixes: on Amazon Bedrock, a turn fails with "The agent run failed before producing a reply." after a tool such as `read` returns an image, on GPT-6 Sol, GPT-6.1 Sol, Kimi K3 and any application inference profile that points at them.

## User Impact

User impact: image-returning tools work on every non-Claude Bedrock route, including opaque application-inference-profile ARNs and models that ship later, without a code change per model. Claude requests are byte-for-byte unchanged. No config or migration.

## Why This Change Was Made

#149336 added the sibling layout (tool results first, then a labeled user image group per result, no history rewrite) for one route name. Each new route that rejects nested images was a user-visible failure until someone added its name, and opaque ARNs never matched.

This flips the default: only Claude keeps images nested, using the `isAnthropicClaudeModel` predicate this file already uses for signatures and caching. Every other route gets the sibling layout, which the reporter's 24-request Converse matrix shows every tested route accepts. A wrong guess now still completes the turn instead of failing it. Production change: one line, net 0.

Two consequences, named on purpose:

- **Nova moves from nested to sibling.** AWS documents nested images for Nova, and only Nova Pro has been seen to accept the sibling layout (#187159's live run). I chose not to add an `amazon.nova` name match: sibling user images are documented for Converse, and the tool-free replay path in this file already sends tool images as plain user images on every model.
- **`isAnthropicClaudeModel` also matches a model whose `name` contains "claude".** A non-Claude profile named, say, "claude-replacement" would keep the nested layout. That is the same exposure signature replay has today.

A non-Claude session that already holds a tool image gets one prompt-cache miss on its next request, because the replayed layout changes once.

Credit: @beezly reported this with the full route matrix and proposed this exact inversion (#187159); @yousan opened the first fix and ran a live Kimi K3 ConverseStream turn with the sibling layout. This PR keeps yousan's commit and replaces its name list with the inverted default.

## Evidence

- Regression: `stream.runtime.test.ts` › "lifts non-Claude tool images into user content, keeping result associations" now uses an opaque application-inference-profile ARN for the lifted case (red on base: images stay nested) and a Claude id for the nested control.
- End to end, built `dist/` on both sides, isolated Gateway, one `openclaw agent` turn whose `read` returns a PNG, against a local ConverseStream server that enforces the observed rule (nested image on a non-Claude/non-Nova model -> 400 `ValidationException` with AWS's message; otherwise the reply carries the SHA-256 of each image it received). Results: #186834 (comment)
- Limit: the local server encodes the observed rule, so it cannot prove that Nova accepts the sibling layout; only a live AWS call can.

Merge danger: two-way door. A revert restores the old layout; nothing is stored or migrated (transcript rows are unchanged; only the request built from them differs). Blast radius: Bedrock ConverseStream requests that replay a tool result containing an image, on non-Claude models.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: clord-dispatch <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this fix. The same root cause landed in #186834 (95e6470), which credits your work, so I'm closing this one as covered.

@obviyus obviyus closed this Nov 27, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…GPT-6/6.1 Sol and Kimi K3 (#186834)

Root cause: `extensions/amazon-bedrock/stream.runtime.ts:970` moved tool-returned images out of `toolResult.content` only when `model.id.includes("openai.gpt-5.6-sol")`, so every other route sent them nested, a layout AWS documents only for Claude and Nova and that GPT-6/6.1 Sol and Kimi K3 reject with `ValidationException`.

Fixes #186753

## What Problem This Solves

Fixes: on Amazon Bedrock, a turn fails with "The agent run failed before producing a reply." after a tool such as `read` returns an image, on GPT-6 Sol, GPT-6.1 Sol, Kimi K3 and any application inference profile that points at them.

## User Impact

User impact: image-returning tools work on every non-Claude Bedrock route, including opaque application-inference-profile ARNs and models that ship later, without a code change per model. Claude requests are byte-for-byte unchanged. No config or migration.

## Why This Change Was Made

#149336 added the sibling layout (tool results first, then a labeled user image group per result, no history rewrite) for one route name. Each new route that rejects nested images was a user-visible failure until someone added its name, and opaque ARNs never matched.

This flips the default: only Claude keeps images nested, using the `isAnthropicClaudeModel` predicate this file already uses for signatures and caching. Every other route gets the sibling layout, which the reporter's 24-request Converse matrix shows every tested route accepts. A wrong guess now still completes the turn instead of failing it. Production change: one line, net 0.

Two consequences, named on purpose:

- **Nova moves from nested to sibling.** AWS documents nested images for Nova, and only Nova Pro has been seen to accept the sibling layout (#187159's live run). I chose not to add an `amazon.nova` name match: sibling user images are documented for Converse, and the tool-free replay path in this file already sends tool images as plain user images on every model.
- **`isAnthropicClaudeModel` also matches a model whose `name` contains "claude".** A non-Claude profile named, say, "claude-replacement" would keep the nested layout. That is the same exposure signature replay has today.

A non-Claude session that already holds a tool image gets one prompt-cache miss on its next request, because the replayed layout changes once.

Credit: @beezly reported this with the full route matrix and proposed this exact inversion (#187159); @yousan opened the first fix and ran a live Kimi K3 ConverseStream turn with the sibling layout. This PR keeps yousan's commit and replaces its name list with the inverted default.

## Evidence

- Regression: `stream.runtime.test.ts` › "lifts non-Claude tool images into user content, keeping result associations" now uses an opaque application-inference-profile ARN for the lifted case (red on base: images stay nested) and a Claude id for the nested control.
- End to end, built `dist/` on both sides, isolated Gateway, one `openclaw agent` turn whose `read` returns a PNG, against a local ConverseStream server that enforces the observed rule (nested image on a non-Claude/non-Nova model -> 400 `ValidationException` with AWS's message; otherwise the reply carries the SHA-256 of each image it received). Results: #186834 (comment)
- Limit: the local server encodes the observed rule, so it cannot prove that Nova accepts the sibling layout; only a live AWS call can.

Merge danger: two-way door. A revert restores the old layout; nothing is stored or migrated (transcript rows are unchanged; only the request built from them differs). Blast radius: Bedrock ConverseStream requests that replay a tool result containing an image, on non-Claude models.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: clord-dispatch <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 95e6470)
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…GPT-6/6.1 Sol and Kimi K3 (#186834)

Root cause: `extensions/amazon-bedrock/stream.runtime.ts:970` moved tool-returned images out of `toolResult.content` only when `model.id.includes("openai.gpt-5.6-sol")`, so every other route sent them nested, a layout AWS documents only for Claude and Nova and that GPT-6/6.1 Sol and Kimi K3 reject with `ValidationException`.

Fixes #186753

## What Problem This Solves

Fixes: on Amazon Bedrock, a turn fails with "The agent run failed before producing a reply." after a tool such as `read` returns an image, on GPT-6 Sol, GPT-6.1 Sol, Kimi K3 and any application inference profile that points at them.

## User Impact

User impact: image-returning tools work on every non-Claude Bedrock route, including opaque application-inference-profile ARNs and models that ship later, without a code change per model. Claude requests are byte-for-byte unchanged. No config or migration.

## Why This Change Was Made

#149336 added the sibling layout (tool results first, then a labeled user image group per result, no history rewrite) for one route name. Each new route that rejects nested images was a user-visible failure until someone added its name, and opaque ARNs never matched.

This flips the default: only Claude keeps images nested, using the `isAnthropicClaudeModel` predicate this file already uses for signatures and caching. Every other route gets the sibling layout, which the reporter's 24-request Converse matrix shows every tested route accepts. A wrong guess now still completes the turn instead of failing it. Production change: one line, net 0.

Two consequences, named on purpose:

- **Nova moves from nested to sibling.** AWS documents nested images for Nova, and only Nova Pro has been seen to accept the sibling layout (#187159's live run). I chose not to add an `amazon.nova` name match: sibling user images are documented for Converse, and the tool-free replay path in this file already sends tool images as plain user images on every model.
- **`isAnthropicClaudeModel` also matches a model whose `name` contains "claude".** A non-Claude profile named, say, "claude-replacement" would keep the nested layout. That is the same exposure signature replay has today.

A non-Claude session that already holds a tool image gets one prompt-cache miss on its next request, because the replayed layout changes once.

Credit: @beezly reported this with the full route matrix and proposed this exact inversion (#187159); @yousan opened the first fix and ran a live Kimi K3 ConverseStream turn with the sibling layout. This PR keeps yousan's commit and replaces its name list with the inverted default.

## Evidence

- Regression: `stream.runtime.test.ts` › "lifts non-Claude tool images into user content, keeping result associations" now uses an opaque application-inference-profile ARN for the lifted case (red on base: images stay nested) and a Claude id for the nested control.
- End to end, built `dist/` on both sides, isolated Gateway, one `openclaw agent` turn whose `read` returns a PNG, against a local ConverseStream server that enforces the observed rule (nested image on a non-Claude/non-Nova model -> 400 `ValidationException` with AWS's message; otherwise the reply carries the SHA-256 of each image it received). Results: #186834 (comment)
- Limit: the local server encodes the observed rule, so it cannot prove that Nova accepts the sibling layout; only a live AWS call can.

Merge danger: two-way door. A revert restores the old layout; nothing is stored or migrated (transcript rows are unchanged; only the request built from them differs). Blast radius: Bedrock ConverseStream requests that replay a tool result containing an image, on non-Claude models.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: clord-dispatch <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 95e6470)
Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…GPT-6/6.1 Sol and Kimi K3 (openclaw#186834)

Root cause: `extensions/amazon-bedrock/stream.runtime.ts:970` moved tool-returned images out of `toolResult.content` only when `model.id.includes("openai.gpt-5.6-sol")`, so every other route sent them nested, a layout AWS documents only for Claude and Nova and that GPT-6/6.1 Sol and Kimi K3 reject with `ValidationException`.

Fixes openclaw#186753

## What Problem This Solves

Fixes: on Amazon Bedrock, a turn fails with "The agent run failed before producing a reply." after a tool such as `read` returns an image, on GPT-6 Sol, GPT-6.1 Sol, Kimi K3 and any application inference profile that points at them.

## User Impact

User impact: image-returning tools work on every non-Claude Bedrock route, including opaque application-inference-profile ARNs and models that ship later, without a code change per model. Claude requests are byte-for-byte unchanged. No config or migration.

## Why This Change Was Made

openclaw#149336 added the sibling layout (tool results first, then a labeled user image group per result, no history rewrite) for one route name. Each new route that rejects nested images was a user-visible failure until someone added its name, and opaque ARNs never matched.

This flips the default: only Claude keeps images nested, using the `isAnthropicClaudeModel` predicate this file already uses for signatures and caching. Every other route gets the sibling layout, which the reporter's 24-request Converse matrix shows every tested route accepts. A wrong guess now still completes the turn instead of failing it. Production change: one line, net 0.

Two consequences, named on purpose:

- **Nova moves from nested to sibling.** AWS documents nested images for Nova, and only Nova Pro has been seen to accept the sibling layout (openclaw#187159's live run). I chose not to add an `amazon.nova` name match: sibling user images are documented for Converse, and the tool-free replay path in this file already sends tool images as plain user images on every model.
- **`isAnthropicClaudeModel` also matches a model whose `name` contains "claude".** A non-Claude profile named, say, "claude-replacement" would keep the nested layout. That is the same exposure signature replay has today.

A non-Claude session that already holds a tool image gets one prompt-cache miss on its next request, because the replayed layout changes once.

Credit: @beezly reported this with the full route matrix and proposed this exact inversion (openclaw#187159); @yousan opened the first fix and ran a live Kimi K3 ConverseStream turn with the sibling layout. This PR keeps yousan's commit and replaces its name list with the inverted default.

## Evidence

- Regression: `stream.runtime.test.ts` › "lifts non-Claude tool images into user content, keeping result associations" now uses an opaque application-inference-profile ARN for the lifted case (red on base: images stay nested) and a Claude id for the nested control.
- End to end, built `dist/` on both sides, isolated Gateway, one `openclaw agent` turn whose `read` returns a PNG, against a local ConverseStream server that enforces the observed rule (nested image on a non-Claude/non-Nova model -> 400 `ValidationException` with AWS's message; otherwise the reply carries the SHA-256 of each image it received). Results: openclaw#186834 (comment)
- Limit: the local server encodes the observed rule, so it cannot prove that Nova accepts the sibling layout; only a live AWS call can.

Merge danger: two-way door. A revert restores the old layout; nothing is stored or migrated (transcript rows are unchanged; only the request built from them differs). Blast radius: Bedrock ConverseStream requests that replay a tool result containing an image, on non-Claude models.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: clord-dispatch <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
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: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

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

2 participants