Skip to content

[codex] preserve image detail in responses#32

Merged
0x4007 merged 1 commit into
developmentfrom
codex/preserve-image-detail
May 15, 2026
Merged

[codex] preserve image detail in responses#32
0x4007 merged 1 commit into
developmentfrom
codex/preserve-image-detail

Conversation

@0x4007

@0x4007 0x4007 commented May 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Preserve detail on normalized input_image content before forwarding /v1/responses requests to Codex.
  • Preserve nested chat-style image_url.detail as well as top-level Responses input_image.detail.
  • Add a regression test proving the upstream Codex request still contains detail: "high".

Root Cause

The gateway accepted OpenAI-compatible image input shapes, but normalization rebuilt image content as { type: "input_image", image_url } and dropped detail. Runtime callers could send detail: "high", but Codex never received it. Dense menu-photo OCR through gpt-5.5 then behaved like an omitted-detail request and returned upstream 502s for real menu photos.

Impact

Clients using ai.ubq.fi/v1/responses can now explicitly control image detail for vision/OCR requests. This is needed by restaurant-food-picker before relying on GPT-5.5 for menu-image extraction.

Validation

  • deno fmt --check src/openai.ts src/types.ts tests/openai-compat.test.ts
  • deno task lint
  • deno task build
  • deno test --allow-env --allow-net tests/openai-compat.test.ts
  • deno test --env --allow-env (118 passed)
  • Local patched provider smoke test against the GPS restaurant menu fixture returned 200 and extracted visible menu items.

Note

deno task test currently fails because the task runs deno test --env without env permission while tests/embeddings.test.ts reads VOYAGEAI_API_KEY at module load. Rerunning with explicit --allow-env passes.

@github-actions

Copy link
Copy Markdown

@0x4007 0x4007 marked this pull request as ready for review May 15, 2026 06:40
@0x4007

0x4007 commented May 15, 2026

Copy link
Copy Markdown
Member Author

@codex review
@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

@0x4007 Sure, kicking off a full review now!

✅ Actions performed

Full review triggered.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

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

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Rate limit exceeded

@0x4007 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 57 minutes and 58 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e47afd96-dfa2-4e77-95cb-b3b6c8dc8efa

📥 Commits

Reviewing files that changed from the base of the PR and between fa3cb41 and 9993bfe.

📒 Files selected for processing (3)
  • src/openai.ts
  • src/types.ts
  • tests/openai-compat.test.ts
📝 Walkthrough

Walkthrough

This PR adds support for an optional detail field on image inputs within message content. The type definition for MessageContentItem now includes detail?: string on the input_image variant. A small normalization helper trims and validates the detail value, and both the message content extraction and response input normalization code paths now extract and preserve this field when present. A new test verifies that detail values pass through the normalization and are included in forwarded upstream requests.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving image detail in Codex responses.
Description check ✅ Passed The description provides comprehensive context about the change, root cause, impact, and validation performed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/preserve-image-detail

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
tests/openai-compat.test.ts (1)

800-844: ⚡ Quick win

Add one more case to cover the second normalization branch.

Line 800 validates message-content input_image.detail, but not top-level content-item normalization (normalizeResponseContentItem) or nested image_url.detail. Adding those keeps this regression fully locked down.

Suggested test shape
-Deno.test("openai: responses preserve image detail on normalized input images", async () => {
+Deno.test("openai: responses preserve image detail on normalized input images", async (t) => {
   // existing case...
+
+  await t.step("preserves detail on top-level input_image items", async () => {
+    // input: [{ type: "input_image", image_url: "...", detail: "high" }]
+    // assert forwarded input_image keeps detail
+  });
+
+  await t.step("preserves nested image_url.detail", async () => {
+    // input: [{ role: "user", content: [{ type: "image_url", image_url: { url: "...", detail: "high" } }] }]
+    // assert forwarded input_image keeps detail
+  });
 });

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a2511a9-dcf1-4226-964b-cab109eb910c

📥 Commits

Reviewing files that changed from the base of the PR and between fa3cb41 and 9993bfe.

📒 Files selected for processing (3)
  • src/openai.ts
  • src/types.ts
  • tests/openai-compat.test.ts

@0x4007 0x4007 merged commit b6e8122 into development May 15, 2026
2 checks passed
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