Skip to content

Conversation

@dkhokhlov
Copy link
Contributor

@dkhokhlov dkhokhlov commented Nov 16, 2025

Description

  • codex exec --json resume --last "" bailed out because clap treated the prompt as SESSION_ID. I removed the conflicts_with flag and reinterpret that positional as a prompt when
    --last is set, so the flow now keeps working in JSON mode. (codex-rs/exec/src/cli.rs:84-104, codex-rs/exec/src/lib.rs:75-130)
  • Added a regression test that exercises resume --last in JSON mode to ensure the prompt is accepted and the rollout file is updated. (codex-rs/exec/tests/suite/resume.rs:126-178)

Testing

  • just fmt
  • cargo test -p codex-exec
  • just fix -p codex-exec
  • cargo test -p codex-exec

#6717

Signed-off-by: Dmitri Khokhlov <dkhokhlov@cribl.io>
@github-actions
Copy link

github-actions bot commented Nov 16, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@dkhokhlov
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Nov 16, 2025
pub session_id: Option<String>,

/// Resume the most recent recorded session (newest) without specifying an id.
#[arg(long = "last", default_value_t = false, conflicts_with = "session_id")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropping conflicts_with = "session_id" was safe here:

  • The only time clap used that constraint was to reject resume --last when was parsed as SESSION_ID. We now re-interpret that positional as the prompt whenever --last is set.

  • Users can still run resume <SESSION_ID> without --last; the parser still sets session_id and leaves last false, so nothing changes for that flow.

  • If someone deliberately provides both an ID and --last, we prefer the session_id path because we only treat the positional as a prompt when last is true and no explicit prompt was supplied. So accidental conflicts disappear, and intentional resume --last -- session-id (if someone tried) still resolves consistently.

Clap doesn’t need the explicit conflicts_with once the parser logic distinguishes the cases.

@etraut-openai
Copy link
Collaborator

Thanks for the contribution. Please take a look at the codex code review above.

@etraut-openai etraut-openai added the needs-response Additional information is requested label Nov 16, 2025
@dkhokhlov
Copy link
Contributor Author

dkhokhlov commented Nov 19, 2025

@etraut-openai any action on my side? that code comment was from me.

@etraut-openai
Copy link
Collaborator

@codex review

@etraut-openai etraut-openai removed the needs-response Additional information is requested label Nov 19, 2025
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

#[arg(long = "last", default_value_t = false)]
pub last: bool,

/// Prompt to send after resuming the session. If `-` is used, read from stdin.
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Restore --last/session_id conflict

Removing conflicts_with = "session_id" means clap will now happily parse codex exec resume <SESSION_ID> --last. With the new prompt fallback we even reinterpret that <SESSION_ID> as the prompt, but resolve_resume_path still treats args.last as authoritative and ignores the provided id. The net result is that this command (which used to error) silently resumes the most recent conversation instead of the explicit session the user asked for, and sends the session id string as the first prompt. That is a regression in CLI safety—users/scripts that accidentally pass both options now touch the wrong session. We need to keep the conflict (or otherwise reject the combination) while fixing the JSON-mode prompt parsing.

Useful? React with 👍 / 👎.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is correct, but I'm not sure how to express this more cleanly with clap.

@etraut-openai etraut-openai merged commit e4257f4 into openai:main Nov 20, 2025
25 of 26 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants