mirror of
https://github.com/jwadow/kiro-gateway.git
synced 2026-04-25 01:15:57 +03:00
[GH-ISSUE #70] BUG: 422 validation error when tool_result contains image content blocks (browser screenshots) #46
Labels
No labels
bug
bug
enhancement
enhancement
fixed
fixed
invalid
needs-info
needs-testing
pull-request
question
upstream
wontfix
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/kiro-gateway-jwadow#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bhaskoro-muthohar on GitHub (Feb 7, 2026).
Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/70
Kiro Gateway Version
v2.2 (latest, commit
9c7933c)What happened?
When using the Anthropic Messages API route (
/v1/messages) with a client that sends tool results containing image content blocks (e.g., browser screenshots from computer use / OpenClaw browser channel), the gateway returns a 422 Pydantic validation error:Per the Anthropic API spec,
tool_resultcontent can include both text and image blocks. This is common when tools return screenshots (e.g., computer use, browser automation).Root cause (two issues):
1.
models_anthropic.py- Pydantic model rejects image blocksToolResultContentBlock.contentis typed asOptional[Union[str, List[TextContentBlock]]], which rejects image content blocks at validation time.2.
converters_anthropic.py- Images inside tool_results are silently droppedconvert_anthropic_messages()callsextract_images_from_content()only on top-level message content blocks. It never looks insidetool_result.content, so images embedded in tool results (like browser screenshots) are silently dropped and never sent to Kiro.Debug Logs
Request body (truncated) showing the failing message structure:
Pydantic rejects this at validation time because
List[TextContentBlock]doesn't match a list containing anImageContentBlock.Related to #50 (similar area of code, but that was about Pydantic text extraction, not images in tool results).