SettledContextEstimate class final
Memoized context estimate for the SETTLED part of a transcript.
The status line renders on every frame — including every keystroke while
the user types over a run. Keying the memo on the message list LENGTH
and the LAST message's identity (never on in-flight stream content)
makes each streamed delta cost one O(stream) estimateTokens instead
of a full O(context) re-scan: on a 200k-token transcript that is the
difference between ~50 whole-transcript scans per second and none.
The key deliberately survives list COPIES: AgentState.messages
hands out a fresh List.unmodifiable wrapper on every read, so a
whole-list identity key would miss on every single frame. Settled
messages are immutable once appended, so (length, last-instance)
changes exactly when the settled estimate can change: appends grow
the length, compaction/session switches replace the last instance.
Constructors
-
SettledContextEstimate({ContextUsageEstimate estimator(List<
Message> )?}) -
Creates a memo;
estimatoris injectable for tests.
Properties
- estimatorCalls → int
-
How many times the underlying estimator actually ran (test seam).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
settled(
List< Message> messages) → int - The token total of settledEstimate.
-
settledEstimate(
List< Message> messages) → ContextUsageEstimate -
Estimate for the settled
messages, recomputed only when the list length or the last message instance changed (appends, compaction, session switches). An in-place mutation that keeps both is deliberately NOT tracked — settled messages are immutable once appended. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited