Skip to content

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

@SockingPanda

Description

@SockingPanda

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions