Skip to content

Add per-session Monitor telemetry - #8

Merged
merefield merged 5 commits into
mainfrom
agent/per-session-monitor
Aug 12, 2026
Merged

merefield merged 5 commits into
mainfrom
agent/per-session-monitor

Conversation

@merefield

@merefield merefield commented Aug 12, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • split the Monitor dashboard into one responsive metrics-and-graph row per independent local Codex root session
  • recursively aggregate explicitly linked spawned agents into their root session while keeping unlinked internal activity in an unattributed row
  • synchronize 30-second graph sampling across sessions after a fresh telemetry read, with accurate partial intervals for sessions detected mid-window
  • record account quota windows at Monitor Start, track their observed percentage-point movement, and show each session's exact local-token share plus an explicitly labelled estimated quota impact
  • add compact, content-free response telemetry to each session row: model-call count and recency, latest/peak time to first token, and latest/peak output tokens
  • add Page Up/Page Down and mouse-wheel navigation when the terminal cannot display every session row
  • document session grouping, inherited history, sampling, response telemetry, quota attribution, and navigation behavior
  • bump the maintained minor version from 0.3.0 to 0.4.0

Why

The previous Monitor combined all local Codex activity into one total. That made simultaneous CLI sessions indistinguishable and could not show whether usage originated in a root interaction or its spawned agents. It also showed throughput without the response cadence, responsiveness, or output size behind it.

Correctness and hardening

Codex child rollouts may include inherited parent telemetry. Current rollouts expose an ordinal ownership boundary; older rollouts are separated using the child session timestamp. Inherited cumulative totals establish a baseline without being reported as new usage. Graph buckets wait for a boundary fetch rather than closing from stale telemetry, and late-discovered roots use their own observation lifetime for rates and first-bucket duration.

Response telemetry is derived only from appended local rollout records after Monitor Start. CALLS means upstream model-response cycles, not complete user turns; a tool-using turn may make several calls. Output size comes from the provider-reported last_token_usage, and TTFT comes from the persisted completed-turn timing. Records that omit either measurement still count as activity but display that individual reading as N/A, preventing a stale earlier value from masquerading as the latest one. Retained final-response text is neither decoded nor stored.

Quota attribution is hardened as follows:

  • quota is read before the local baseline at Start and after the final local reading at Stop, so the account observation brackets the measured local interval
  • failed, missing, partial, or reset-crossing quota data suppresses the per-session number instead of reusing a stale value
  • the UI labels attribution EST LOCAL-ONLY; concurrent account activity outside the visible local sessions is explicitly documented as a contaminating factor
  • whole-number source granularity is preserved: apportioned values use whole points or <1PP, and an unchanged integer reading says NO INTEGER Δ

User impact

Monitor users can now compare independent Codex sessions side by side, see the number of linked agents contributing to each root, identify which session produced the largest share of locally observed activity, and navigate all rows responsively on shorter terminals.

Each row also gives a compact sense of model activity and responsiveness without crowding out the graph: how many response cycles occurred, how recently, the latest and slowest TTFT, and the latest and largest output.

The per-session quota value is deliberately labelled EST: Codex does not expose direct session-to-quota attribution, so Codexometer apportions observed percentage-point movement by local token share. Estimates are marked partial for incomplete baselines and suppressed across detected resets.

Validation

  • go test ./...
  • go test -race -cover ./...
  • go vet ./...
  • rebuilt and format-checked the local binary plus Darwin, Linux, and Windows binaries for amd64 and arm64
  • confirmed the local binary reports codexometer v0.4.0

@merefield
merefield marked this pull request as ready for review August 12, 2026 11:18
@merefield
merefield requested a lite review from Copilot August 12, 2026 11:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands Codexometer’s Monitor to report per-root-session local telemetry (including explicitly linked spawned agents), adds compact response-cycle stats (calls/TTFT/output), tracks account quota windows with a labeled local-only attribution estimate, and updates documentation and versioning to v0.4.0.

Changes:

  • Reworked Monitor rendering to show one metrics+graph row per root session, with paging via Page Up/Page Down and mouse wheel.
  • Added quota window snapshotting/sync and per-session “EST LOCAL-ONLY” attribution based on local token share.
  • Extended local rollout parsing to group spawned descendants, avoid inherited-history double counting, and extract output-token + TTFT pulses.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents per-session grouping, response telemetry, quota attribution, navigation, and bumps referenced version to v0.4.0.
main.go Updates demo fetcher to emit per-session model-call + TTFT telemetry for Monitor.
main_test.go Updates version output expectation to v0.4.0.
internal/version/version.go Bumps maintained fallback version to 0.4.0.
internal/version/version_test.go Updates fallback version test to 0.4.0.
internal/ui/view_test.go Updates Monitor header expectation (“MONITOR READOUT”).
internal/ui/monitor.go Implements per-session Monitor rendering, response stats formatting, quota readout rendering, and dynamic bucket span labeling.
internal/ui/monitor_test.go Adds/updates tests for per-root sampling, response telemetry, quota attribution/reset behavior, and row paging/navigation.
internal/ui/model.go Adds Monitor state for per-session data, boundary sampling, quota window tracking, and new input handling for paging.
internal/codex/live_usage.go Adds session grouping (root + spawned agents), inherited-history boundary handling, and extraction of output-token + TTFT pulses.
internal/codex/live_usage_test.go Adds coverage for pulse extraction, grouping, inherited-history handling, and source-shape parsing.
Suppressed comments (1)

internal/codex/live_usage.go:410

  • Same issue for cursor.turnTimings: allocating and copying on every overflow adds avoidable overhead once the history reaches telemetryHistoryMax. A simple reslice keeps the newest entries without per-event allocations.
				if len(cursor.turnTimings) > telemetryHistoryMax {
					cursor.turnTimings = append([]LiveTurnTiming(nil), cursor.turnTimings[len(cursor.turnTimings)-telemetryHistoryMax:]...)
				}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/ui/model.go Resolved
Comment thread internal/codex/live_usage.go Resolved
@merefield
merefield merged commit 5be8d68 into main Aug 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants