Turns one parsed log record (the rec element of a llm_log_read() entry)
back into the config and messages an experiments row needs, so an archived
call can be re-issued live or matched against a config-driven call. The
provider-specific request body is canonicalized to provider-neutral
role/content turns and its generation parameters are recovered onto a
reconstructed llm_config().
Usage
llm_request_from_log(record, on_unsupported = c("error", "warn", "quiet"))Arguments
- record
A parsed log record: a list with at least
provider,model, andrequest(as found inllm_log_read(x)$records[[i]]$rec).- on_unsupported
What to do when the request body uses a shape this reconstructor does not cover, so the rebuilt messages would be empty or lack a turn's content (
complete = FALSE) – chiefly the OpenAI Responses API (input/instructions) and turns whose only content is a non-text block."error"(default) aborts;"warn"warns and returns the best-effort result;"quiet"returns it silently. Failing loudly is the default because a silently empty replay is worse than none.
Value
A list with config (an llm_config()), messages, complete,
and reissuable; NULL when the record carries no request body.
messages is a character vector of turns named by role, or, when a turn
carries non-text content, a list of turns whose attachments are kept only
as hashes. complete is TRUE when every turn was recovered with its
text and attachment hashes, which is what llm_request_hash() needs.
reissuable is TRUE when the rebuilt messages can also be sent again as
the original request: it is FALSE when the record has attachments (only
their hashes survive), tool calls or tool results (which are dropped), or a
role mapped with loss (such as developer to system).
