Skip to content

fix(openai): disable image generation tool for Codex models - #148

Closed
naveenreddy007 wants to merge 1 commit into
1jehuang:masterfrom
naveenreddy007:fix/codex-disable-image-generation-tool
Closed

naveenreddy007 wants to merge 1 commit into
1jehuang:masterfrom
naveenreddy007:fix/codex-disable-image-generation-tool

Conversation

@naveenreddy007

@naveenreddy007 naveenreddy007 commented May 6, 2026 •

Copy link
Copy Markdown

Summary

  • Do not attach the provider-native image_generation tool when the active OpenAI/ChatGPT model is a Codex model.
  • Preserve native image generation for non-Codex ChatGPT models.
  • Add payload regression tests for both supported and unsupported model families.

Why

ChatGPT/Codex routes such as gpt-5.3-codex-spark can reject requests with:

invalid_request_error: Tool 'image_generation' is not supported with gpt-5.3-codex-spark-1p-codexswic-ev3.

This happens because Jcode currently adds image_generation for all ChatGPT-mode OpenAI requests. Codex models do not support that native tool, so requests can fail before the assistant can respond.

Validation

  • cargo fmt --all
  • cargo test test_chatgpt_payload_ --lib
  • cargo build --release

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

zombi3butt pushed a commit to zombi3butt/jcode that referenced this pull request May 22, 2026
In ChatGPT mode, build_response_request unconditionally pushed
{ "type": "image_generation" } onto the request's tool array. The
OpenAI Responses API rejects that tool for codex-family models
(gpt-5.x-codex*, including the [1m] long-context suffix variants)
with HTTP 400 ("unsupported tool image_generation for model …"),
which aborted the entire session for ChatGPT-mode codex users.

Add Self::supports_native_image_generation(model_id) returning false
for any model id whose lower-cased / [1m]-stripped form contains
"codex". Gate the tools.push site by that helper. Non-codex ChatGPT
models (gpt-5.x non-codex, gpt-4o, etc.) still receive the tool.

Two regression tests in src/provider/openai_tests/payloads.rs:
- test_chatgpt_payload_includes_native_image_generation_for_non_codex_models
- test_chatgpt_payload_excludes_native_image_generation_for_codex_models
  iterating gpt-5.3-codex, gpt-5.3-codex-spark, and gpt-5.3-codex-spark[1m].

Ports upstream PR 1jehuang#148.
Closes 1jehuang#115
@1jehuang 1jehuang added the triage: converted PR triage: worth tracking as an issue label Jun 12, 2026
@1jehuang

Copy link
Copy Markdown
Owner

Thanks! This repo no longer accepts external PRs, but the underlying problem is real - it's now tracked in #369 (with credit to this PR). Closing.

@1jehuang 1jehuang closed this Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage: converted PR triage: worth tracking as an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants