Skip to contents

gptr_sessions() lists the sessions of the workspace store (.gptr/sessions/, or tempdir()/gptr/sessions/ without a workspace), newest first. It reads only the header and the last lines of each file.

gptr_resume() returns the live object when one exists in this process; otherwise it rebuilds the session from its JSONL file (leaf = the last entry; status idle when the tail is a final answer, else interrupted) with home envir. A rebuilt fork always gets a fresh overlay of envir. A detached copy (from saveRDS(), a knitr cache or callr) is attached under the split-brain rules. block = returns the session that a document replay bound to that block. Resuming restores conversation state, not a complete analysis workspace, and does not rerun the R tool code. Make required objects available in envir; use document replay when the intention is to execute the recorded analysis again.

gptr_last() returns the most recently active session of this R process. It is held strongly (it survives gc()), so a session whose call was interrupted before its result was assigned is not lost.

Usage

gptr_sessions(project = TRUE)

gptr_resume(x = NULL, envir = parent.frame(), block = NULL, child = NULL)

gptr_last()

Arguments

project

TRUE: the stored sessions; FALSE: also the live sessions of this process that are not in that store.

x

NULL (the most recently updated stored session), a session id, a file path, or a detached gptr_session.

envir

The home of a rebuilt session.

block, child

A document block id (and a team member name): the session replay bound to that block in this process, or gptr_error_replay_unbound; never a fallback to envir.

Value

gptr_sessions() returns a gptr_sessions data frame: id, file, created, updated, turns, model, status, title (the first prompt, 60 characters), live. gptr_resume() returns a gptr_session: the live object when one exists in this process, otherwise one rebuilt from its session file. gptr_last() returns the most recently active session of this process, or NULL when no session was created in this process.

Examples

session = peter("hi", model = gptr_fake_provider(list("hello")))
#> gptr: thinking
#> gptr: done · 1 turn · 1.6k tokens · $0.0000
identical(gptr_last(), session)
#> [1] TRUE
gptr_sessions()
#> # Columns 1/2
#>   id           status       file       created     updated     turns  model
#> 1 s73215d9152  idle         /tmp/R...  2026-10...  2026-10...  1      fake/fa...
#> 2 s821e7f6633  idle         /tmp/R...  2026-10...  2026-10...  2      fake/fa...
#> 3 sd78fbf036e  interrupted  /tmp/R...  2026-10...  2026-10...  0      NA
#> 4 s5a87880424  idle         /tmp/R...  2026-10...  2026-10...  1      fake/fa...
#> 5 sa7b5e3174d  idle         /tmp/R...  2026-10...  2026-10...  1      fake/fa...
#> 6 s3118db43ad  idle         /tmp/R...  2026-10...  2026-10...  1      fake/fa...
#> 7 sc83c4ca36b  idle         /tmp/R...  2026-10...  2026-10...  2      fake/fa...
#> 8 s2d74f5e20c  idle         /tmp/R...  2026-10...  2026-10...  1      fake/fa...
#> # Columns 2/2
#>   title      live
#> 1 hi         TRUE
#> 2 Make x     TRUE
#> 3            TRUE
#> 4 Review it  TRUE
#> 5 Plan it    TRUE
#> 6 hi         FALSE
#> 7 first      FALSE
#> 8 first      FALSE
#> 
#> # 8 rows
identical(gptr_resume(session$id), session)
#> [1] TRUE