goose_stream: Stream Response from Goose

View source: R/streaming.R

goose_streamR Documentation

Stream Response from Goose

Description

Execute a query with streaming response handling

Usage

goose_stream(
  query,
  callback = NULL,
  error_callback = NULL,
  complete_callback = NULL,
  session_id = NULL,
  max_time = getOption("goose.stream_timeout", Inf),
  idle_timeout = getOption("goose.stream_idle_timeout", Inf)
)

Arguments

query

The query to send to Goose

callback

Function to call with each chunk (default: cat)

error_callback

Function to call on error

complete_callback

Function to call on completion

session_id

Optional session ID for context

max_time

Numeric, maximum runtime in seconds for the stream (default uses getOption('goose.stream_timeout', Inf)). Set to Inf for no limit.

idle_timeout

Numeric, maximum time in seconds without receiving any output before aborting the stream (default uses getOption('goose.stream_idle_timeout', Inf)). Set to Inf for no limit.

Value

Invisible NULL (results handled via callbacks)

Examples

## Not run: 
# Simple streaming with default output
goose_stream("Explain R functions")

# Custom callback for processing chunks
goose_stream("Write a function", callback = function(chunk) {
  message("Received: ", nchar(chunk), " characters")
  cat(chunk)
})

## End(Not run)

gooseR documentation built on Feb. 6, 2026, 5:07 p.m.