Agent$compact() and $last_compaction() return this read-only S7 value.
$ and S7::prop() read its properties. S7::props() returns a plain list
for explicit reporting; nested usage must also be projected for JSON.
Original provider conditions in attempts retain their identity and any
reference semantics. Reporting code should select safe evidence fields
rather than serialize arbitrary conditions or provider objects.
Usage
DeputyCompaction(
method,
automatic,
turns_compacted,
turns_kept,
estimated_tokens = NULL,
usage = AgentUsage(),
summary = NULL,
attempts = list(),
run_id = NULL
)Arguments
- method
Outcome:
"none","cancelled","custom","hook","llm", or"text".- automatic
Whether the run triggered compaction automatically.
- turns_compacted
Number of turns removed from the active context.
- turns_kept
Number of retained turns.
- estimated_tokens
Estimated context size before compaction, or
NULLwhen unavailable.- usage
An AgentUsage value for summary generation, including failed attempts. Unknown provider costs remain unknown.
- summary
Installed summary text, or
NULLwhen no replacement occurred.- attempts
List of summary attempt records containing
fallback_index,provider,model,usage, and the originalcondition(orNULL).- run_id
Governed run identifier, or
NULLfor manual compaction.
Examples
outcome <- DeputyCompaction("custom", FALSE, 4, 2, summary = "Earlier work")
outcome$turns_compacted
#> [1] 4
S7::props(outcome$usage)
#> $requests
#> [1] 0
#>
#> $tool_calls
#> [1] 0
#>
#> $input_tokens
#> [1] 0
#>
#> $output_tokens
#> [1] 0
#>
#> $cached_tokens
#> [1] 0
#>
#> $total_tokens
#> [1] 0
#>
#> $cost_usd
#> [1] 0
#>