-
Notifications
You must be signed in to change notification settings - Fork 289
Description
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:
- Reuse
findCodexSessionFile()to find the matching JSONL session file for the workspace - Extract the thread/session ID from the JSONL filename
- Extract conversation context from the JSONL (last user prompt or session summary)
- Build a CLI command with context as the initial prompt:
codex [flags] -- "Continue previous session. Context: <summary>" - Return
nullif no session found (falls back to freshgetLaunchCommand())
Reference: packages/plugins/agent-claude-code/src/index.ts lines 732-759 — getRestoreCommand() pattern.
Files to modify
packages/plugins/agent-codex/src/index.ts— addgetRestoreCommand()methodpackages/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
nullwhen no matching session found - Returns
nullwhen workspacePath is missing - Does not throw on corrupt/missing session files