Skip to content

fix(money): count per-agent advisor artifacts in sessions scan - #13

Merged
rz1989s merged 2 commits into
mainfrom
fix/nested-advisor-scan
Oct 12, 2026
Merged

rz1989s merged 2 commits into
mainfrom
fix/nested-advisor-scan

Conversation

@rz1989s

@rz1989s rz1989s commented Oct 12, 2026

Copy link
Copy Markdown
Member

Problem

The money line under-counted advisor spend. scanMoney walked <repo>/<session-dir>/*.jsonl (main sessions, subagent <Agent>.jsonl, main __advisor.jsonl) but never entered the per-agent subtrees — <repo>/<session-dir>/<Agent>/__advisor.jsonl sits one level deeper and was silently skipped.

Advisor artifacts carry the standard usage.cost.total shape, so this was real spend missing from DAY/7DAY/30DAY.

Measured impact (live sessions tree, 2026-10-12)

Window Before Missed Undercount
DAY $6.87 (168.1M tok) +$1.91 (48.8M) 27.9%
7DAY $137.56 (3.64B) +$30.33 (861.9M) 22.0%
30DAY $1336.74 (12.2B) +$30.33 2.3%

157 files / ~6.8k entries affected. Depth 5 verified empty — no recursion needed, one extra level covers the tree completely.

Change

  • scanSessionDir(): walks the session dir itself plus per-agent subtrees one level deeper.
  • Test fixture pins nested-advisor coverage (windows, sub share, entry count).
  • README money bullet + /sl notify docs name both __advisor.jsonl levels; sub field comment now reads "subagent + advisor artifact share".

Verify

  • typecheck + 62/62 tests pass
  • Rescan of real tree after fix: DAY $8.93 (221.2M) · 7DAY $168.03 (4.5B) · 30DAY $1367.21 (13.1B) — deltas reconcile exactly with the measured gap
  • Global message-id dedupe unchanged (resumed/branched copies still count once)

The scan walked <repo>/<session-dir>/*.jsonl (main sessions, subagent
artifacts, main __advisor.jsonl) but stopped one level short of
<repo>/<session-dir>/<Agent>/__advisor.jsonl — advisor consults inside
subagent trees carry usage.cost.total like any other artifact and were
silently dropped. Measured on the live sessions tree: 157 files / ~6.8k
entries missed, ~22% under 7DAY, ~28% under DAY.

Scan now covers session-dir subtrees one level deeper; omp writes no
.jsonl below that (verified: zero files at depth 5), so no recursion.
@rz1989s
rz1989s merged commit d197bb1 into main Oct 12, 2026
@rz1989s
rz1989s deleted the fix/nested-advisor-scan branch October 12, 2026 04:09
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.

1 participant