AutoCompactorFactory class
Hosts plug in their own AutoCompactorSources, hooks, and settings; the factory wires the smol/main summarizers with the configured CompactionPrompts and optional memory hook, then runs the loop.
When force is true the compactor skips shouldCompact — used by
manual /compact so the user can force a compaction regardless of
the auto-trigger threshold.
Constructors
-
AutoCompactorFactory({required Session session, required AgentState state, required int window, required CompactionSettings settings, required AutoCompactorSources sources, required AutoCompactorHooks hooks, CompactionPrompts prompts = defaultCompactionPrompts, Future<
void> memoryExtractionHook(String summarizedText)?, int maxPasses = 8, int maxAttempts = 3, Duration baseBackoff = const Duration(seconds: 1), bool force = false, Duration attemptBudget = const Duration(seconds: 300), Duration totalBudget = const Duration(minutes: 15), CompactionEngine engine = CompactionEngine.structured, CancelToken? runToken}) -
const
Properties
- attemptBudget → Duration
-
Per-attempt wall-clock budget, forwarded to the built AutoCompactor.
final
- baseBackoff → Duration
-
final
- engine → CompactionEngine
-
Which engine compactions use (issue #148 D8):
CompactionEngine.structured (the default since issue #287) or
CompactionEngine.classic (the legacy 1.0 rollback — lossy prefix
summary; the structured engine also falls back to it when it cannot
get the context under the window).
final
- force → bool
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hooks → AutoCompactorHooks
-
final
- maxAttempts → int
-
final
- maxPasses → int
-
final
-
memoryExtractionHook
→ Future<
void> Function(String summarizedText)? -
final
- prompts → CompactionPrompts
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- runToken → CancelToken?
-
The owning run's cancellation token (issue #1085), forwarded to the
built AutoCompactor and linked to the structured engine's budget
token: a user abort during a mid-run relief cancels the in-flight
compaction on BOTH engines.
null= standalone compaction.final - session → Session
-
final
- settings → CompactionSettings
-
final
- sources → AutoCompactorSources
-
final
- state → AgentState
-
final
- totalBudget → Duration
-
Whole-run wall-clock budget, forwarded to the built AutoCompactor.
Defaults to 15 min (
attemptBudget × maxAttempts); see the AutoCompactor.totalBudget doc for why it must stay in step with the per-attempt budget.final - window → int
-
final
Methods
-
build(
) → AutoCompactor - Builds the AutoCompactor from the factory's configuration without starting it. Useful for tests or for hosts that want to wrap the loop in extra logging.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
) → Future< bool> - Builds the AutoCompactor and runs it. Hosts that want to inspect the compactor before starting (e.g. for logging) can use build instead.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited