Writes a self-contained, hash-sealed archive of a run: the study
agent_manifest() (manifest.json), the transcript (transcript.csv), the
event / call / tool / state views, the per-call provenance (calls.jsonl,
the LLMR audit log copied verbatim when one was kept), any artifacts, a
drafted methods note (README-methods.md), and a hashes.sha256 manifest
over every file written. The archive is the supplementary material a paper
can ship: it carries the apparatus's identity and the calls' provenance, not
just the prose.
Usage
archive_agent_study(
run,
path,
include_messages = TRUE,
redact = NULL,
formats = c("csv", "jsonl", "rds")
)Arguments
- run
An object accepted by
as_agent_run()(an Agent, a conversation or preset result, a pipeline, an experiment, or anagent_run).- path
Directory to write into; created (recursively) if absent.
- include_messages
If
TRUE(default), write the transcript and the free-text columns of the tool and state tables. IfFALSE, those tables are still written but their free-text columns are blanked, keeping only structure, hashes, and metadata.- redact
Optional redaction applied to the free-text columns of the written transcript, tool, and state tables (
text,content,arguments,result,response_text) – never to hashes, and never to the verbatim audit log. Either afunction(text) -> text, or a character vector of regular expressions, each of which is replaced by"[REDACTED]". Redaction is applied to the on-disk copy after hashing, so the join invariant holds.- formats
Which optional formats to write, any of
"csv"(the tabular views),"jsonl"(events and calls; always written), and"rds"(theagent_runobject asrun.rds). Defaults to all three.
Value
Invisibly, an object of class agent_archive: a list with path,
files (relative paths written), manifest_hash, and n_calls. Print
lists what was written and confirms the seal.
Details
Hashes are identity, not outcome. The request_hash in calls.jsonl is
computed over the original request, so a call read back from the archive
still matches the same call issued live. Redaction therefore never touches a
hash, and when an LLMR audit log is present it is copied byte-for-byte rather
than reserialized.
Examples
if (FALSE) { # \dontrun{
a <- agent("Aria", LLMR::llm_config("groq", "openai/gpt-oss-20b"))
a$chat("Hello")
archive_agent_study(a, tempfile("study_"))
} # }