-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Request: expose conversation fork/backtrack API in @openai/codex-sdk #4972
Description
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:
- store the entire transcript myself on the client, and
- 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:
- fetch the rollout metadata/path for a thread;
- truncate history before the _n_th user message, matching the CLI logic;
- 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!