GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(images): Codex P2 follow-ups for image bridge (#424) by Wibias · Pull Request #528 · lidge-jun/opencodex

Conversation

@Wibias

@Wibias Wibias commented Jul 27, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

  • Follow-up to feat(images): add Grok image bridge for non-OpenAI models #424 addressing the Codex P2 notes left as non-blockers on the R2 approval.
  • Depends on feat(images): add Grok image bridge for non-OpenAI models #424 — branched from tip 6d6b252. Prefer merging feat(images): add Grok image bridge for non-OpenAI models #424 first, then this; until then, review the tip commit (full compare vs dev also includes feat(images): add Grok image bridge for non-OpenAI models #424).

Changes

  • Clamp images.maxRounds to [0, 10] (clampImageMaxRounds) so hand-edited 10000 / fractional values cannot unbound paid xAI calls
  • Honor images.timeoutMs in callXaiImages (via plan → fulfill)
  • Forced-final alias filter — strip every name in plan.toolNames, not only imageGeneration:true
  • SSE headers before queue.collect() on Cursor/runTurn (skip eager drain; heartbeat while collecting)
  • Preserve _cursorConversationId across image-loop iterations
  • Wire onUsage / logCtx for image-bridge completions (parity with web-search)
  • 429 key rotation via rotateProviderTransportOn429 inside the image loop
  • Parallel image calls share one assistant turn with thinking attached once (Anthropic extended-thinking safety)

Test plan

  • bun test --isolate tests/images/ (94 pass)
  • bun run typecheck
  • Cross-platform CI green after feat(images): add Grok image bridge for non-OpenAI models #424 lands / FTC approval

Summary by CodeRabbit

  • New Features
    • Added an opt-in Image Bridge to route hosted image-generation requests through xAI Grok Imagine for non-OpenAI providers, with streamed tool-call interception and multi-round controls (maxRounds, timeoutMs).
    • Generated images are now materialized as local on-disk artifacts and the model receives local file paths.
  • Security
    • Strengthened URL/IP destination safety with fail-closed DNS checks and improved SSRF protections; tightened inline/download payload validation and byte limits.
  • Documentation
    • Added an “Image Bridge” guide and clarified how it differs from Codex’s built-in image_gen.
  • Tests
    • Added end-to-end and unit tests covering bridge priority/activation, loop behavior (including cursor/runTurn), and download/SSRF enforcement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
Wibias requested review from Ingwannu and lidge-jun as code owners July 27, 2026 02:07
@github-actions github-actions Bot added the bug Something isn't working label Jul 27, 2026
@Wibias Wibias mentioned this pull request Jul 27, 2026
feat(images): add Grok image bridge for non-OpenAI models #424
Closed
3 tasks done
@coderabbitai

This comment was marked as outdated.

Sign in to view
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Ingwannu
Ingwannu requested changes Jul 27, 2026
View reviewed changes

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I reviewed the current head (553e9afc), not the earlier automated-review snapshots. The auth-mode selection, hidden-iteration usage aggregation, runTurn dispatch/stall handling, tool-choice mapping, duplicate-tool replacement, paid-call cap, hosted size/quality defaults, configured deadlines, and provider fetch transport findings are addressed in this head. The focused image tests and typecheck pass when the mock-heavy files are run in their intended isolated processes.

One merge blocker remains: downloadImageToArtifact() resolves the provider-returned hostname in assertUrlResolvesPublic(), then calls global fetch(url), which performs a second independent DNS resolution. A rebinding host can pass the first public-address check and resolve to loopback/private/metadata space for the actual connection. The code comment currently records this as a residual, but this PR introduces the remote-download surface; it cannot rely on a check that is detached from the connected peer.

Please either pin the validated address for the actual HTTPS connection while retaining the original hostname/SNI, validate the connected peer, or constrain downloads to a defensible trusted-host contract. Add a regression where the validation lookup is public and the connection lookup changes to a blocked address. After that and resolution of the stale review threads, I can re-review. This is a valuable feature, but it is not ready to merge into dev with that boundary open.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lidge-jun added a commit that referenced this pull request Jul 27, 2026
@lidge-jun
docs(devlog): correct the decision ledger against an independent audit
01aa08f
Two read-only audit lenses returned 30 contradictions; the verified ones are
applied here and recorded in 006_corrections.md.

Factual corrections:
- claude-code#1124 closed 2025-05-16, not 2025-08-10
- 13 open enhancement issues, not 11
- #529 is merged, so issue #42 phase 2 is done
- #418 has no PR behind it; it was miscounted as in-flight
- #528 does not contain #424's current head, so it needs a rebase
- #527's retarget is manual and independent of #526

Framing corrections:
- stale-needs-info.yml is absent from the default branch, so bundle C had no
  real deadline
- the debug switch #543's reporter asked for already exists
- whether #545 is our defect is answerable from code, not owner judgment
- #491 is an OAuth credential change, so it is a security boundary rather
  than a warm-up; #533 and #447 keep their security classification too

Structure: bundle G added for roadmap honesty, bundle F rescoped to the
security boundary, #498 split out of bundle B, cycle order rebuilt, and the
loop archetype corrected to decision-elicitation.
Ingwannu
Ingwannu requested changes Jul 27, 2026
View reviewed changes

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Re-reviewed current head 21c65c97. The DNS-rebinding blocker from my prior review is addressed correctly in principle: the code resolves once, keeps the original hostname for Host/SNI, and pins the validated address through a custom lookup. The focused artifact suite passes 28/28, typecheck passes, and the previous DNS thread is now outdated.

A new blocking regression is introduced by the pinned transport, though: pinnedHttpsGet() collects every data chunk into chunks and calls Buffer.concat(chunks) before it returns a Response. downloadImageToArtifact() applies MAX_DOWNLOAD_BYTES only while reading that already-buffered Response afterward. Therefore an untrusted image URL can make the process allocate an unbounded response body before the intended 50 MiB cap runs, defeating the memory-exhaustion protection this path previously had.

Please stream the IncomingMessage through to the existing bounded reader, or enforce the same hard cap inside pinnedHttpsGet() and destroy the request immediately when exceeded. Add a regression against the default pinned transport that exceeds the cap and proves it aborts before full buffering; the current injected pinnedDownload tests do not exercise this allocation path.

Process gates also remain: this head currently conflicts with current dev (CONFLICTING / DIRTY) and the new tip has not completed cross-platform CI. After the bounded transport fix, rebase/resolve against current dev, run CI on the mergeable SHA, and ping for re-review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
coderabbitai[bot]

This comment was marked as outdated.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
Wibias marked this pull request as draft July 27, 2026 15:17
@Wibias
Wibias requested a review from Ingwannu July 27, 2026 15:25
@Wibias
Wibias marked this pull request as ready for review July 27, 2026 15:25
coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lidge-jun lidge-jun mentioned this pull request Jul 27, 2026
fix(ci): let the PR labeler actually write labels #566
Merged
Your Name and others added 12 commits July 27, 2026 21:00
Your Name @Wibias
feat(images): add Grok image bridge for non-OpenAI models
7393805
When a non-OpenAI model receives an image_generation hosted tool from Codex,
OpenAI's server-side execution is unavailable. This intercepts the tool call,
routes it to xAI Grok Imagine, materializes the image to ~/.opencodex/artifacts/,
and feeds the result back to the model — all inside a streaming SSE loop.

Architecture mirrors the proven web-search sidecar pattern:
- parser.ts: extract hosted image_generation tool, stash into parsed._imageGeneration
- plan.ts: decide whether to activate (xAI provider + token available, non-OpenAI route)
- loop.ts: agentic loop (max 3 rounds) — intercept image tool calls, fulfill via xAI,
  inject results, re-call model, bridge to SSE
- synthetic-tool.ts: buildImageTool() injection + isImageGenName() detection
- xai-client.ts: xAI /images/generations and /images/edits API client
- fulfill.ts: execute single image call, materialize to disk (never throws)
- artifacts.ts: extended with downloadImageToArtifact() + magic byte format detection

New files:
  src/images/{types,xai-client,synthetic-tool,fulfill,plan,loop,index}.ts
  tests/images/{xai-client,plan,fulfill,synthetic-tool,loop}.test.ts
  docs-site/src/content/docs/guides/image-bridge.md

Modified files:
  src/types.ts: +_imageGeneration stash, +OcxTool.imageGeneration flag, +OcxImagesConfig fields
  src/responses/parser.ts: extractHostedImageGeneration extraction
  src/server/responses/core.ts: image bridge trigger point
  src/images/artifacts.ts: +downloadImageToArtifact, +guessExtFromMagic, shared helpers
Your Name @Wibias
fix(images): address Wibias review blockers for #424
6428f5d
- Enforce HTTPS-only scheme in downloadImageToArtifact (reject ftp/http/gopher)
- Fix dispatch order: image bridge defers to web-search when both eligible
- Narrow buildImageTool description to generation-only (no 'edit' promise)
- Remove URL-interpolating error from fulfill.ts console.warn
- Add downloadImageToArtifact SSRF tests (http/ftp reject, https succeeds)
- Add handler-activation regression tests (stream/400/dual-tool defer)
Your Name @Wibias
fix(images): address Wibias R2 review blockers for #424
58d0672
- Move web-search dispatch before runTurn so dual-tool turns reach
  web-search even on Cursor/runTurn adapters
- Guard image bridge with !routedCompaction to prevent hijacking
  compaction requests
- Fix IPv4-mapped IPv6 hex SSRF bypass in destination-policy
  (::ffff:7f00:1 now decoded and classified as loopback)
- Add SSRF tests: private IP, gopher, IPv6 mapped (dotted+hex),
  redirect:error fail-closed
- Add regression: runTurn dual-tool → web-search wins
- Add regression: compaction request → image bridge skipped
@Wibias
fix(images): address Codex P2 follow-ups for image bridge
b96bfa9
Clamp maxRounds, honor images.timeoutMs, strip all image tool aliases on forced-final, return SSE headers before runTurn collect, preserve Cursor conversation ids across loop iterations, wire onUsage/logCtx and 429 key rotation, and keep parallel image calls in one assistant turn.
@Wibias
fix(images): address Codex and CodeRabbit feedback on #528
dd5c49b
Keep runTurn adapters out of the unsupported web-search loop, honor xAI authMode, cap paid image calls, and close the remaining review gaps around usage, transport, tool-choice, and tests.
@Wibias
fix(images): abort stalled runTurn and merge incomplete usage
83987e8
Cancel the in-flight runTurn when the image-bridge collect deadline fires, fire onAttemptSend at dispatch time, and fold accumulated usage into incomplete terminals as well as done.
@Wibias
fix(images): pin validated DNS for artifact downloads against rebinding
8755671
Resolve once via resolvePublicAddresses, then connect with a custom https lookup that keeps SNI/Host on the original hostname so a later private answer cannot retarget the peer.
@Wibias
fix(images): stream pinned downloads with byte cap and idle timeout
4b772ca
Address Ingwannu and CodeRabbit feedback on #528: pinnedHttpsGet returns a streaming body, enforces MAX_DOWNLOAD_BYTES mid-stream, honors lookup all:true, and times out idle peers. Drop unreachable localhost check after assessDestination. Add transport regressions.
@Wibias
fix(images): destroy pinned HTTPS response on non-2xx status
d4478ec
Reject failed downloads before attaching a streaming body so unread 4xx/5xx payloads cannot keep the socket alive, and cancel custom-seam bodies on !ok.
@Wibias
fix(docs): point image-bridge Providers link at guides/providers
ad5d04c
CodeRabbit: /reference/providers/ is not a registered Starlight page.
@Wibias
fix(images): address Codex review on #528
de19c7e
Reject non-global IPv6 peers, stop double-counting hidden usage, reset runTurn idle stalls on progress, reject empty/non-image downloads, backfill Cursor conversation ids from the image loop, and clarify Responses vs /images/generations activation in docs.
@Wibias
fix(images): unblock runTurn idle timeout without waiting on the adapter
0a4c781
On idle expiry abort the runTurn signal and close the event queue so the consumer finishes even when runTurn ignores cancellation and never settles. Add a never-settling regression.
Wibias added 3 commits July 27, 2026 21:01
@Wibias
fix(test): raise Windows CI timeout for injected cleanup rollback cases
34c6d85
Rebase onto dev and extend the storage cleanup harness timeout for injected satellite rollback tests that measure 6–13s on Windows runners.
@Wibias
fix(tests): stabilize blocked policy worker test on Windows CI
11b740f
Wait for worker spawn and holdAfterLoadMs before concurrent PUT so slow Windows CI worker startup does not load a disabled policy snapshot.
@Wibias
Merge upstream/dev into fix/image-bridge-p2
8e220b0
Resolve api-storage-policy.test.ts conflict: keep Windows CI worker spawn timing (blockMs 1500, sawRunning gate, 800ms hold margin).
coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
fix(images): address CodeRabbit review on image bridge P2
2db8b57
@Wibias Wibias mentioned this pull request Jul 27, 2026
feat(images): Grok image bridge (maintainer takeover of #424) #577
Merged
2 of 5 tasks
@Wibias

Wibias commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by maintainer takeover #577, which folds this P2 branch into the #424 landing vehicle on latest dev. Closing once #577 merges.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Wibias added a commit that referenced this pull request Jul 27, 2026
@Wibias
feat(images): Grok image bridge (maintainer takeover of #424) (#577)
de35caa
Credit: @tizerluo for the original feature on #424.
Folds stacked #528 hardening and maintainer review/security follow-ups.
Reconciled with #355 artifact helpers on latest dev.

Closes #424
Closes #528
@Wibias

Wibias commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Superseded and landed as part of maintainer takeover #577 (merged to dev). Closing as completed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias Wibias closed this Jul 27, 2026
@Wibias
Wibias deleted the fix/image-bridge-p2 branch July 28, 2026 00:16
This was referenced Jul 28, 2026
feat(videos): add Grok video bridge for non-OpenAI models #582
Merged
fix(openai-responses): round-trip image-gen namespace #588
Merged
feat: route GPT-5.6 Pro through standard ChatGPT #757
Closed
feat(proxy): opt-in same-target 429 wait-and-retry before key failover (#487) #865
Merged
fix(responses): keep DeepSeek reasoning_content on tool-call continuations (#950) #971
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 30, 2026
feat(images): relay Codex image_gen to xAI Imagine with Grok OAuth (carry of #2083) #2986
Merged
3 tasks done
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
feat(images): Grok image bridge (maintainer takeover of lidge-jun#424) (
a4fdb40
lidge-jun#577)

Credit: @tizerluo for the original feature on lidge-jun#424.
Folds stacked lidge-jun#528 hardening and maintainer review/security follow-ups.
Reconciled with lidge-jun#355 artifact helpers on latest dev.

Closes lidge-jun#424
Closes lidge-jun#528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@lidge-jun lidge-jun Awaiting requested review from lidge-jun lidge-jun is a code owner
@Ingwannu Ingwannu Awaiting requested review from Ingwannu Ingwannu is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Wibias @Ingwannu
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.