Repository navigation
fix(bedrock): preserve images returned by tools - #149336
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 12:11 AM ET / 04:11 UTC (Revision 5). ClawSweeper reviewWhat this changesThe Bedrock provider moves tool-returned images into labeled user-content blocks on affected routes, preserving tool-result order, image bytes, and conversation history. Merge readiness✅ Ready for maintainer review The fix remains necessary and has convincing live AWS proof. Earlier ordering and association concerns are resolved, the draft hold has been lifted, and no blocking defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Amazon Bedrock plugin converts OpenClaw conversation messages and tool results into AWS Converse streaming requests. Its serializer determines whether the model receives and can interpret images returned by tools. flowchart TD
A[Conversation and tool results] --> B[Bedrock serializer]
B --> C{Affected model route?}
C -->|Yes| D[Tool results followed by labeled images]
C -->|No| E[Existing content layout]
D --> F[AWS Converse stream]
E --> F
F --> G[Assistant response]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +27, Tests +108. Total +135 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the route-specific adaptation in the existing Bedrock serializer, with deterministic image associations and unchanged stored transcripts. Do we have a high-confidence way to reproduce the issue? Yes: current main emits the nested tool-image layout rejected in the linked issue's synthetic AWS comparison; the contributor supplies a concrete paired reproduction. This review inspected source and recorded evidence without executing AWS requests. Is this the best way to solve the issue? Yes: adapting the AWS request at its existing serializer preserves the supported tool-image behavior without adding configuration, rewriting transcripts, or changing unrelated routes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8e98d20f4d3e. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
@clawsweeper re-review Added real after-fix evidence to the PR body: streamSimpleBedrock compiled from the reviewed PR head called actual AWS Bedrock (no transport mocks), consumed a synthetic tool-returned image, and completed with “Red square; blue circle.” The image content was not described in the prompt. Includes captured output, reproducible fixture generator and harness, terminal success, and unchanged-history assertion. No private data or infrastructure details are included. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Yigtwxx
left a comment
There was a problem hiding this comment.
Reviewed head 0d3b19a3c73 (Node 24.21.0). The two new cases are green on the head and both go red when the model gate is mutated (includes("openai.gpt-5.6-sol") -> a non-matching string), so the regression pins the branch. I cannot run the live Bedrock leg; the notes below are about the request shape the tests lock in versus the one shape the live proof covers.
1. The only shape with live evidence is one tool result + one image; the shape the test pins for multiple results is the interleaved one, which is the contestable case.
The test asserts a single user message ordered [toolResult A, image, image, toolResult B, image, toolResult C] (stream.runtime.accounting-replay.test.ts, the input.messages expectation). The live harness in the body sends [toolResult, image] only. If Bedrock maps this model's Converse messages onto the OpenAI message contract one block at a time (which is what "accepts user images but rejects images inside tool results" suggests), then the [toolResult A, image, toolResult B] order puts a user-image item between two tool outputs of the same assistant turn. That is precisely the ordering OpenAI's chat contract refuses: every tool output must follow the assistant tool_calls message contiguously before any other message. The single-result shape is fine under that rule, the multi-result shape is not, and the multi-result shape is the one production will hit whenever an agent calls two image-returning tools in one turn (browser screenshot + file preview is a routine pair).
The repository already has the safe shape for OpenAI-style targets: packages/ai/src/openai-completions-messages.ts:255-297 emits every tool message first, then one user message that carries all images, each group prefixed with Image(s) from tool result #N (toolName):. Two ways to close this:
- Keep the current interleaving and add a live run with two tool calls that both return an image (same harness, one more
toolCall/toolResultpair). If Bedrock accepts it, the test's ordering is proven and I have nothing further. - Or reorder to
[...toolResults, ...images]inside the same user message, with the per-result label instead of "attached immediately after this result". That shape is valid under both contracts this could map to (OpenAI's contiguous tool outputs, and the toolResult-first layout the Converse tool-use flow documents), and it is what the rest of the codebase does for the same problem, so it needs no second live run to be believed.
Either is small; I would not merge the interleaved ordering on the strength of the single-result proof alone.
2. The association placeholder depends on order being preserved by the translation layer.
"Images returned by this tool are attached immediately after this result." is only true if the block order survives into whatever the model sees. With three results and three images in one message the model has no other way to tell which image belongs to which call. The label used by the completions path (#N (toolName)) carries the association in the text itself and survives any reordering, and describeToolResultMediaPlaceholder (packages/ai/src/providers/tool-result-text.ts:146) already produces the in-result "(see attached image)" marker that createBedrockToolResult uses on the text-only fallback, so both strings exist and are shared today. Minor, but it comes for free with option 2 above.
3. Small, non-blocking: the completions path gates the relocation on model.input.includes("image"); here the images are emitted regardless. Not a regression versus main (the nested path did not gate either), just noting the difference in case the maintainers want the two paths to agree.
Scope check: git grep -n "toolResult" origin/main -- extensions/amazon-bedrock-mantle finds no Converse-style tool-result serialization in the Mantle extension, so this file is the only place the nested shape is built for Bedrock.
|
Thank you @Yigtwxx for the careful review and for identifying the multi-result ordering and association gap. I took the tool-results-first approach and also added real multi-tool behavior proof. Changes:
Validation:
Only generated images and generic tool IDs are used below. No private documents, account information, host details, or conversation content are included. Please re-review the revised ordering and evidence. Reproducible two-tool synthetic live testBuild the provider from the revised PR checkout: pnpm exec esbuild extensions/amazon-bedrock/stream.runtime.ts --bundle --platform=node --format=esm --packages=external --outfile=pr-provider-v2.mjsGenerate both fixtures: from PIL import Image, ImageDraw
im = Image.new('RGB', (384, 256), 'white')
d = ImageDraw.Draw(im)
d.rectangle((24, 56, 144, 176), fill='#e02020')
d.ellipse((230, 70, 330, 170), fill='#2040e0')
im.save('synthetic.png')
im = Image.new('RGB', (384, 256), 'white')
d = ImageDraw.Draw(im)
d.polygon([(192, 30), (50, 220), (334, 220)], fill='#20a040')
im.save('synthetic-second.png')Run this harness alongside the provider and images, with the normal AWS credential chain configured and runtime dependencies available: import { readFileSync } from 'node:fs';
import { createHash } from 'node:crypto';
import { streamSimpleBedrock } from './pr-provider-v2.mjs';
const model = {id:'us.openai.gpt-5.6-sol',name:'GPT-5.6 Sol',api:'bedrock-converse-stream',provider:'amazon-bedrock',baseUrl:'https://bedrock-runtime.us-east-1.amazonaws.com',reasoning:true,input:['text','image'],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:200000,maxTokens:4096};
const image = readFileSync(new URL('./synthetic.png',import.meta.url));
const secondImage = readFileSync(new URL('./synthetic-second.png',import.meta.url));
const usage = {input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};
const context = {messages:[
{role:'user',content:'Inspect both tool results. For each tool call ID, state the colors and shapes in its image. Be brief.',timestamp:1},
{role:'assistant',content:[{type:'toolCall',id:'call_inspect',name:'inspect',arguments:{}},{type:'toolCall',id:'call_second',name:'inspect',arguments:{}}],api:model.api,provider:model.provider,model:model.id,usage,stopReason:'toolUse',timestamp:2},
{role:'toolResult',toolCallId:'call_inspect',toolName:'inspect',content:[{type:'image',mimeType:'image/png',data:image.toString('base64')}],isError:false,timestamp:3},
{role:'toolResult',toolCallId:'call_second',toolName:'inspect',content:[{type:'image',mimeType:'image/png',data:secondImage.toString('base64')}],isError:false,timestamp:4}
],tools:[{name:'inspect',description:'Returns a synthetic test image.',parameters:{type:'object',properties:{},required:[]}}]};
const before=JSON.stringify(context);
console.log(JSON.stringify({entrypoint:'streamSimpleBedrock',test:'two image-returning tools in one assistant turn',transport:'real AWS SDK ConverseStream (no mocks)',model:model.id,imageBytes:image.length,imageSHA256:createHash('sha256').update(image).digest('hex'),inputImageLocation:'toolResult.content only',prompt:context.messages[0].content}));
const events=[];
const stream=streamSimpleBedrock(model,context,{region:'us-east-1',maxTokens:1024,signal:AbortSignal.timeout(90000)});
for await (const event of stream) {events.push(event.type);}
const result=await stream.result();
console.log(JSON.stringify({events,stopReason:result.stopReason,text:result.content.filter(x=>x.type==='text').map(x=>x.text).join(''),error:result.errorMessage,historyUnchanged:before===JSON.stringify(context)}));
const text=result.content.filter(x=>x.type==='text').map(x=>x.text).join('');
if(result.stopReason!=='stop' || before!==JSON.stringify(context) || !/red/i.test(text) || !/blue/i.test(text) || !/green/i.test(text) || !/triangle/i.test(text) || !text.includes('call_second') || !text.includes('call_inspect')) process.exitCode=1;Captured application stdout: {"entrypoint":"streamSimpleBedrock","test":"two image-returning tools in one assistant turn","transport":"real AWS SDK ConverseStream (no mocks)","model":"us.openai.gpt-5.6-sol","imageBytes":1349,"imageSHA256":"f64971d2df26aaad98b1757a110b8dcdbc2d4454db363b50826b7aecb1eb869a","inputImageLocation":"toolResult.content only","prompt":"Inspect both tool results. For each tool call ID, state the colors and shapes in its image. Be brief."}
{"events":["start","thinking_start","thinking_end","text_start","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_delta","text_end","done"],"stopReason":"stop","text":"- `call_inspect`: red square and blue circle.\n- `call_second`: green triangle.","historyUnchanged":true}
|
Yigtwxx
left a comment
There was a problem hiding this comment.
Re-reviewed head 337283d4987. Both points from my earlier note are closed:
- Ordering: every consecutive
toolResultnow precedes the lifted images in the same user message (toolResults.map+userContent.push(...attachedImages)), and the association is carried by the text (Images from tool result <toolUseId>:group label, matching(see attached images labeled …)marker inside the result), so it no longer depends on adjacency. The two-tool live run answering per call ID is the shape that was missing. - Test: 36/36 on the head. Mutation check: moving the image groups back between the first and second result (
userContent.splice(1, 0, ...attachedImages)) turns both model-ID cases red, so the contiguous ordering is what the suite pins, not just block membership.
Nothing further from me.
|
landpr-approve-admin-merge |
|
Thanks @dclosefuturex! Proof: Your real-network two-tool run confirmed image interpretation and association. An authenticated Gateway check also completed with a recording transport and preserved the original transcript rows and PNG bytes.
|
## What Problem This Solves Tool-returned images make the next request fail with `ValidationException` on affected Bedrock routes. Fixes openclaw#149332. ## Why This Change Was Made The serializer generates image labels from each tool-call ID; input images need no labels. All consecutive tool results come first, followed by image groups in the same tool order. Request state has one writer. `stream.runtime.ts`: +28/−1 for this conversion. Growth accepted under the owner's standing acceptance (2026-09-15). ## User Impact Image-reading turns can finish without losing image bytes, tool associations, or error status. ## Evidence Authenticated `chat.send` → registered `read` on a synthetic PNG: main sent a nested image and failed; candidate sent a sibling image and completed with the scripted “Red square; blue circle.” Our run used a recording HTTP transport. The [contributor's real two-tool run](openclaw#149336 (comment)) confirms image interpretation and association. ## Compatibility Concrete route identities select the conversion. Opaque aliases keep their layout. The general schema permits nested images for some routes; this repair addresses the affected route’s observed rejection. No config or public interface changes. ## Consumers All clients use the existing Bedrock serializer. ## Invalidation Conversion is request-local. Stored transcript rows and original image bytes remain unchanged. ## Tests `node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-providers.config.ts extensions/amazon-bedrock`: 289 tests across 12 files passed on a fresh merge with main. Types, lint, formatting, file-size and assertion limits, and unused-export checks passed. Co-authored-by: Ayaan Zaidi <[email protected]>
* feat(meta): add Muse Spark 1.3 models (#136553) * feat(meta): add Muse Spark 1.3 models * docs(meta): cite Muse Spark 1.3 recommendation Co-authored-by: Tharun Tej Tammineni <[email protected]> --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 194b7f2) * feat(anthropic): support Fable 5.1 from shared model metadata (#135638) * feat(anthropic): support Fable 5.1 from shared model metadata * test(anthropic): keep alias coverage within the file limit * fix(media): decouple image limits from catalog augmentation (cherry picked from commit 0a9b08c) * feat(openai): support GPT Image 2.5 variants (#143068) * feat(openai): support GPT Image 2.5 variants * docs(openai): correct GPT Image 2.5 section link (cherry picked from commit f93881f) * feat(fal): support GPT Image 2.5 variants (#143069) * feat(fal): support GPT Image 2.5 variants * test(agents): restore Windows media fixture isolation (cherry picked from commit a57c799) * fix(bedrock): preserve images returned by tools (#149336) ## What Problem This Solves Tool-returned images make the next request fail with `ValidationException` on affected Bedrock routes. Fixes #149332. ## Why This Change Was Made The serializer generates image labels from each tool-call ID; input images need no labels. All consecutive tool results come first, followed by image groups in the same tool order. Request state has one writer. `stream.runtime.ts`: +28/−1 for this conversion. Growth accepted under the owner's standing acceptance (2026-09-15). ## User Impact Image-reading turns can finish without losing image bytes, tool associations, or error status. ## Evidence Authenticated `chat.send` → registered `read` on a synthetic PNG: main sent a nested image and failed; candidate sent a sibling image and completed with the scripted “Red square; blue circle.” Our run used a recording HTTP transport. The [contributor's real two-tool run](#149336 (comment)) confirms image interpretation and association. ## Compatibility Concrete route identities select the conversion. Opaque aliases keep their layout. The general schema permits nested images for some routes; this repair addresses the affected route’s observed rejection. No config or public interface changes. ## Consumers All clients use the existing Bedrock serializer. ## Invalidation Conversion is request-local. Stored transcript rows and original image bytes remain unchanged. ## Tests `node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-providers.config.ts extensions/amazon-bedrock`: 289 tests across 12 files passed on a fresh merge with main. Types, lint, formatting, file-size and assertion limits, and unused-export checks passed. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 115522a) * fix: preserve Ultra across model runtime boundaries (#135397) * fix: preserve Ultra across model runtime boundaries Keep native Codex Ultra as a runtime mode instead of clamping it against physical Responses effort tiers. Share the selected collaboration effort between turn fields and remove the redundant forwarding wrapper. Carry the active parent thinking level through existing spawn context so one-shot overrides reach native subagents without changing saved preferences. Keep explicit child overrides and configured child defaults authoritative. Scope Control UI thinking catalog fallback to the selected runtime, sharing one prepared entry for picker options and the inherited default. Document the native orchestration/budget boundary and active-turn inheritance. * refactor: simplify Ultra reasoning fixtures * fix: preserve active thinking across shared tool contexts * docs: clarify Off thinking for side questions (cherry picked from commit ee9e22b) * fix(anthropic): Fable 5.1 sessions lose reasoning after model switches and runtime events (#136782) * fix(anthropic): keep Fable 5.1 thinking valid across model switches and runtime context Claude Fable 5.1 binds each thinking block to the producing model and to the exact request prefix that preceded it. Three harness behaviors conflicted with that contract on Anthropic-family routes: - Moving a session onto Fable 5.1 (from Opus 5, Sonnet 5, Opus 4.8, Fable 5) dropped readable reasoning client-side; the replay contract now preserves it while leaving Fable 5.1 still drops. - The per-turn runtime-context carrier was injected transiently after the active user turn, stripped on the next request, relocated inside tool loops, and removed by the context-engine assembly. It is now persisted right after its user turn and replayed in place; inline inbound metadata stays in place too, and consecutive user turns are no longer merged at load for the Messages API because the merged form lost the second turn's timestamp stamp. - Direct API-key requests with adaptive thinking send the thinking-binding-controls beta with prefix_mismatch_behavior=drop_block, so a residual mismatch degrades to a server-side unbilled drop with a warning listing the dropped paths instead of a 400, a duplicate request, and a transcript-wide thinking wipe. OAuth, proxies, Bedrock, Vertex, and Foundry keep the existing strip-and-retry recovery. Live-verified against api.anthropic.com: nine-request Fable/Opus/Fable session with tool loops and carriers reports input_transformations: [] on every request with four retained thinking blocks; a /think change on the direct API yields a logged server-side drop and no retry. * fix(anthropic): limit the preserved-thinking replay target to Fable 5.1 Mythos 5.1 is not registered in the bundled catalog and has no cross-model replay proof, so unregistered Mythos targets keep the existing drop path. (cherry picked from commit 30837ae) * feat(openai): support GPT-6 Astra (#137550) * feat(openai): support GPT-6 Astra * fix(models): preserve declared pricing tiers during catalog refresh (cherry picked from commit eb72093) * fix(openai): require discovery before offering Astra for OAuth (#137561) (cherry picked from commit 8b1add5) * fix(diagnostics-prometheus): reject unauthorized metric scrapes (#140903) * fix(diagnostics-prometheus): require operator.read for metric scrapes The Prometheus scrape route registers under the trusted-operator runtime scope surface, so the Gateway authenticates the caller and applies its named-role scope ceiling before dispatch. The handler never consulted those scopes, so an authenticated identity whose role grants no operator scopes still received the full diagnostics document with 200, while the same caller was correctly refused on equivalent read operations. Check the runtime request scopes inside the handler and fail closed with 403 "missing scope: operator.read" unless the caller holds operator.read, operator.write, or operator.admin, mirroring the Gateway read implication set. The guard runs before rendering so HEAD probes cannot disclose the document size either. * test(diagnostics-prometheus): prove role-limited scrape denial (cherry picked from commit 0c9330b) * fix(discord): enforce sender media policy on guild asset uploads (#140334) The Discord emoji-upload, sticker-upload, and event-create branches dropped the sender-scoped media access options before dispatching the action, so the guild runtime loaded the requested host-local path with only a byte limit. A sender permitted to run those actions could therefore place bytes from a file outside their allowed media roots into an outbound Discord emoji, sticker, or event-cover request. Forward the resolved action options from all three branches, carry mediaAccess/mediaLocalRoots/mediaReadFile through the guild runtime, and load upload sources through buildOutboundMediaLoadOptions like every other outbound Discord media path. Adds regression coverage that a source outside the sender roots is rejected before any request is issued, with an in-roots control. (cherry picked from commit e5e7764) * fix(discord): preserve realtime speaker and playback ownership (#137433) * fix(discord): preserve realtime speaker and playback ownership Bind provider connections to one Discord principal so delayed transcripts and native consultations cannot inherit another speaker's authority. Keep the shared agent route and serialize response-owned audio on one room player, preserving continuations and recovery after playback gaps. Admit host-requested responses before dispatch and map Google Live turn completion to canonical terminal outcomes so queued speech can finish. Closes #137349 Related: #136982, #123243 Follow-up: #137417 * test(discord): preserve room capture across speaker recovery (cherry picked from commit 85d510c) * fix(doctor): preserve enabled skills during automatic updates (#138730) Use runtime-repair approval for optional skill disabling. Keep standalone explicit repair and required config migrations unchanged. (cherry picked from commit acc9a65) * fix: generated images disappear after failed tool calls (#131226) ## What Problem This Solves WebChat drops generated media when a later tool failure is the turn's only reply payload. ## Root cause The embedded-run terminal projection assigned successful tool media to the first non-reasoning payload. A later error warning could become that owner. Gateway error projection then discarded the attached media. ## Fix - Attach tool media only to a successful, non-reasoning reply. - Emit a separate media-only payload when the turn has no successful reply. - Preserve the newer host-owned and automatic-delivery media paths from current `main`. - Keep regression coverage at the payload owner and physical-delivery boundaries. - Remove the mocked browser test that manually inserted its expected result. ## Evidence - Baseline: current `main` at `8544aed05a5dbffb871483be781f71351203319e`. - Real path: branch-built Control UI → real Gateway → mock OpenAI Responses provider → successful image tool → later failing tool → terminal WebChat event. - Red: current `main` rendered zero generated images. - Green: `d2a10d40c633bfe796ad4ab19222aa831184a327` rendered one generated image. - Anti-cheat: the proof recorded `image-success` before `later-failure` and verified that Chromium loaded the exact Gateway-served asset from the branch build. ## Validation - Focused unit and integration tests: 19 passed across 2 Vitest shards. - Real Gateway and built Control UI proof: passed on current `main` and the candidate head with opposite image assertions. - Targeted format, Oxlint, conflict-marker, max-lines, assertion-safety, and diff checks passed. - Type checks run in continuous integration because repository policy forbids them on this host. Production change: `+3/-3`, net zero. Test change: `+23/-1`, net `+22`. Co-authored-by: A28Hui <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 88be1b8) * fix(matrix): refresh verification status before reporting device trust (#136226) * fix(matrix): refresh verification status before reporting device trust Refresh own-device keys after crypto preparation and before the authoritative trust read. Keep the missing-device preflight and use the Matrix SDK’s existing query contract. * test(slack): remove core-coupled threading duplicate --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit a812054) * chore(release): prepare extended-stable 2026.8.33 * fix(release): integrate model and Discord security backports * docs(release): clarify extended-stable workflow baseline * fix(release): complete stable-line backport integration * fix(ios): restore dependency resolution with WebRTC 152 (#134942) * fix(release): repair frozen validation inputs * fix(discord): stop error replies after voice consult cancellation (#135380) * fix(discord): stop error replies after voice consult cancellation Treat host-cancelled Discord realtime consults as terminal cancellation, preserve late-call dedupe, and wait for every native delivery before returning forced playback ownership. Timeouts and genuine errors retain their normal handling. Closes #135340. Related phone cancellation helper: #134924. * test(acp): run CLI lifecycle checks against prepared runtime * test(cli): cover selective runtime build admission * test(ci): account for ACP runtime preparation * fix(release): complete Discord cancellation backport * test(release): keep candidate fixtures current * test(update): isolate frozen release version --------- Co-authored-by: tharuntejmeta <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: dclosefuturex <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: Pavan Kumar Gondhi <[email protected]> Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: CGlashu <[email protected]> Co-authored-by: A28Hui <[email protected]>
…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]>
…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)
…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]>
…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]>
What Problem This Solves
Tool-returned images make the next request fail with
ValidationExceptionon affected Bedrock routes. Fixes #149332.Why This Change Was Made
The serializer generates image labels from each tool-call ID; input images need no labels. All consecutive tool results come first, followed by image groups in the same tool order. Request state has one writer.
stream.runtime.ts: +28/−1 for this conversion.Growth accepted under the owner's standing acceptance (2026-09-15).
User Impact
Image-reading turns can finish without losing image bytes, tool associations, or error status.
Evidence
Authenticated
chat.send→ registeredreadon a synthetic PNG: main sent a nested image and failed; candidate sent a sibling image and completed with the scripted “Red square; blue circle.” Our run used a recording HTTP transport.The contributor's real two-tool run confirms image interpretation and association.
Compatibility
Concrete route identities select the conversion. Opaque aliases keep their layout. The general schema permits nested images for some routes; this repair addresses the affected route’s observed rejection. No config or public interface changes.
Consumers
All clients use the existing Bedrock serializer.
Invalidation
Conversion is request-local. Stored transcript rows and original image bytes remain unchanged.
Tests
node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-providers.config.ts extensions/amazon-bedrock: 289 tests across 12 files passed on a fresh merge with main. Types, lint, formatting, file-size and assertion limits, and unused-export checks passed.