From e2646ad2b0c28bd64ad4efd6b154f97f8a35e0ad Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Fri, 12 Jun 2026 00:43:55 +0900 Subject: feat(metrics): expose current context size to the frontend contextSize = the turn's FINAL step inputTokens+outputTokens (true context occupancy; NOT the aggregate usage, which sums per-step prompts and overcounts multi-step turns). Stamped on both the live done event (kernel) and persisted TurnMetrics (session-orchestrator); a client reads the latest turn's value. - @dispatch/wire 0.4.0->0.5.0: optional contextSize on TurnDoneEvent + TurnMetrics - @dispatch/transport-contract 0.5.0->0.6.0 (re-export only) - glossary: context size (reserve 'context window' for the model limit, later) - FE courier: frontend-context-size-handoff.md 881 vitest pass; tsc -b EXIT 0; biome clean. --- tasks.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tasks.md') diff --git a/tasks.md b/tasks.md index e756612..85a3e79 100644 --- a/tasks.md +++ b/tasks.md @@ -5,7 +5,7 @@ > Keep this lean and current; do not let it re-accrete a step-by-step changelog. ## Status (current) -`tsc -b` EXIT 0 · biome clean · **865 vitest + 135 bun = 1000 tests**. +`tsc -b` EXIT 0 · biome clean · **881 vitest + 135 bun = 1016 tests**. Built and verified live (full-fidelity: every feature is a manifest-loaded extension through the host): @@ -231,6 +231,26 @@ workspace root, working directory. finished it directly; also fixed a real design bug the agent missed: the manager read config statically instead of per-cwd (would have broken Roblox). +## Context size — current context-window usage (DONE) +User-gated decisions: term = **context size** (current usage; reserve "context window" for the +model's max LIMIT, a later feature); definition = the turn's **FINAL step `inputTokens + +outputTokens`** (NOT the aggregate `usage`, which sums per-step prompts and overcounts a +multi-step turn); delivery = a backend-computed field on BOTH the live `done` event and the +persisted `TurnMetrics`. +- [x] **Contract (orchestrator):** optional `contextSize?: number` added to `TurnDoneEvent` + + `TurnMetrics` in `@dispatch/wire` (`0.4.0→0.5.0`); `@dispatch/transport-contract` + `0.5.0→0.6.0` (re-exports both — no other change). Glossary: added **context size**. +- [x] **Wave (parallel, disjoint pkgs):** + - [x] **kernel** — `run-turn.ts` tracks the last step's `Usage`; `doneEvent()` stamps + `done.contextSize = lastStep.input + lastStep.output` (omitted when no usage). +3 tests. + - [x] **session-orchestrator** — `metrics.ts build()` stamps `TurnMetrics.contextSize` from + the final per-step metrics (same definition; equals the live value). +5 tests. +- [x] Verified: `tsc -b` EXIT 0, biome clean, 881 vitest pass; both owners stayed in-lane. + `conversation-store` (JSON passthrough) + `transport-http` (forwards/serves) unchanged. +- [x] **FE courier handoff:** `frontend-context-size-handoff.md` (user couriers to + `../dispatch-web`). Not yet exercised end-to-end against a live LLM (unit tests cover both + producers); optional live-verify deferred. + ## Open items - **`prefix.fingerprint` / `warm|real` cache-bust attributes (deferred):** decoupled from dedup by the content-addressed decision; also gated on cache-warming being -- cgit v1.2.3