Skip to content

agent.configure_compaction

agent.configure_compaction(settings)

Set the context-compaction policy. The last call wins.

Parameters

  • settings: {mode: string?, grow_by: number | string?, compact_at: number | string?, keep_recent: number | string?, min_gain: number | string?, min_turns: number?, enable_llm_summary: boolean?, summarizer_model: string?, summarizer_chunk: number | string?, summarizer_concurrency: number?, summarizer_timeout: string?}
    • mode'auto' (default) or 'off'.
    • grow_by — Sawtooth cadence: compact after this much new context accrues since the last compaction.
    • compact_at — Hard safety: also compact once live context reaches this, regardless of growth or the other gates.
    • keep_recent — The recent-conversation budget always kept live.
    • min_gain — Skip an automatic compaction that would drop less than this.
    • min_turns — The minimum number of turns between automatic compactions.
    • enable_llm_summary — Whether the supplemental model-written Observations summary runs (enable_llm_summary). Defaults to true; false yields deterministic-only compaction while leaving auto-compaction on.
    • summarizer_model — The summarizer model as [provider/]model[@effort]; omitted components inherit the session's provider/model/effort. Omitting the field entirely uses the session's own model as the summarizer.
    • summarizer_chunk — The per-chunk input budget for the map step, as a token count or window fraction. Overrides the window-derived budget and is the explicit constraint for a local provider with no advertised window.
    • summarizer_concurrency — The maximum number of concurrent map calls (default 1). 0 is rejected.
    • summarizer_timeout — The wall-clock bound on the whole summary pass, as a human duration string (e.g. "30s", "2m"). Defaults to 120s.