Class ContextTracker
java.lang.Object
io.agentscope.extensions.aistio.model.ContextTracker
Incrementally maintains one session's effective-context view and its
contextHash from the
Level-2 event stream.
A compaction event resets the view down to a single summary message, matching what the
framework itself will send to the model afterwards.
This is an approximation rebuilt from events; the authoritative context still comes from
FrameworkAdapter.extractContext(). Its value is that it is always available in memory, so
Level-1 snapshots and change detection cost nothing.
Not thread-safe: the bridge serializes access under its own lock.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintintintgetModel()intintbooleanbooleanonEvent(SessionEvent event) Consumes one event.Prefer the last effective prompt; fall back to the builder base.voidsetContextUsedTokens(int contextUsedTokens) Tokens in the live effective context; used for pressure = used / maxTokens.voidsetEffectiveSystemPrompt(String effectiveSystemPrompt) Last middleware-composed system prompt observed for this session (may differ from the builder base prompt).voidsetMaxTokens(int maxTokens) Context window size of the model behind this session, used for pressure ratios.voidModel name from agent config, when known.voidsetSystemPrompt(String systemPrompt) voidsetTools(List<ContextSnapshot.ToolInfo> tools) snapshot()
-
Constructor Details
-
ContextTracker
-
-
Method Details
-
getSessionId
-
getContextHash
-
getMessageCount
public int getMessageCount() -
getEffectiveMessageCount
public int getEffectiveMessageCount() -
getTokensIn
public int getTokensIn() -
getTokensOut
public int getTokensOut() -
getContextUsedTokens
public int getContextUsedTokens() -
setContextUsedTokens
public void setContextUsedTokens(int contextUsedTokens) Tokens in the live effective context; used for pressure = used / maxTokens. -
isCompacted
public boolean isCompacted() -
getMaxTokens
public int getMaxTokens() -
setMaxTokens
public void setMaxTokens(int maxTokens) Context window size of the model behind this session, used for pressure ratios. -
getModel
-
setModel
Model name from agent config, when known. -
setSystemPrompt
-
setEffectiveSystemPrompt
Last middleware-composed system prompt observed for this session (may differ from the builder base prompt). Empty until the first turn completesonSystemPrompt. -
getEffectiveSystemPrompt
-
resolveSystemPrompt
Prefer the last effective prompt; fall back to the builder base. -
setTools
-
onEvent
Consumes one event.- Returns:
truewhen the context hash changed, which is what gates Level-4 pushes
-
snapshot
-