Skip to content

Commit 14ae284

Browse files
feat(budget-report): add weekly spend digest command (#115)
Aggregates cost across sessions for a configurable time window. - Total spend, session count, avg cost with week-over-week delta - Top 5 most expensive sessions - Cost breakdown by tool (estimated from tool call frequency) - Watchdog savings: reads post-mortem files to show budget-ceiling value - --format text|markdown|json; markdown suitable for Slack/email - --since / --until accept ISO dates or durations (7d, 24h) - 31 tests covering empty store, windowing, watchdog detection, all formats Co-authored-by: Ona <no-reply@ona.com>
1 parent e4ba406 commit 14ae284

5 files changed

Lines changed: 846 additions & 1 deletion

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,48 @@ Supported models: `sonnet` (default), `opus`, `haiku`, `gpt4`, `gpt4o`. Token co
303303

304304
See [examples/session_analysis.md](examples/session_analysis.md) for a full walkthrough combining `import`, `explain`, and `cost`.
305305

306+
### Weekly spend digest (budget-report)
307+
308+
Aggregate cost across sessions for a configurable time window. Shows total spend, top sessions, cost by tool, and savings from watchdog budget ceilings.
309+
310+
```bash
311+
# Last 7 days (default)
312+
agent-strace budget-report
313+
314+
# Custom window
315+
agent-strace budget-report --since 2026-05-01 --until 2026-05-23
316+
317+
# Markdown output (paste into Slack or email)
318+
agent-strace budget-report --format markdown
319+
320+
# Machine-readable JSON
321+
agent-strace budget-report --format json
322+
```
323+
324+
Example output:
325+
326+
```
327+
Budget Report — May 16 to May 23, 2026
328+
329+
Total spend: $47.23 (↑ 12% vs prior period)
330+
Sessions: 34 (↑ 3 vs prior period)
331+
Avg cost/session: $1.39
332+
333+
Top 5 most expensive sessions:
334+
1. a84664242afa $8.43 refactor-auth 2026-05-21
335+
2. bf1207728ee6 $6.21 add-test-coverage 2026-05-22
336+
3. c91ab3312fde $4.87 fix-login-bug ⚠ watchdog 2026-05-20
337+
338+
Cost by tool (estimated):
339+
Bash $18.43 (39%)
340+
Read $12.11 (26%)
341+
Write $9.87 (21%)
342+
343+
Sessions terminated by watchdog: 3 ($14.21 saved by budget ceiling)
344+
```
345+
346+
Week-over-week delta is shown when prior-period data exists. The `--format markdown` output is designed to paste directly into Slack without editing.
347+
306348
### Static behaviour analysis (lint)
307349

308350
Analyse a session for known bad patterns — tool loops, reasoning spirals, budget proximity, context saturation, redundant reads, error-retry loops, and sessions that produced no output.

src/agent_trace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""agent-trace: strace for AI agents."""
22

3-
__version__ = "0.47.0"
3+
__version__ = "0.48.0"

0 commit comments

Comments
 (0)