A comprehensive toolkit for continuing Anthropic Codex CLI sessions with full context preservation, similar to Claude's --continue feature.
- Session Persistence: Continue previous Codex sessions with complete context
- Directory-Aware: Automatically finds sessions for your current working directory
- Multiple Loading Strategies: Choose optimal method based on your needs
- Session Selection: Resume any previous session, not just the latest
- Context Verification: Ensure full context is loaded correctly
- Token Optimization: Smart chunking and loading strategies
- Tool History: Preserves tool calls and outputs
- Python 3.6+
- Codex CLI installed
- Unix-like environment (macOS/Linux)
- Clone the repository:
git clone https://github.com/BTankut/codex-resume-tool.git
cd codex-resume-tool- Make scripts executable:
chmod +x *.py- Add all aliases at once:
cat >> ~/.zshrc << 'EOF'
# Codex Resume Tool Aliases
alias codex-resume="python3 $(pwd)/codex-resume.py"
alias codex-resume-full="python3 $(pwd)/codex-resume-full.py"
alias codex-direct="python3 $(pwd)/codex-resume-direct.py"
alias codex-chunked="python3 $(pwd)/codex-resume-chunked.py"
alias codex-verify="python3 $(pwd)/verify-context.py"
EOF
source ~/.zshrccodex-resume # Resume most recent session
codex-resume --list # List all sessions for current directory
codex-resume --session 3 # Resume specific session #3
codex-resume --help # Show detailed help- Token Usage: ~8,000 tokens
- Content: Last 30 messages only
- Speed: Very fast
- Use When: Quick continuation of recent work
codex-resume-full # Resume with FULL context
codex-resume-full --list # List sessions with sizes
codex-resume-full --session 2 # Load session #2 with full context
codex-resume-full --help # Show detailed help- Token Usage: 50,000-250,000+ tokens
- Content: ALL messages, tool calls, outputs
- Loading: Uses file reading (π tool) with optimized chunking
- Use When: Need complete history, calculations, tool outputs
codex-direct # Load context directly
codex-direct --list # List available sessions
codex-direct --session N # Load specific session- Token Usage: ~80,000 tokens
- Content: Optimized selection of important content
- Speed: Fast, no chunking issues
- Use When: File reading is problematic
codex-chunked # Load with intelligent chunking- Token Usage: ~50,000 tokens
- Content: Last 50 important messages
- Use When: Alternative lightweight option
codex-verify # Check if context was fully loadedRun this in a separate terminal after loading context to verify:
- File size and location
- Line and token counts
- Content markers
- Tool call statistics
| Command | Tokens | Speed | Completeness | Best For |
|---|---|---|---|---|
codex-resume |
~8K | β‘β‘β‘ | Last 30 msgs | Quick work |
codex-resume-full |
50K-250K+ | β‘ | Everything | Critical work |
codex-direct |
~80K | β‘β‘ | Optimized | No file reading |
codex-chunked |
~50K | β‘β‘ | Smart selection | Alternative |
codex-resume --listShows:
- Session filenames with timestamps
- File sizes
- Modification times
- Session numbers for selection
codex-resume --session 2 # Lightweight load of session #2
codex-resume-full --session 2 # Full load of session #2After loading context, verify in Codex:
"How many lines did you read?"
"Did you find the END OF HISTORY marker?"
"Search for [TOOL: - how many occurrences?"
Or from another terminal:
codex-verifyEdit codex-resume.py:
recent_messages = messages[-30:] # Change 30 to desired countEdit codex-resume-full.py:
optimal_chunk_size = 2000 # Increase for fewer read operationsThe scripts use intelligent chunking:
- Default: 2000 lines per chunk (1-2 reads total)
- Codex default: 25 lines (40+ reads)
- Adjustable based on your needs
- Codex uses file reading capability (π), not a "Read tool"
- Script automatically handles this
- Use
codex-directfor direct loading - Or increase
optimal_chunk_sizein scripts
- Run
codex-verifyto check - Look for start/end markers
- Verify token count matches expected
- Ensure you're in the correct directory
- Check
~/.codex/sessions/for files - Use
--listto see available sessions
codex-resume-tool/
βββ codex-resume.py # Lightweight resume (8K tokens)
βββ codex-resume-full.py # Full context resume (250K+ tokens)
βββ codex-direct.py # Direct loading without file reading
βββ codex-chunked.py # Smart chunked loading
βββ verify-context.py # Context verification tool
βββ VERIFICATION.md # Verification guide
βββ README.md # This file
βββ LICENSE # MIT License
The tool includes multiple verification methods:
- Automatic: Scripts report loading statistics
- Manual: Ask Codex about loaded content
- External: Use
codex-verifycommand
β Included:
- All user messages
- All assistant responses
- Tool calls (bash, edit, write, etc.)
- Tool outputs and results
- Error messages
β Not Included:
- Encrypted reasoning blocks
- State metadata
- System messages
- For day-to-day work: Use
codex-resume(fast, lightweight) - For critical continuity: Use
codex-resume-full(complete context) - Always verify: Run
codex-verifyfor important sessions - Session selection: Use
--listto find the right session - Monitor tokens: Check token usage with
/statusin Codex
- Token Limits: Full sessions can use 250K+ tokens
- Pro Account Recommended: For large context loading
- Directory Specific: Sessions are filtered by working directory
- No Auto-Execution: Scripts instruct Codex to wait for commands
Contributions welcome! Feel free to:
- Report issues
- Suggest improvements
- Submit pull requests
MIT License - see LICENSE file
- Inspired by Claude's
--continuefeature - Built for the Codex community
- Special thanks to Anthropic for Codex CLI
- Issues: GitHub Issues
- Author: @BTankut
Latest Version: 2.0.0
Last Updated: December 2024