Skip to content

Codex image summaries fail because -i consumes exec #242

@alfozan

Description

@alfozan

Summary

Local image summaries fail when the Codex CLI backend is selected because summarize puts Codex image args before the exec subcommand:

codex -i <image.jpg> exec --output-last-message ...

Codex's -i/--image <FILE>... option accepts multiple files, so exec can be consumed as another image argument. The remaining --output-last-message flag is then parsed at the wrong command level and Codex exits before the summary starts.

Reproduction

This came up from a repo workspace with a local WhatsApp media image. The exact file is not important, any local JPEG that uses the Codex backend should exercise the same argv shape:

summarize /path/to/WhatsApp-Assistant/profiles/global-equities-testing/media/3AFF789EBAE19B8737AB/0-example.jpg --length short --plain

Observed failure:

Command failed: codex -i /path/to/image.jpg exec --output-last-message /tmp/.../last-message.txt --skip-git-repo-check --json -m gpt-5.5 -c text.verbosity="medium"
error: unexpected argument '--output-last-message' found

Running the same Codex invocation with exec before -i works:

codex exec -i /path/to/image.jpg --output-last-message /tmp/last-message.txt --skip-git-repo-check --json -m gpt-5.5 'Summarize this image briefly.'

Expected behavior

The Codex backend should invoke image summaries as:

codex exec -i <image.jpg> --output-last-message ...

Likely cause

buildAssetCliContext() correctly adds Codex image attachment args as:

codex: ["-i", filePath]

But the Codex provider path in src/llm/cli.ts appends those extra args before exec. This is adjacent to the Codex argument construction touched by #215, but #215 fixed isolation/context loading and did not change the relative order of codexExtraArgs and exec.

Proposed fix

Move the Codex subcommand before provider-specific extra args:

args.push("exec");
args.push(...codexExtraArgs);

and add a regression test asserting that exec appears before -i for image summaries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions