Overview
dsh-session-stats
Source-level overviewFunction plugin registering the sessionStats projection unit: whole-log conversation figures — turn/step counts and the LLM, tool, first-token, and decode wall times — folded from step boundaries, stream chunks, tool pairs, and assembled assistant messages, and served through the session-projection seam (registry snapshot, change feed, and every projection carrier: history tail page, session/projection push frames, session list rows). Clients render full-session figures that paging and compaction cannot change; the reference consumer is the web chat stats strip, whose window fold mirrors these field names as its no-unit fallback.Collapse technical overview
sessionStats projection unit: whole-log conversation figures — turn/step counts and the LLM, tool, first-token, and decode wall times — folded from step boundaries, stream chunks, tool pairs, and assembled assistant messages, and served through the session-projection seam (registry snapshot, change feed, and every projection carrier: history tail page, session/projection push frames, session list rows). Clients render full-session figures that paging and compaction cannot change; the reference consumer is the web chat stats strip, whose window fold mirrors these field names as its no-unit fallback.This is an atomic module already shipped with Harness, not a standalone profile layer.
Capabilities
What it contributes
README / EN
Package documentation
@deepseek-ai/dsh-session-stats
English | 中文
Function plugin registering the sessionStats projection unit: whole-log conversation figures — turn/step counts and the LLM, tool, first-token, and decode wall times — folded from step boundaries, stream chunks, tool pairs, and assembled assistant messages, and served through the session-projection seam (registry snapshot, change feed, and every projection carrier: history tail page, session/projection push frames, session list rows). Clients render full-session figures that paging and compaction cannot change; the reference consumer is the web chat stats strip, whose window fold mirrors these field names as its no-unit fallback.
Fold semantics
stepscountsstep/endevents. The agent loop appends exactly one per entered step, in afinally, so completed, failed, cancelled, and max-tokens steps all count. Counting assembled assistant messages instead would overcount max-tokens usage-host messages (empty content, excluded from the surface) and undercount cancelled steps (aborted before the message assembles).turnscounts distinct turns carrying at least one closed step; rejected or empty turns (closed with no step) are uncounted. Turn numbers are host-assigned and monotonic per session, so the fold keeps only the last counted turn.llmMssumsstep/start→assistant/messageper step that assembled a message (retry waits inside the step are model time, as in the window fold).ttftMs/ttftStepssum and countstep/start→ first non-empty delta chunk; the first attempt's boundary survives an in-stepllm/retry(windowresetForRetryparity).decodeMs/decodeTokenssum first token → assembled message and the provider-reported output tokens, only over steps carrying both.toolMssumstool/call→tool/resultpairs matched by callId; unresolved calls are dropped atturn/end(results land within their turn).- Every field is 0 until its first contributing event. A composed registry always serves the key, so clients read the value, never key presence.
Composition
- id: session-stats
name: '@deepseek-ai/dsh-session-stats'
Injects sessionProjections — the plugin's whole purpose; in assemblies without the registry the fiber stays pending and nothing registers.
Model Experience
None, as the plugin only computes a client-facing read model of already-logged session events and touches no prompt, message, schema, stream, or tool result.
KV Cache effect
None; the plugin never assembles or sends provider requests.
Known Limitations and Deferred Work
- Steps count work attempted, not visible output — a step that failed before producing any visible content still closed with
step/endand counts; a step interrupted by a crash counts after the session reloads, when crash recovery appends its syntheticstep/end(interruptedTurnClosersin dsh-session). - A cancelled step is counted but untimed — no assistant message assembles, so its partial stream time enters no wall-time figure, matching the window fold's untimed interrupted node; a max-tokens usage-host message conversely contributes model time the surface does not show.
- Counts are log-scoped, not surface-scoped — steps whose messages were later compacted away stay counted; the figures describe the whole session, not the current model-visible surface.
- Mounted only in the web-app bundle — other assemblies serve no
sessionStatskey, and their consumers fall back to window-scoped counting (the web stats strip's fallback path).
LIMITATIONS
Known limitations
- **Steps count work attempted, not visible output** — a step that failed before producing any visible content still closed with `step/end` and counts; a step interrupted by a crash counts after the session reloads, when crash recovery appends its synthetic `step/end` (`interruptedTurnClosers` in dsh-session). - **A cancelled step is counted but untimed** — no assistant message assembles, so its partial stream time enters no wall-time figure, matching the window fold's untimed interrupted node; a max-tokens usage-host message conversely contributes model time the surface does not show. - **Counts are log-scoped, not surface-scoped** — steps whose messages were later compacted away stay counted; the figures describe the whole session, not the current model-visible surface. - **Mounted only in the web-app bundle** — other assemblies serve no `sessionStats` key, and their consumers fall back to window-scoped counting (the web stats strip's fallback path).
