Skip to content

fix(chat): accept Pi and Anthropic-shaped image parts on the chat wire - #4497

Merged
lidge-jun merged 1 commit into
devfrom
codex/260913-chat-tool-image-parts
Sep 13, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/260913-chat-tool-image-parts

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

  • Aside (Pi agent core, openai-completions API) returns read_file screenshots as tool-result parts shaped {type:"image", data, mimeType}. The chat inbound translator (src/chat/inbound.ts) only recognized image_url parts and silently dropped these, so vision models answered that the image data never arrived.
  • Live-reproduced against the running proxy (2.53.0 dev dogfood): claude-opus-5 with a Pi-style tool image reports the image missing; the identical request in image_url form is described correctly. Anthropic-messages, chat user-message, and Responses inbound image paths were probed and are unaffected.
  • Fix: normalize Pi/MCP-style {type:"image", data, mimeType} and Anthropic source-object ({type:"base64", media_type, data} / {type:"url", url}) parts to the data-URI form the Responses pipeline already handles. This restores screenshot reading for every Pi-adapter client, any model.
  • Regression tests added to the chatCompletionsToResponsesBody image-parts table (5 new cases: Pi base64+mimeType, mediaType alias, pre-formed data URI, Anthropic base64 source, Anthropic URL source).

Verification

  • Local suite/build/typecheck: NOT RUN (maintainer rule for this task; hosted exact-head CI is the gate).
  • Live probes against the running proxy (user's own instance, tiny 200px screenshot): bug reproduced pre-fix (model: "the image data didn't come through"); standard shapes confirmed working pre-existing.
  • Translator-level regression cases added under tests/responses/chat-completions-endpoint.test.ts.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Aside (Pi agent core, openai-completions) returns read_file screenshots as
tool-result parts of shape {type:"image", data, mimeType}. The chat
inbound translator only recognized image_url parts and silently dropped
these, so vision models answered that the image data never arrived
(live-reproduced against the running proxy: claude-opus-5 with a Pi-style
tool image reports the image missing, while the same request in image_url
form is described correctly). Claude-shaped clients sending Anthropic
source-object image parts over the same endpoint were dropped the same way.
Normalize both shapes to the data-URI form the Responses pipeline already
handles.

Local suite NOT RUN per maintainer rule; hosted exact-head CI is the gate.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 13, 2026 09:54
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-13T09:58:21.865553Z 9b9675b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the bug Something isn't working label Sep 13, 2026
@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 72a243af-c324-44d2-9f51-fece534af141

📥 Commits

Reviewing files that changed from the base of the PR and between 981b53e and 9b9675b.

📒 Files selected for processing (2)
  • src/chat/inbound.ts
  • tests/responses/chat-completions-endpoint.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The image-part normalizer now supports OpenAI, native data, and Anthropic-style image formats. Tests cover five additional image conversion cases.

Changes

Image input handling

Layer / File(s) Summary
Normalize and test image parts
src/chat/inbound.ts, tests/responses/chat-completions-endpoint.test.ts
imageUrlFromPart now handles image_url, native image data with mimeType or mediaType, prefixed data URLs, and Anthropic-style base64 or URL sources. Five parametrized tests verify conversion to Responses input_image values.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9b967

The added image formats preserve their MIME metadata and targeted tests cover the supported conversions. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: chat now accepts Pi- and Anthropic-shaped image parts. It is concise, specific, and consistent with the updated image-part translation and regression tests…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/260913-chat-tool-image-parts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Copy link
Copy Markdown

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: 9b9675b202

ℹ️ 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".

Comment thread src/chat/inbound.ts
// (Aside read_file tool results), Anthropic-shaped clients carry a source
// object. Dropping either silently blinds a vision model, so normalize both
// to the URL/data-URI form the Responses pipeline already understands.
if (part.type === "image") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize non-OpenAI images before native Chat dispatch

When /v1/chat/completions selects an eligible openai-chat provider, handleChatCompletions dispatches the untouched body through handleNativeChatCompletions before calling this translator, so this new branch never runs and the upstream receives the unsupported {type:"image", ...} object. Moreover, chatBodyCarriesImage recognizes only image_url, meaning these parts also fail to divert explicitly text-only models through the Responses vision path. Pi and Anthropic-shaped screenshots therefore remain rejected or ignored on ordinary OpenAI-compatible targets; normalize the native body or make native eligibility recognize these shapes and cover the real handler path with a regression test.

AGENTS.md reference: AGENTS.md:L376-L379

Useful? React with 👍 / 👎.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration record (MAINTAINERS.md dev exception): integrating as repository owner without a second maintainer approval. No outstanding maintainer change requests. Exact-head verification: all required checks green on head 9b9675b (ci aggregator, gates, hygiene, enforce-target, docker smoke, api usage, CodeRabbit completed; windows/macos-control skipped by changes-gate design). Local suite NOT RUN per task rule; hosted exact-head CI is the gate. User-reported blocker (Aside/Pi screenshots blind on every model) — root cause live-reproduced pre-fix; fix verified at translator level by the added regression cases; end-to-end re-verification against the live proxy follows the merge.

@lidge-jun
lidge-jun merged commit eb81eaa into dev Sep 13, 2026
27 checks passed
@lidge-jun
lidge-jun deleted the codex/260913-chat-tool-image-parts branch September 13, 2026 10:05
luvs01 pushed a commit to luvs01/opencodex that referenced this pull request Sep 13, 2026
Product tree is dev at eb81eaa, byte-identical (dev already carries the
2.53.0 version line).

This promotion follows a 364-commit regression audit (origin/main..981b53e)
by 15 parallel subagent lanes plus two audit-spawned fixes reviewed and merged
to dev: lidge-jun#4496 (live sideband connect watchdog) and lidge-jun#4497 (chat image part
shapes). Zero unresolved P0/P1 at promotion time. Exact-head hosted CI green
on eb81eaa (run 34750934849). Local suite NOT RUN per task rule; hosted
exact-head CI is the gate.
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…ol-image-parts

fix(chat): accept Pi and Anthropic-shaped image parts on the chat wire
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant