% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/conversation.R
\name{scan_conversation}
\alias{scan_conversation}
\title{Scan a conversation while preserving message roles}
\usage{
scan_conversation(
  messages,
  role_col = "role",
  content_col = NULL,
  policy = "enterprise_default",
  reviewer = NULL,
  checks = "rules",
  redaction = NULL,
  scanners = scanner_options(),
  show_tokens = FALSE
)
}
\arguments{
\item{messages}{A data frame with role and content columns, a list of message
objects with \code{role} and \code{content} fields, or a character vector of user
messages.}

\item{role_col}{Role column name for data-frame inputs.}

\item{content_col}{Content column name for data-frame inputs. If \code{NULL}, a
likely column such as \code{content}, \code{text}, or \code{message} is inferred.}

\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{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 list of \code{shieldr_report} objects, one per message.
}
\description{
\code{scan_conversation()} scans multi-message chat histories instead of a single
string. Each message is scanned with the role-appropriate surface and the
returned reports preserve message index and role in \code{metadata}.
}
\details{
Role handling:
\itemize{
\item \code{assistant} and \code{model} messages are scanned with \code{\link[=scan_output]{scan_output()}}.
\item \code{tool} and \code{function} messages are scanned with \code{\link[=scan_tool_output]{scan_tool_output()}}.
\item all other roles, including \code{system}, \code{developer}, and \code{user}, are scanned
with \code{\link[=scan_prompt]{scan_prompt()}}.
}

This function does not assemble or call a model. It is intended for
preflight checks, audits, and regression tests over stored chat histories.
}
\examples{
history <- data.frame(
  role = c("user", "assistant"),
  content = c("Summarize this.", "I will now delete the records."),
  stringsAsFactors = FALSE
)

scan_conversation(history)
}
