Allow forked sessions to be re-rooted so obsolete ancestors can be deleted
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
What variant of Codex are you using?
CLI
What feature would you like to see?
Please add a supported operation that detaches or re-roots a forked session.
Editing and resubmitting an earlier prompt creates a new session with a fresh ID. The new session records the previous session in forked_from_id. This preserves the original branch, which is useful.
However, repeated rewinds can produce a linear chain:
A → B → C → D → E → F
Assume that F is the current session. I want to preserve F and permanently delete the obsolete sessions A through E.
The current operations do not support this:
- Archiving A through E hides them but preserves their transcripts and storage.
- Deleting an ancestor also deletes its descendants.
- Forking F creates another descendant instead of an independent root.
Please provide an explicit operation such as:
codex detach <SESSION>
or an equivalent UI action.
The operation should:
- Verify that the selected session can resume independently.
- Remove or replace its parent relationship.
- Preserve the selected session as a new root.
- Permit ordinary deletion of its previous ancestors.
- Warn that the detached session still contains inherited conversation content.
- Update the rollout files and SQLite metadata transactionally.
- Report a precise error if the session cannot be detached safely.
If the session stores a complete copied history, detaching can reuse that history. If it uses reference-backed or delta history, Codex should materialize the required history or refuse with a clear explanation.
The existing descendant-cascade behavior for codex delete should remain the default. Explicit detachment would preserve that privacy guarantee while allowing intentional cleanup.
Additional information
Environment:
- Codex CLI 0.151.0
- macOS 26.6.2
I reproduced this with a sequence of conversation rewinds. The resulting session_meta records formed a direct forked_from_id chain. The final session remained active and resumable.
Running codex delete <ancestor> --force could not remove an ancestor while preserving the active leaf. It returned only:
Error: failed to delete session
A more specific error would also help. It should identify that the target has descendants and explain that deletion would include them.
The official documentation states that /fork clones the current chat into a new session and that session deletion removes descendants:
https://developers.openai.com/codex/cli/reference/
Related issues cover adjacent behavior but not descendant-preserving cleanup:
- #26348: rewind UX and accidental branch proliferation
- #35647: full-history fork storage amplification
- #38144: parent writer remains active after a fork
- #39919: non-atomic session deletion failures
I searched open and closed issues but did not find an existing request for detaching or re-rooting a fork before deleting its ancestors.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the CLI session fork and delete operations, then inspect the rollout files and SQLite session_meta records mentioned in the issue. Define how detachment validates resumability and updates the parent relationship transactionally. Done means a detached session remains usable, its ancestors can be deleted, unsafe cases return precise errors, and inherited-content warnings are shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sqlite
- Domain
- cli, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100