% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/streaming.R
\name{scan_stream}
\alias{scan_stream}
\title{Scan streamed output chunks with rolling context}
\usage{
scan_stream(
  chunks,
  policy = "enterprise_default",
  reviewer = NULL,
  checks = "rules",
  chunk_size = 1000L,
  overlap = 200L,
  on_block = c("stop", "return"),
  redaction = NULL,
  scanners = scanner_options(),
  show_tokens = FALSE
)
}
\arguments{
\item{chunks}{Character vector of streamed text chunks, or one long string.}

\item{policy}{A \code{shieldr_policy} or built-in policy name.}

\item{reviewer}{Optional reviewer function or object with \verb{$chat()}.}

\item{checks}{One of \code{"rules"}, \code{"nlp"}, \code{"llm"}, or \code{"both"}.}

\item{chunk_size}{Maximum size used to split a single long string.}

\item{overlap}{Number of trailing characters from prior output to include
when scanning the next chunk.}

\item{on_block}{One of \code{"stop"} or \code{"return"}.}

\item{redaction}{Optional redaction strategy from \code{\link[=redaction_strategy]{redaction_strategy()}}.}

\item{scanners}{Optional scanner configuration from \code{\link[=scanner_options]{scanner_options()}}.}

\item{show_tokens}{Whether to attach token counts when \code{ellmer} is available.}
}
\value{
A \code{shieldr_stream_result} list with \code{action}, \code{text}, and \code{reports}.
}
\description{
\code{scan_stream()} scans character chunks as they arrive from a streaming model
API. Each scan uses the current chunk plus a configurable overlap from the
previous text so rules can catch phrases split across chunk boundaries.
}
\details{
This helper is intentionally transport-agnostic: pass the text chunks you
receive from an SDK, callback, or websocket handler. It returns per-window
reports and a combined action. If \code{on_block = "stop"}, the function aborts
as soon as a window resolves to \code{block}; use \code{on_block = "return"} when you
want a full report object instead.

\code{chunk_size} is used only when \code{chunks} is a single long string. Character
vectors with more than one element are treated as already chunked.
}
\examples{
scan_stream(
  c("I will now ", "delete the records."),
  on_block = "return"
)
}
