Files
paseo/REPORT-codex-history-bug.md
T
Mohamed BoudraandClaude Opus 4.5 40835bbe9d Fix Codex history persistence after daemon restart
- Modified loadPersistedHistoryFromDisk() to use sessionId or conversationId as fallback
- Added rollout path and session dir persistence in agent metadata
- Added fallback to default Codex session root when metadata path is empty
- Cleaned up create-agent-modal.tsx (removed 800+ lines of dead code)
- Updated app routing and home-footer cleanup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 11:39:20 +07:00

15 lines
1.0 KiB
Markdown

# Codex history missing after daemon restart
## Root cause
- Codex MCP history loader only searched a single session root derived from `CODEX_SESSION_DIR` (or metadata), then stopped.
- In practice the Codex CLI still writes rollouts under the default `~/.codex/sessions` even when a custom session dir is present in metadata, so the lookup could miss the real rollout file after a daemon restart.
- When the lookup fails, `loadPersistedHistoryFromDisk()` returns an empty timeline, so `streamHistory()` yields nothing and the UI shows an empty conversation.
## Fix
- Prefer a persisted rollout path if present, but fall back to scanning the default Codex sessions directory when the preferred root has no rollout file.
- Allow history lookup to use `conversationId` when `sessionId` is missing so resume still works.
- Persist `codexSessionDir` so future resumes can try the same root first, but always fall back to the default root if it does not contain the rollout file.
## Files touched
- `packages/server/src/server/agent/providers/codex-mcp-agent.ts`