codex-session-restore
Skill11 starsChanged 4 months agoMITView on GitHub
Use when Codex Desktop sidebar sessions disappear, fail with systemError, or cannot continue after a model_provider switch. Diagnoses and repairs active, non-archived sessions without changing authentication or provider configuration.
In this repository17 other files it gives its agents.
- app-bug-forensicsSkill
- app-feature-craftSkill
- app-release-readinessSkill
- design-taste-frontendSkill
- experiment-plannerSkill
- feishu-paper-readingSkill
- github-project-releaseSkill
- grill-meSkill
- paper-framework-figure-studio-proSkill
- paper-review-panelSkill
- paper-share-htmlSkill
- paper-visual-craftSkill
- paper-writingSkill
- rebuttal-response-skillsSkill
- research-evidenceSkill
- search-firstSkill
- ui-ux-pro-maxSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 4 are distinctive, and 16 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Use the bundled script first.
- Very specific: line 18
If the user switched from krill/custom to official OAuth and wants old active sessions to appear under the current official login, use …
- Very specific: line 20
If the user explicitly wants to switch the environment back to krill and make sessions belong to krill, use --provider krill.
- Very specific: line 22
Do not edit config.toml, auth.json, or cc-switch's current provider just to restore sidebar visibility.
- Very specific: line 49
Use repair-active --provider PROVIDER --apply --yes only after a dry run confirms the active non-archived session set is correct.
- Very specific: line 62
Run scan-thread --thread-id ID before single-thread repair.
- Very specific: line 67
Run the same command with --apply only after the preview is acceptable.
- Very specific: line 68
Run verify --provider PROVIDER or verify --thread-id ID --provider PROVIDER.
- Distinctive: line 69
If available, search the live Codex thread list for a known old title to confirm local sessions reappeared.
- Very specific: line 75
When the user says, "I am logged in with official Codex now, but my krill sessions disappeared," keep official OAuth as-is and migrate …
- Very specific: line 86
When the user explicitly wants to use krill as the current provider, repair active session metadata to krill:
- Very specific: line 97
Do not touch archived_sessions or archived rows unless the user explicitly asks and the command includes --include-archived.
- Distinctive: line 99
Do not switch provider configuration or copy third-party auth settings unless the user explicitly asks to change providers.
- Distinctive: line 102
Do not edit live files manually when the script can perform the same repair.
- Very specific: line 103
Do not use task_complete to close an interrupted or damaged turn.
- Very specific: line 105
Do not delete non-empty historical turns.
- Very specific: line 107
Do not close recent open turns unless the user explicitly confirms they are stale.
- Distinctive: line 111
Prefer single-thread repair before bulk repair unless the user explicitly asks to restore all active sessions.
- Very specific: line 116
Update threads.model_provider and rollout session_meta provider metadata.
- Very specific: line 130
Read references/recovery-checklist.md when deciding whether to repair provider metadata only, repair rollout structure, close child edges, …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Codex Session Restore
Use the bundled script first. It is dry-run by default and writes nothing unless
--apply is present.
Provider Direction Rule
Set --provider to the provider that Codex Desktop should recognize now, not
automatically to the provider that originally created the sessions.
- If the user switched from krill/custom to official OAuth and wants old active
sessions to appear under the current official login, use
--provider openai. - If the user explicitly wants to switch the environment back to krill and make
sessions belong to krill, use
--provider krill. - Do not edit
config.toml,auth.json, or cc-switch's current provider just to restore sidebar visibility. Changing current auth/provider is a separate user request.
Quick Start
Resolve <skill-dir> to the directory containing this SKILL.md; do not
assume a particular global skills installation root.
Restore old krill sessions into the current official/OAuth sidebar:
python "<skill-dir>/scripts/restore_codex_sessions.py" scan --provider openai
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-active --provider openai
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-active --provider openai --apply --yes
python "<skill-dir>/scripts/restore_codex_sessions.py" verify --provider openaiRepair one thread:
python "<skill-dir>/scripts/restore_codex_sessions.py" scan-thread --thread-id THREAD_ID --provider openai
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-thread --thread-id THREAD_ID --provider openai
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-thread --thread-id THREAD_ID --provider openai --apply
python "<skill-dir>/scripts/restore_codex_sessions.py" verify --thread-id THREAD_ID --provider openaiUse repair-active --provider PROVIDER --apply --yes only after a dry run
confirms the active non-archived session set is correct. Open turns newer than
30 minutes are treated as possibly active and are not closed unless
--close-recent-open-turns is explicitly present. Archived sessions stay
untouched unless --include-archived is explicitly present.
Workflow
- Identify the target thread id or run
scanto find active non-archived threads with provider mismatch, parse errors, open turns, open child spawn edges, or stale goals. - Decide the target provider from the user's current login/config goal:
current official OAuth means
openai; current krill meanskrill. - Run
scan-thread --thread-id IDbefore single-thread repair. Readreferences/recovery-checklist.mdwhen the report shows multiple issue types or Codex Desktop still showssystemError. - Run
repair-thread --thread-id ID --provider PROVIDERorrepair-active --provider PROVIDERwithout--applyto preview actions. - Run the same command with
--applyonly after the preview is acceptable. - Run
verify --provider PROVIDERorverify --thread-id ID --provider PROVIDER. - If available, search the live Codex thread list for a known old title to confirm local sessions reappeared. Otherwise fully restart Codex Desktop so the app server reloads thread state from disk.
Common Provider Switch Recipes
When the user says, "I am logged in with official Codex now, but my krill
sessions disappeared," keep official OAuth as-is and migrate active session
metadata to openai:
python "<skill-dir>/scripts/restore_codex_sessions.py" scan --provider openai
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-active --provider openai
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-active --provider openai --apply --yes
python "<skill-dir>/scripts/restore_codex_sessions.py" verify --provider openaiWhen the user explicitly wants to use krill as the current provider, repair
active session metadata to krill:
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-active --provider krill
python "<skill-dir>/scripts/restore_codex_sessions.py" repair-active --provider krill --apply --yes
python "<skill-dir>/scripts/restore_codex_sessions.py" verify --provider krillSafety Rules
- Do not touch
archived_sessionsor archived rows unless the user explicitly asks and the command includes--include-archived. - Do not switch provider configuration or copy third-party auth settings unless the user explicitly asks to change providers. Session restore normally repairs metadata to match the provider already in use.
- Do not edit live files manually when the script can perform the same repair.
- Do not use
task_completeto close an interrupted or damaged turn. Useturn_aborted. - Do not delete non-empty historical turns. The script isolates open turns by
inserting or appending
turn_aborted. - Do not close recent open turns unless the user explicitly confirms they are
stale. Use
--close-recent-open-turnsonly for known failed continuations. - Back up before every write. The script creates
session-restore-backup-YYYYMMDD-HHMMSSunderCODEX_HOME. - Prefer single-thread repair before bulk repair unless the user explicitly asks to restore all active sessions.
Script Capabilities
- Update
threads.model_providerand rolloutsession_metaprovider metadata. - Detect rollout parse errors, missing rollout files, open task turns, and provider metadata drift.
- Coalesce duplicate
turn_contextentries by uniqueturn_id; ignore legacy no-turn_idcontexts for mutation. - Insert one
turn_abortedevent per stale open turn. - Close stale
thread_spawn_edgesafter making child rollouts internally closed. - Report non-complete
thread_goals; optionally complete them only when an explicit repair flag is used. - Print provider distributions, backup paths, modified files, and restart guidance.
Reference
Read references/recovery-checklist.md when deciding whether to repair provider
metadata only, repair rollout structure, close child edges, complete stale goals,
or ask the user to restart Codex Desktop.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

