Skip to content

fix(converters): preserve user image attachments across adjacent message merging - #286

Open
AhmedAttia3 wants to merge 1 commit into
jwadow:mainfrom
AhmedAttia3:fix/tool-result-image-merge
Open

AhmedAttia3 wants to merge 1 commit into
jwadow:mainfrom
AhmedAttia3:fix/tool-result-image-merge

Conversation

@AhmedAttia3

Copy link
Copy Markdown

Problem

During tool continuation flows, a tool result message is often followed immediately by a user message containing image attachments (image_url data URLs). In converters_core.py::merge_adjacent_messages, adjacent user messages were merged by combining text and tool_results, but images lists on subsequent user messages were omitted, dropping multi-modal images from the generated Kiro payload.

Fix

Merge user images lists in order in merge_adjacent_messages without list-alias mutation (last.images = list(last.images) + list(msg.images)), preserving tool calls, tool results, and image counts across merged adjacent user messages.

Tests & Verification

  • Focused converter tests: 409 passed across core, OpenAI, and Anthropic test suites (test_converters_core.py, test_converters_openai.py, test_converters_anthropic.py).
  • Edge cases covered:
    • Direct image input and multi-image attachments (PNG, JPEG).
    • Preserved image ordering across message concatenation.
    • Tool continuation flows with subsequent image attachments.
    • Non-mutation of caller input lists (list(last.images) + list(msg.images)).
    • OpenAI and Anthropic converter transformations and payload preservation.
  • Full unit baseline note: Upstream base has an existing test_config reload fixture isolation limitation causing 79 errors in unmodified unit suites; with this fix, all 1606 valid tests pass with the identical 79 baseline error node set preserved.
  • Manual live acceptance: Tested both direct image input and tool-result view_image flows against live Kiro backend; image descriptions succeeded and verified.

…age merging

When adjacent user messages are merged (e.g. tool result followed by user message with images), merge_adjacent_messages combined text and tool results but discarded detached user images lists.

Merges images lists in order without mutating caller input lists, preserving tool results and image counts.

Added unit test coverage for core, OpenAI, and Anthropic converters; updated English and Russian ARCHITECTURE.md.
@cla-bot

cla-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

Thanks for the PR! 🎉

Before merge, we need a one-time CLA confirmation.
It confirms that you have the right to contribute this code and allow the project to use it.

Full CLA text:
https://github.com/jwadow/kiro-gateway/blob/main/CLA.md

Please reply once with:

I have read the CLA and I accept its terms

You need to write once, all further messages from me can be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant