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; the mode it last ran with, or the mode setting for a file that records none; status idle when the tail is a final answer or, for a team or fan-out, an idle settlement, 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. From model code during a run, gptr_resume() needs an allowing permission decision (a person's, in every mode but yolo; see gptr_security); otherwise it signals gptr_error_permission.

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 · fake-1 · 1 request · 1.6k tokens · 99% context left
identical(gptr_last(), session)
#> [1] TRUE
gptr_sessions()
#> # Columns 1/2
#>   id           status  file      created              updated              turns
#> 1 s0e1f4b1996  idle    /tmp/...  2026-11-29 05:30:26  2026-11-29 05:30:26  1
#> 2 sa1b0845a68  idle    /tmp/...  2026-11-29 05:30:23  2026-11-29 05:30:24  2
#> 3 s2707d6b214  idle    /tmp/...  2026-11-29 05:30:19  2026-11-29 05:30:19  0
#> 4 s9ed925771f  idle    /tmp/...  2026-11-29 05:30:19  2026-11-29 05:30:19  1
#> 5 sdb8aa7fa98  idle    /tmp/...  2026-11-29 05:30:19  2026-11-29 05:30:19  1
#> 6 s94a5ad76ef  idle    /tmp/...  2026-11-29 05:30:18  2026-11-29 05:30:18  1
#> 7 sf032e10a3f  idle    /tmp/...  2026-11-29 05:30:15  2026-11-29 05:30:15  2
#> 8 s44f6546a78  idle    /tmp/...  2026-11-29 05:30:15  2026-11-29 05:30:15  1
#> # Columns 2/2
#>   model        title      live
#> 1 fake/fake-1  hi         TRUE
#> 2 fake/fake-1  Make x     TRUE
#> 3 fake/fake-1             TRUE
#> 4 fake/fake-1  Review it  TRUE
#> 5 fake/fake-1  Plan it    TRUE
#> 6 fake/fake-1  hi         FALSE
#> 7 fake/fake-1  first      TRUE
#> 8 fake/fake-1  first      TRUE
#> 
#> # 8 rows
identical(gptr_resume(session$id), session)
#> [1] TRUE