Skip to contents

Returns the small set of health numbers behind an agent_run: call counts, token totals, tool and blocked-event counts, summed call durations, and the study's manifest_hash. Token and outcome figures are read through LLMR::llm_usage() over the run's call-level rows, so they match the rest of the LLMR ecosystem.

Usage

# S3 method for class 'agent_run'
diagnostics(x, ...)

# S3 method for class 'Agent'
diagnostics(x, ...)

Arguments

x

An agent_run or an Agent. Convert other results with as_agent_run() first.

...

Unused.

Value

A one-row tibble with the following columns.

run_id, kind

Run identifier and kind.

n_calls, n_ok, n_failed, ok_rate

Stored call counts and success rate.

n_truncated, n_filtered

Counts of recorded finish reasons.

tokens_sent, tokens_received, tokens_total, reasoning_tokens

Sums of reported counts.

n_tool_calls

Rows in the tool view.

n_blocked

Events with status "blocked" or "stopped".

duration_s

Sum of available call durations in seconds.

manifest_hash

Study manifest hash, or NA when unavailable.

n_unknown_tokens

Calls whose sent, received, or total count is missing, as defined by LLMR::llm_usage().

Details

Token sums omit missing values, and n_unknown_tokens counts the calls, failed ones included, whose sent, received, or total count is missing (a total counts as known when both parts are), so a sum of zero with a positive n_unknown_tokens does not mean that nothing was used. Skipped rows and batch follow-on rows are not counted. When a level of the run cannot be read, the figures that depend on it are NA and a warning names the level and the reason; the other figures are still computed. A run with no calls has zero counts and sums. duration_s adds the recorded call durations rather than measuring elapsed time, and is NA when calls exist but none recorded a duration. An agent's own accounting (agent$usage()) can include tool-loop rounds, compactions, and embedding operations that have no call row, so the two need not agree.

Examples

a <- agent("Aria", LLMR::llm_config("groq", "openai/gpt-oss-20b"), quiet = TRUE)
diagnostics(a)   # no calls yet: zero counts and sums

if (FALSE) { # \dontrun{
a$chat("Hello")
diagnostics(a)
} # }