Skip to content

No way to resume in non-interactive mode when session id is not outputted #3817

Closed

Description

@jordan-BAIC

codex-cli 0.36.0

codex exec --json "<my message>" does not return a session id, and therefore I cannot then perform codex exec --json resume <session_id> "<my followup message"

using codex proto seems to have the opposite problem, it returns a session id but is not capable of resuming with it.

My workaround for now if getting the latest session id from the ~/.codex/sessions directory, but my application lets you run multiple prompts in rapid succession so this is not reliable.

Activity

  1. added
    bug
    on Sep 17, 2025
  2. MaurUppi commented on Sep 18, 2025

    @MaurUppi
  3. skeskinen commented on Sep 20, 2025

    @skeskinen

    Facing the same issue with vibe-kanban.

    codex-cli 0.38.0 & codex-cli 0.39.0

  4. eadlam commented on Sep 28, 2025

    @eadlam

    You can use --last with exec.

  5. pakrym-oai commented on Oct 1, 2025

    @pakrym-oai
    Contributor

    Hi, can you please try codex exec --experimental-json (will soon become the default --json behavior) that returns thread_id in combination with codex exec resume <thread_id>?

  6. varunursekar commented on Oct 1, 2025

    @varunursekar

    @pakrym-oai This kind of works, however, cli flags and arguments from the first invocation aren't preserved in subsequent ones - in the screenshot below you can see that when we resume, it no longer outputs JSON. Maybe for JSON this isn't so bad, but there are other arguments (e.g. skip-git-repo-check) that preclude this workaround.

    Image
  7. pakrym-oai commented on Oct 1, 2025

    @pakrym-oai
    Contributor

    The current command line parsing logic is a bit deficient and requires arguments to go between codex exec and resume
    try codex exec --experimental-json <other args> resume ... .

    We are aware and working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions