Skip to content

feat(agent-codex): conversation resume via getRestoreCommand() #183

@suraj-markup

Description

@suraj-markup

Problem

Claude Code's plugin implements getRestoreCommand() which builds a claude --resume <sessionId> command, allowing sessions to resume with full conversation history. The agent-codex plugin does NOT implement getRestoreCommand(), so session-manager.ts always falls back to a fresh getLaunchCommand() — all conversation context is lost on restore.

Related: #161 explored resume workarounds via context re-injection.

Codex CLI Resume Limitations

Unlike Claude Code (claude --resume <id>), the Codex CLI does not have a --resume or --thread-id flag for CLI mode. True conversation resume requires the app-server's thread/resume JSON-RPC method.

What to implement

Implement getRestoreCommand() as a context re-injection workaround:

  1. Reuse findCodexSessionFile() to find the matching JSONL session file for the workspace
  2. Extract the thread/session ID from the JSONL filename
  3. Extract conversation context from the JSONL (last user prompt or session summary)
  4. Build a CLI command with context as the initial prompt: codex [flags] -- "Continue previous session. Context: <summary>"
  5. Return null if no session found (falls back to fresh getLaunchCommand())

Reference: packages/plugins/agent-claude-code/src/index.ts lines 732-759 — getRestoreCommand() pattern.

Files to modify

  • packages/plugins/agent-codex/src/index.ts — add getRestoreCommand() method
  • packages/plugins/agent-codex/src/index.test.ts — add tests

Acceptance criteria

  • getRestoreCommand() returns a valid CLI command when a matching session exists
  • Command includes the same flags as getLaunchCommand() (permissions, model, reasoning)
  • Extracted context is shell-escaped and passed as prompt
  • Returns null when no matching session found
  • Returns null when workspacePath is missing
  • Does not throw on corrupt/missing session files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions