Retain a bounded history of applied live steering
Source:R/graphics-plots.R, R/graphics-timeline.R
llm_timeline.RdAppends the next on_state audit, dropping oldest complete states to respect the explicit working budget and retention window. No activations or model handles are retained. The table records sampled states, not committed text.
Usage
# S3 method for class 'relm_timeline'
plot(x, ...)
llm_timeline(state, history = NULL, max_states = 256L, max_bytes = 8 * 1024^2)Arguments
- x
A relm_timeline returned by llm_timeline(), optionally row-filtered to at most 16 intervention IDs for rendering.
- ...
Named main, cex or col (one or three colors).
- state
A single observation delivered to
on_state.- history
NULL to start at state 1, or the previous returned history.
- max_states
Number of newest whole states to retain, from 1 through 1024.
- max_bytes
Working materialization budget, whole bytes from 64 KiB to 64 MiB.
Value
The plot method returns the history invisibly.
A relm_timeline data frame containing step columns followed by
intervention, layer and coef, plus explicit retained/dropped ranges.
Details
Inside a callback assign history <- llm_timeline(state, history), then
explicitly return NULL or the intended steering reply. Do not return this
history as a callback reply. A change requested at state k applies to the
next decode, and setting a coefficient to zero does not clear KV history.
The helper validates consistency of editable R records, not their origin.
Examples
source(system.file("examples", "graphics-states.R", package = "relm"), local = TRUE)
history <- llm_timeline(reference, max_states = 8)
next_state <- example_state(2L, coefficient = 0, revision = 1L, after = 1L)
history <- llm_timeline(next_state, history, max_states = 8)
history[, c("state_id", "coef", "applied_after_state")]
#> state_id coef applied_after_state
#> 1 1 0.25 0
#> 2 2 0.00 1
figure <- tempfile(fileext = ".pdf")
grDevices::pdf(figure, width = 10, height = 7)
tryCatch(plot(history), finally = grDevices::dev.off())
unlink(figure)