Appends new to old then trims the list to at most n entries by
dropping the oldest. Use this instead of reducer_append() whenever the
channel feeds into an LLM call, to prevent the context window from growing
unboundedly and causing connection errors on long workflows.
Examples
r <- reducer_last_n(3L)
r(list("a", "b", "c"), "d") # drops "a", keeps "b", "c", "d"
#> [[1]]
#> [1] "b"
#>
#> [[2]]
#> [1] "c"
#>
#> [[3]]
#> [1] "d"
#>