Skip to content

Conversation

@dkhokhlov
Copy link
Contributor

@dkhokhlov dkhokhlov commented Nov 28, 2025

Addressed:

Changes

  • change --last flag to accept optional prompt value (e.g. --last <PROMPT>)
  • simplify prompt handling by using last_prompt() helper method
  • reject invalid or nonexistent session IDs with error message instead of silently creating new conversation
  • reinstate clap's conflicts_with between --last and explicit session id
  • add tests for conflict validation, prompt forwarding, and invalid session ID rejection

Problems

1. Interactive codex resume --last didn't accept prompt values (#6717)

Problem: The interactive codex resume --last command used a boolean flag that couldn't accept a prompt value. Users couldn't provide a prompt directly after --last.

Before:

$ codex resume --last "next steps"
# --last was a bool flag, prompt was ignored

After:

$ codex resume --last "next steps"
# Now correctly accepts and forwards the prompt

2. codex exec resume silently ignored session_id when used with --last (#6719 discussion)

Problem: When both a session ID and --last were provided, the code silently ignored the session ID and used --last, potentially resuming the wrong session. This was unsafe for scripts and users.

Before:

$ codex exec resume 123e4567-e89b-12d3-a456-426614174000 --last
# Silently ignored the session_id and resumed most recent session
# Could touch the wrong session unintentionally

After:

$ codex exec resume 123e4567-e89b-12d3-a456-426614174000 --last
error: the argument '--last' cannot be used with '<SESSION_ID>'
# Fails fast with clear error message

3. Invalid session IDs silently created new conversations

Problem: When an invalid or nonexistent session ID was provided, codex exec resume silently created a new conversation instead of erroring, causing confusion.

Before:

$ codex exec resume sdfsdfgfds2546456 "2+2"
# Silently creates a new conversation (confusing!)
$ codex exec resume 123e4567-e89b-12d3-a456-426614174000 "2+2"
# (UUID format valid but session doesn't exist)
# Silently creates a new conversation

After:

$ codex exec resume sdfsdfgfds2546456 "2+2"
No saved session found with ID sdfsdfgfds2546456.
# Exits with error code 1
$ codex exec resume 123e4567-e89b-12d3-a456-426614174000 "2+2"
No saved session found with ID 123e4567-e89b-12d3-a456-426614174000.
# Exits with error code 1

Testing

Added tests for:

  • Invalid session ID rejection (non-UUID format)
  • Nonexistent valid UUID rejection
  • Conflict validation between --last and session ID
  • Prompt forwarding when using --last <PROMPT>

All existing tests pass, and the behavior now matches the interactive codex resume command which already had proper error handling.

- change `--last` flag to accept optional prompt value (e.g. `--last <PROMPT>`)
- simplify prompt handling by using `last_prompt()` helper method
- reject invalid or nonexistent session IDs with error message instead of silently creating new conversation
- reinstate clap's `conflicts_with` between `--last` and explicit session id
- add tests for conflict validation, prompt forwarding, and invalid session ID rejection
@dkhokhlov
Copy link
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

@dkhokhlov dkhokhlov marked this pull request as ready for review November 28, 2025 04:07
@dkhokhlov dkhokhlov changed the title fix resume --last prompt handling and reinstate session-id conflict fix resume --last prompt handling and reinstate session-id conflict check Nov 28, 2025
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.

1 participant