Skip to content

Fix user message text silently dropped when message contains both text and image#8071

Merged
DOsinga merged 3 commits intoblock:mainfrom
vincenzopalazzo:claude/elated-keller
Mar 24, 2026
Merged

Fix user message text silently dropped when message contains both text and image#8071
DOsinga merged 3 commits intoblock:mainfrom
vincenzopalazzo:claude/elated-keller

Conversation

@vincenzopalazzo
Copy link
Copy Markdown
Contributor

Summary

  • When a user message contained both MessageContent::Text and MessageContent::Image blocks, the text was silently dropped in the OpenAI format conversion
  • Root cause: text_array and content_array were populated independently, but the final assembly used an if-else that only picked one — when content_array was non-empty (image present), text_array was ignored
  • Fix: merge text_array entries into content_array as {"type": "text", "text": "..."} objects before serialization
  • Added test_format_messages_with_text_and_image covering the mixed text+image case

Closes #8067

Test plan

  • New unit test test_format_messages_with_text_and_image passes
  • All 23 existing openai format tests pass
  • cargo clippy clean

🤖 Generated with Claude Code

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c484ffc27d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jh-block jh-block self-assigned this Mar 23, 2026
When a user message contained both `MessageContent::Text` and
`MessageContent::Image` blocks, the text was silently dropped because
text and image content were collected into separate arrays, and the
final assembly only used one of them.

Fix: push all content blocks into a single array in their original
order, preserving the interleaving the caller specified. When only
text is present, collapse back to the simple string format for
backward compatibility.

Closes block#8067

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Vincenzo Palazzo <[email protected]>
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct — user message text was silently dropped when a message contained both text and image content. The unified content_array with has_non_text_content flag properly preserves ordering. Removed two restatement comments per project style guidelines; everything else looks good.

@DOsinga DOsinga enabled auto-merge March 24, 2026 23:21
@DOsinga DOsinga added this pull request to the merge queue Mar 24, 2026
Merged via the queue into block:main with commit 9849671 Mar 24, 2026
21 checks passed
lifeizhou-ap added a commit that referenced this pull request Mar 25, 2026
* main:
  Fix user message text silently dropped when message contains both text and image (#8071)
  fix: use pnpm when publishing (#8092)
  Alexhancock/publish npm file format fix (#8091)
  fix: iteration on the publish-npm workflow (#8087)
  chore: ignore unmaintained warning for proc-macro-error (#8084)
  chore: clean up stray recipe.yaml (#8086)
  chore(release): bump version to 1.29.0 (minor) (#8088)
  Update lockfile references (#8085)
  Fix version bump (#8083)
  Add a code review step which uses a short-lived provider token (#7932)
michaelneale added a commit that referenced this pull request Mar 25, 2026
* origin/main:
  Fix user message text silently dropped when message contains both text and image (#8071)
  fix: use pnpm when publishing (#8092)
  Alexhancock/publish npm file format fix (#8091)
  fix: iteration on the publish-npm workflow (#8087)
  chore: ignore unmaintained warning for proc-macro-error (#8084)
  chore: clean up stray recipe.yaml (#8086)
  chore(release): bump version to 1.29.0 (minor) (#8088)
  Update lockfile references (#8085)
  Fix version bump (#8083)
  Add a code review step which uses a short-lived provider token (#7932)
@vincenzopalazzo vincenzopalazzo deleted the claude/elated-keller branch March 25, 2026 09:44
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.

[BUG]: User message text is silently dropped when message contains both text and image in OpenAI format

3 participants