Request: expose conversation fork/backtrack API in @openai/codex-sdk

Resolved 💬 4 comments Opened Oct 8, 2025 by SockingPanda Closed Oct 8, 2025
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Summary

In the Codex CLI you can hit Ctrl + T and backtrack to fork a conversation at an earlier user turn. Under the hood the CLI issues Op::GetPath, reads the rollout JSONL, truncates before the selected user message, and calls ConversationManager::fork_conversation to spin up a new branch.

Problem

The TypeScript SDK only exposes startThread, resumeThread, run, and runStreamed, so there’s no way to replicate the CLI’s forking workflow. Once a thread is running, I can’t:

  • obtain rollout metadata or the JSONL path,
  • trim history at a given user turn, or
  • start a new thread seeded with that truncated history.

To approximate the behavior today I have to:

  1. store the entire transcript myself on the client, and
  2. whenever I “rewind,” create a brand-new thread and manually replay the context.

That works, but it diverges from the CLI experience and makes it hard to share forked context across tools.

Request

Please expose an SDK-level API (or document the workflow) that lets developers:

  1. fetch the rollout metadata/path for a thread;
  2. truncate history before the _n_th user message, matching the CLI logic;
  3. optionally prefill the next prompt with the selected user input.

Even lower-level primitives—e.g. codex.getRollout(threadId) returning the JSONL path or entries, plus a codex.forkConversation(options) helper—would let SDK users recreate the CLI backtrack flow without reimplementing Codex internals.

Use case

I’m building a personal project and would like to offer the same “fork from history” capability that the CLI exposes via Ctrl + T. Without official support I have to rebuild the entire context locally, which is cumbersome and error-prone.

Thanks for considering!

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 10 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #4690
  • #4514
  • #3005
  • #3492

Powered by Codex Action

matthew-plusprogramming · 10 months ago

Was this completed? I don't see an referenced commit

matthew-plusprogramming · 10 months ago

@SockingPanda

mistercrunch · 4 months ago

I don't think forking is actually supported/implemented on the SDK, can we re-open the issue?