openai / openai/codex

Allow forked sessions to be re-rooted so obsolete ancestors can be deleted

Open
#41,713 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CLI enhancement session
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:

  1. Verify that the selected session can resume independently.
  2. Remove or replace its parent relationship.
  3. Preserve the selected session as a new root.
  4. Permit ordinary deletion of its previous ancestors.
  5. Warn that the detached session still contains inherited conversation content.
  6. Update the rollout files and SQLite metadata transactionally.
  7. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.