Repository navigation
Conversation
harvest_codex() only walked the flat Codex Desktop archive (~/.codex/archived_sessions), so machines running the Codex CLI — which writes nested ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl files — harvested zero sessions, and the 'auto' source silently fell back to Claude transcripts. - walk both layouts: the Desktop archive (flat) and the sibling sessions/ tree (recursive) - deduplicate adjacent (role, text) pairs when digesting: CLI rollouts record every turn twice (response_item/message + event_msg/*_message, adjacent in either order), which double-counted turns - add tests/test_harvest_codex_cli.py covering nested-layout discovery, desktop+CLI combination, and the dedup/environment_context cases
There was a problem hiding this comment.
🟡 Changes recommended
Reset deduplication across skipped records and strengthen assistant-turn assertions.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds Codex CLI rollout harvesting alongside existing Desktop archive support.
Changes:
- Recursively discovers nested CLI sessions.
- Deduplicates mirrored user and assistant messages.
- Adds coverage for discovery, parsing, tools, and empty sessions.
File summaries
| File | Summary |
|---|---|
tests/test_harvest_codex_cli.py |
Tests CLI rollout harvesting behavior. |
skillopt_sleep/harvest_codex.py |
Supports both layouts and message deduplication. |
Review details
Suppressed comments (1)
tests/test_harvest_codex_cli.py:77
- The fixture includes an event_msg/response_item assistant duplicate, but the assertions only verify user-turn deduplication. A regression that double-counts or duplicates assistant turns would still pass; please assert the assistant count and final text as well.
assert d.n_user_turns == 2
assert d.user_prompts == ["fix the failing tests", "wrong flag, try again"]
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (output_role, sanitized) == last_recorded: | ||
| continue | ||
| last_recorded = (output_role, sanitized) |
|
Thank you for extending discovery to the current Codex CLI rollout layout. Reviewed
|
@microsoft-github-policy-service agree |
Summary
SkillOpt-Sleep's
codextranscript source only supports the Codex Desktop layout: a flat~/.codex/archived_sessions/*.jsonldirectory. Machines running the Codex CLI (which is most CLI-only setups) never archive sessions there — the CLI writes nested rollout files under~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl— soharvest_codex()returns zero sessions and theautosource silently falls back to Claude transcripts. This PR makes the harvester support both layouts.Changes
harvest_codex()now collects candidates from the flat Desktop archive and recursively walks the siblingsessions/tree (derived fromcodex_home, so the existing--codex-home/codex_homeconfig keeps working).digest_codex_archived_session()deduplicates adjacent(role, text)pairs. CLI rollouts record every turn twice — once asresponse_item/messageand once asevent_msg/user_message/event_msg/agent_message(adjacent in either order) — which previously double-countedn_user_turns/n_assistant_turnsand duplicated prompts. Non-adjacent repeats (a user legitimately sending the same message twice) are preserved.user_message,agent_message,messagewithrole,exec_command_end,patch_apply_end, ...) and strips<environment_context>/<user_instructions>wrappers, so no parsing changes were needed beyond the dedup.Testing
tests/test_harvest_codex_cli.py: nested-layout discovery, desktop+CLI combination, turn dedup,<environment_context>dropping, tool-name extraction, and the no-messages →Nonecase.python -m pytest -q→ 1499 passed, 11 skipped, 353 subtests passed.Verification on a real Codex CLI install
Before:
skillopt-sleep harvest --source codex→ 0 sessions (217 rollout files, 1.5 GB on disk). After: full scan digests 120 sessions in ~14 s and mines 39 tasks with the mock backend; a nightlyruncompletes end-to-end against the real Codex backend.