Creates a new idle session whose transcript is the source path up to a cut, with the same entry
ids. Nothing live is shared (listeners, queue, run, lock, usage); the fork's file is written
lazily at its first own message, with parentSession and gptr.forkOf in its header. The
fork's workspace is an overlay of the source's kept home: it reads every object of the source
at zero cost, and its ordinary assignments stay in the overlay, but code that modifies an
object by reference (data.table := and set*(), environments and R6 objects, <<-,
assign(envir =)) changes the source's object too; copy such objects first, for example with
data.table::copy(), when a branch must not touch them.
Usage
gptr_fork(s, at = NULL, envir = c("overlay", "shared"))Examples
fake = gptr_fake_provider(list("A", "B"))
session = peter("first", model = fake)
#> gptr: thinking
#> gptr: done · fake-1 · 1 request · 1.6k tokens · 99% context left
branch = gptr_fork(session)
branch |> peter("branch")
#> gptr: thinking
#> gptr: done · fake-1 · 1 request · 1.6k tokens · 99% context left
#> B
#> idle · fake/fake-1 · 2 turns · 1.6k tokens · $0.0000 · sf032e10a3f
c(session$turns, branch$turns)
#> [1] 1 2