Repository navigation
Description
Problem
agentop observe now shows the cost of each session, so it is easy to see which tasks cost the most. Answering "where did my tokens go this month?" still means adding up sessions by hand, because nothing groups them by the project they ran in. The working directory is the natural key for that: one repo or checkout is usually one project.
Today the directory only appears by accident. The Claude Code title harvest (~/.cortex/session-metadata.json) falls back to the working directory as a session's title when the transcript has no model-generated one, so some rows show a path in TITLE and others don't. Codex, Bob, OpenCode and Pi sessions show no directory at all.
Proposal
Record each session's working directory and let the viewer group and total by it:
- A
DIR(orPROJECT) column in the Sessions pane, separate fromTITLE. - A way to group or scope by directory, like the Agents pane does by agent: one row per directory with
SESSIONS,LAST SEENandCOST <window>, and↵scopes sessions, usage and the$band to it. - The same breakdown in
agentop cost, so a monthly total per directory can be scripted.
Open questions:
- Where does the directory come from per agent? Claude Code records
cwdin its transcripts (the title harvest already reads them). Codex records it in its session files. For other agents it may need the process's cwd, looked up from the pid the proxy already attributes calls to. - Group by the exact path, or by repository root (so
repo/andrepo/sub/count together)? Worktrees under.claude/worktrees/probably belong with their repo. - A session whose directory changes partway through (
cdin a shell agent): first directory, or last? - Is the path sensitive enough to keep out of the session API by default? It is already in
session-metadata.jsonfor Claude Code.
Context
Requested in #cortex-community by @vinodmut (2026-11-09), who uses the per-session cost to compare models and agents (Codex vs Claude Code) and to account for monthly token use.
Where it lives
cmd/agentop/tui/sessions_pane.go,session_metadata.go,sessions_title.gocmd/agentop/cmd_experimental.go(read-claude-sessionsharvest)- The Agents pane, as the model for a per-directory breakdown
cmd/agentop/README.md: the Sessions pane section and the column table
Assisted-By: Claude (Anthropic AI) [email protected]
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
mrsabath commentedon Nov 9, 2026
Directory is a good grouping key, and this open question turns out to be the visible edge of
a second problem worth folding in:
From an offline analysis of a 30-day local archive (66 session directories, 29,606 events):
a single session id can span weeks of unrelated work. The id
defaultrecurs across theentire 2026-10-15 -> 2026-11-06 range in one archive directory, carrying 152 events from
many separate working periods. So "66 sessions" is a directory count, not 66 units of work,
and any per-session total — cost, tokens, latency — silently averages across unrelated
tasks.
That means a
DIRcolumn inherits the problem rather than solving it: if one session idaccumulates work from several directories over three weeks, neither "first" nor "last" is
right, and the monthly per-directory total this issue wants will be wrong in whichever
direction the tie-break goes.
The archive already has enough to fix this.
Seq's own documentation notes thenumbering is unique per incarnation and that whole-session eviction restarts it at 1, and
segments are written per working period with a
lastWritetimestamp. A new segment after along idle gap is a natural incarnation boundary — one of these sessions has 34 segments
spanning three weeks, each one a distinct sitting. Exposing an incarnation/epoch id in
session.jsonwould give both this issue and per-session analytics a stable key for "onecontiguous working period," and would make the first-vs-last question mostly moot: an
incarnation rarely changes directory.
Not asking to widen this issue — the directory column is useful on its own and shipping it
should not wait. Just flagging that the grouping will be more trustworthy with an
incarnation key than without one, and that the tie-break decision can be deferred if the
unit being grouped is a sitting rather than a session id.
(Caveat: one developer's archive, Claude-Code-dominated, so the
default-id reuse patternmay be specific to how these sessions were started.)
Feat: Walk the archive into content-free records over GET /v1/export (#…