agent-session-kit 0.6.0
Every session can now say how full its context window is — measured where
the harness records it (Codex, Grok Build), derived from usage where it
does not (Claude Code) — plus Codex's rate limits as a quota, and a
compaction count. eventSchemaVersion is 3: hosts re-seed stored snapshots.
Added
- Per-session context-window usage — the
/contextgauge.
SessionSnapshot.contextUsageis aContextUsage:used,window,
cached, the timestamp it was read at, and whether the window was
measuredorderived. One definition ofusedacross every harness —
the tokens that were in the model's context when it was last called, cached
prefix included, the reply just generated excluded, because that lands in
the next call's input. Folded bySessionStateReducerfrom a new
AgentEventKind.contextUsage(used:window:cached:source:), which is a
level and never summed;usageremains the delta it always was. A reading
stamped before the one on record is dropped, so a gauge cannot flicker
backwards when a file-mtime-stamped reading is merged behind a log line. SessionSnapshot.compactions, folded fromAgentEventKind.compaction.
One compaction is normal; four in an afternoon is the shape of a session
that keeps forgetting what it was told. A compaction does not zero
contextUsage— the window really did empty, but by how much is not on
disk, and the next model call says so within a step.ModelContextWindows, the model-id → window lookup for the stores that
record the token counts but not the size of the window they filled. Prefixes,
a marker rule for the long-context variants (claude-…[1m]), a documented
default of 200,000 for the Claude family, andnil— not a plausible guess —
for a model nothing matches. Hosts pass their own with
ModelContextWindows.standard.overriding(…), accepted byClaudeLiveAdapter
andClaudeCoworkLiveAdapter.SessionSnapshot.quotaandAgentEventKind.quota(usedPercent:resetsAt:plan:),
from Codex'srate_limits. Read off the rollout; nothing here asks a network
what a limit is. Only theprimarywindow becomes an event — a row with two
percentages and no room to label them is worse than one showing the limit a
person is about to hit — andresets_in_seconds, which older rollouts write
instead ofresets_at, is resolved against the record's clock so a
replayed rollout does not claim its limits reset an hour from now.GrokSignalsReader, which turnssignals.json'scontextTokensUsedand
contextWindowTokensinto a measured reading. Not a tailer: the file is
rewritten in place, so there is no cursor to advance and no history to
replay. It stats on every poll and parses only when the stamp moved, and
rides along insideGrokSessionTailerrather than earning a watch of its
own —signals.jsonstays out ofmightBeSessionFileand out of the
source's auxiliary paths, because Grok rewrites it many times a minute and a
host waking on each rewrite is the storm that rule exists to prevent.CodexJSON.double, for the fractional percentages Codex writes.
Changed
AgentSessionLive.eventSchemaVersionis 3. Two cases were added to
AgentEventKindand three fields toSessionSnapshot, both of which are
encoded structurally, so a host that persisted rows re-seeds rather than
decoding a model it no longer speaks.