Skip to content

fix(codex): avoid vision image tool loops#69551

Merged
steipete merged 4 commits into
mainfrom
land/65061-codex-vision-image-tool
Apr 21, 2026
Merged

fix(codex): avoid vision image tool loops#69551
steipete merged 4 commits into
mainfrom
land/65061-codex-vision-image-tool

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Replacement for #65061 because the contributor fork cannot be updated by maintainers and the original branch conflicts with current main.

Keeps @zhulijin1991's two fixes, rebased on current main, with the run-attempt test hook conflict resolved and extra regression coverage added:

  • Codex app-server drops the dynamic image tool only when the model already supports vision and the turn has inbound images.
  • Image fallback bare override ids inherit the configured image-model provider, while fully-qualified overrides keep their own provider.

Validation run locally:

  • pnpm test extensions/codex/src/app-server/run-attempt.vision-tools.test.ts src/agents/model-fallback.image-provider.test.ts src/agents/model-fallback.test.ts
  • pnpm check:changed
  • Direct OpenAI live smoke using .profile OPENAI_API_KEY: gpt-5.4-nano Responses API returned OK.

Thanks @zhulijin1991 for the original fix in #65061.

@cursor

cursor Bot commented Apr 21, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches Codex tool-exposure logic and image-model fallback provider resolution, which can affect runtime tool availability and which model/provider is invoked during image generation. Scope is contained and covered by new regression tests, but misbehavior could break vision turns or route requests to the wrong provider.

Overview
Prevents Codex vision turns from re-exposing the image tool when the selected model already has vision and the turn includes inbound images, avoiding loops where the model keeps calling image generation instead of using provided inputs.

Adjusts runWithImageModelFallback so a bare image-model override (e.g. gpt-5.4-mini) inherits the provider from the configured agents.defaults.imageModel.primary, while fully-qualified overrides keep their explicit provider. Adds targeted unit tests for both behaviors and bumps the install-sh smoke runner command timeout expectation from 300s to 900s.

Reviewed by Cursor Bugbot for commit ffb218a. Bugbot is set up for automated code reviews on this repo. Configure here.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: codex size: S maintainer Maintainer-authored PR labels Apr 21, 2026
@greptile-apps

greptile-apps Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR ports two targeted bug fixes from #65061 (rebased on current main): it prevents a vision-tool loop in the Codex app-server by dropping the dynamic image tool only when the active model supports vision and the turn carries inbound images; and it fixes bare image-model override IDs inheriting the provider from the configured imageModel.primary rather than defaulting to DEFAULT_PROVIDER. Both changes are covered by new unit tests.

Confidence Score: 5/5

Safe to merge — both fixes are small, well-scoped, and backed by new passing tests with no blocking issues found.

All findings are P2 or lower. The vision-tool filter logic is correct (drop image tool only when both modelHasVision AND hasInboundImages), and the image-model provider inheritance correctly derives from the configured primary model. Tests cover both the positive and negative cases for each fix.

No files require special attention.

Reviews (1): Last reviewed commit: "test: expand codex image fallback covera..." | Re-trigger Greptile

@steipete
steipete force-pushed the land/65061-codex-vision-image-tool branch from 48132da to a41b84e Compare April 21, 2026 03:00
@steipete
steipete merged commit 201bf85 into main Apr 21, 2026
95 checks passed
@steipete
steipete deleted the land/65061-codex-vision-image-tool branch April 21, 2026 03:20
@steipete

Copy link
Copy Markdown
Contributor Author

Landed on main.

Source head: ffb218adbcb24e81f852c74cc84f1249d9683f3f
Main commit: 201bf85ce965720a011167e4287ab8e168dc04b4

Validation:

  • pnpm test extensions/codex/src/app-server/run-attempt.vision-tools.test.ts src/agents/model-fallback.image-provider.test.ts src/agents/model-fallback.test.ts
  • pnpm test test/scripts/test-install-sh-docker.test.ts
  • pnpm check:changed
  • Direct OpenAI Responses API smoke using OPENAI_API_KEY from ~/.profile with gpt-5.4-nano: OK
  • CI run 24701970516: green
  • Parity gate run 24701970519: green

Thanks @zhulijin1991. I kept the original behavior, resolved the stale conflict, added extra regression coverage, and aligned the install-smoke timeout expectation that main had already changed to 900s.

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

Labels

agents Agent runtime and tooling extensions: codex maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants