Skip to content

Class: ContextWindowTracker

Makaio Framework


Makaio Framework / services-core / ContextWindowTracker

Defined in: ../../../packages/services/core/src/session/context-window/context-window-tracker.ts:27

Tracks context window state per session, aggregating across agents.

Subscribes to AgentSubjects.contextWindow.updated and maintains per-session state using “worst agent” aggregation strategy.

const tracker = new ContextWindowTracker(MakaioBus);
tracker.start();
// Later, query session state
const state = tracker.getSessionState('session-123');
if (state?.level === 'critical') {
// Suggest compression
}
// Cleanup on shutdown
tracker.stop();

new ContextWindowTracker(bus, config?): ContextWindowTracker

Defined in: ../../../packages/services/core/src/session/context-window/context-window-tracker.ts:33

IMakaioBus

ContextWindowTrackerConfig

ContextWindowTracker

clearSession(sessionId): void

Defined in: ../../../packages/services/core/src/session/context-window/context-window-tracker.ts:102

Clear state for a specific session (e.g., on session close). Removes both the session state and all agent states for that session.

string

The session to clear

void


getSessionState(sessionId): SessionContextWindowState | undefined

Defined in: ../../../packages/services/core/src/session/context-window/context-window-tracker.ts:93

Get aggregated context state for a session.

State persists until explicitly cleared via clearSession(). Clear is called by MakaioSessionService on:

  • session.close (session closed)
  • session.compressed (context compression)

Even if we haven’t heard from agents recently, the context window is still full - the state remains valid.

string

The session to get state for

SessionContextWindowState | undefined

The aggregated context window state, or undefined if no data


start(): void

Defined in: ../../../packages/services/core/src/session/context-window/context-window-tracker.ts:44

Start tracking context window updates. Idempotent - calling multiple times is safe.

void


stop(): void

Defined in: ../../../packages/services/core/src/session/context-window/context-window-tracker.ts:73

Stop tracking and clear all state.

void