Skip to contents

Starts idle sessions that have queued input, then pumps until no session is running or waiting, or timeout seconds have passed. Every session's egress and replay checks pass before any is started, so a refusal starts none. On timeout the sessions keep their running status and no condition is raised.

Usage

gptr_wait(x, timeout = Inf)

Arguments

x

A session or a list of sessions (a team or fan-out session counts as one).

timeout

Seconds to wait.

Value

x, invisibly. For a single session, a terminal status signals its condition.

Details

timeout limits reactor polling; it does not interrupt R code. Request preparation and synchronous callbacks finish their current step before the deadline is checked again, so a call can return after the specified time.

A timeout is not cancellation. Inspect $status and use gptr_cancel() if you want to abort active work. In Rscript and rendered reports, a blocking call such as this is how experimental background sessions progress when there is no idle console.

Examples

fake = gptr_fake_provider(list("a"))
runs = list(a = peter("one", model = fake, .run = FALSE),
            b = peter("two", model = fake, .run = FALSE))
gptr_wait(runs, timeout = 10)
#> gptr: thinking
#> gptr: thinking
#> gptr: done · 1 turn · 1.6k tokens · $0.0000
#> gptr: done · 1 turn · 1.6k tokens · $0.0000
vapply(runs, function(x) x$status, "")
#>      a      b 
#> "idle" "idle"