Skip to content

feat: add image support and improve error resilience for Codex#7033

Merged
codefromthecrypt merged 2 commits intomainfrom
codex-refactor
Feb 6, 2026
Merged

feat: add image support and improve error resilience for Codex#7033
codefromthecrypt merged 2 commits intomainfrom
codex-refactor

Conversation

@codefromthecrypt
Copy link
Collaborator

Summary

Fix image support for both Codex providers. Previously, users could paste or attach images in goose desktop, but both the Codex CLI and ChatGPT Codex providers silently dropped them — the image appeared in the chat UI but was never sent to the model.

Codex CLI provider (codex): Images are now decoded from base64, written to temp files, and passed to the CLI via the -i flag.

ChatGPT Codex provider (chatgpt_codex): Images are now serialized as input_image content items with a data: URI in the Responses API payload.

Additional improvements (Codex CLI)

  • Model list: Added fetch_supported_models so the UI model dropdown populates correctly
  • Error resilience: Context window exhaustion and rate limit errors are now classified correctly, enabling automatic context compaction and backoff instead of hard failure. Partial responses are preserved on non-zero exit.
  • Hang prevention: A stderr drain prevents pipe buffer deadlock when the CLI writes large error output.

Type of Change

  • Feature
  • Bug fix

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Image path

run just run-ui then attach an test_image.jpg, ask "what's in this image?":

Related Issues

Extracted from #6972

Screenshots/Demos (for UX changes)

Before — Codex CLI (goose v1.23.1, image visible in chat but silently dropped):
codex-cli-before

Before — ChatGPT Codex (goose v1.23.1, image visible in chat but silently dropped):
chatgpt-codex-before

After — Codex CLI (image passed via codex exec -i <FILE>):
codex-cli-after

After — ChatGPT Codex (image sent as input_image in API payload):
chatgpt-codex-after

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds image support to both Codex providers (CLI and ChatGPT) and improves error resilience. Previously, images were visible in the UI but silently dropped during API calls.

Changes:

  • Added image handling for Codex CLI provider (base64 decode → temp files → -i flags)
  • Added image serialization for ChatGPT Codex provider (data URI format in API payload)
  • Improved error classification to handle context window exhaustion and rate limits properly
  • Added stderr draining to prevent pipe buffer deadlock in Codex CLI
  • Added fetch_supported_models implementation for UI model dropdown
  • Refactored messages_to_prompt into a single-pass prepare_input function

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/goose/src/providers/codex.rs Implemented image support via temp files, improved error handling, added stderr draining, refactored input preparation
crates/goose/src/providers/chatgpt_codex.rs Added image serialization as input_image content with data URI

Signed-off-by: Adrian Cole <adrian@tetrate.io>
let prompt = self.messages_to_prompt(system, messages);
// Single pass: text → prompt (stdin), images → temp files (-i flags)
let image_dir = Paths::state_dir().join("codex/images");
std::fs::create_dir_all(&image_dir).ok();
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: ignoring the possible error here means that we'll fail later, inside prepare_input, when we try to create the temp file, which could be more confusing than if we failed here.

@codefromthecrypt codefromthecrypt added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 2c7e229 Feb 6, 2026
18 checks passed
@codefromthecrypt codefromthecrypt deleted the codex-refactor branch February 6, 2026 10:36
katzdave added a commit that referenced this pull request Feb 6, 2026
…webtoken-10.3.0

* origin/main: (54 commits)
  Switch tetrate tool filtering back to supports_computer_use (#7024)
  feat(ui): add inline rename for chat sessions in sidebar (#6995)
  fix: handle toolnames without underscores (#7015)
  feat(claude-code): use stream-json protocol for persistent sessions (#7029)
  test(providers): add model listing to live provider suite (#7038)
  Agent added too much (#7036)
  fix(deps): bump tree-sitter to 0.26 and set sqlx default-features=false to fix RUSTSEC advisories (#7031)
  feat: add image support and improve error resilience for Codex (#7033)
  fix(providers): Azure OpenAI model listing 404 during configure (#7034)
  fix(deps): bump bat to 0.26.1 to resolve RUSTSEC-2026-0008 (#7021)
  Don't swallow Tetrate errors  (#6998)
  docs: remove hardcoded_stuff links (#7016)
  fix(ui): keep Hub chat input from overlapping SessionInsights on paste (#6719)
  Clean up css (#6944)
  docs: aws bedrock bearer token auth (#6990)
  docs: extended custom provider headers support (#7012)
  feat(cli): add type-to-search filtering to select/multiselect dialogs (#6862)
  feat(ci): add cargo-audit workflow for scanning rust vulnerabilities (#6351)
  feat: add User-Agent header to MCP HTTP requests (#6988)
  chore(deps-dev): bump webpack from 5.102.1 to 5.105.0 in /ui/desktop (#6996)
  ...

# Conflicts:
#	Cargo.lock
zanesq added a commit that referenced this pull request Feb 6, 2026
* origin/main:
  Remove build-dependencies section from Cargo.toml (#6946)
  add /rp-why skill blog post (#6997)
  fix: fix snake_case function names in code_execution instructions (#7035)
  Document max_turns settings for recipes and subagents (#7044)
  feat: update Groq declarative data with Preview Models (#7023)
  fix(codex): propagate extended PATH to codex subprocess (#6874)
  Switch tetrate tool filtering back to supports_computer_use (#7024)
  feat(ui): add inline rename for chat sessions in sidebar (#6995)
  fix: handle toolnames without underscores (#7015)
  feat(claude-code): use stream-json protocol for persistent sessions (#7029)
  test(providers): add model listing to live provider suite (#7038)
  Agent added too much (#7036)
  fix(deps): bump tree-sitter to 0.26 and set sqlx default-features=false to fix RUSTSEC advisories (#7031)
  feat: add image support and improve error resilience for Codex (#7033)
  fix(providers): Azure OpenAI model listing 404 during configure (#7034)
  fix(deps): bump bat to 0.26.1 to resolve RUSTSEC-2026-0008 (#7021)
  Don't swallow Tetrate errors  (#6998)
  docs: remove hardcoded_stuff links (#7016)

# Conflicts:
#	ui/desktop/src/components/GooseSidebar/AppSidebar.tsx
kuccello pushed a commit to kuccello/goose that referenced this pull request Feb 7, 2026
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.

2 participants