Skip to content

feat: notifications cost cut + token-report fixes - #251

Merged
max-sixty merged 5 commits into
mainfrom
usage
Apr 11, 2026
Merged

max-sixty merged 5 commits into
mainfrom
usage

Conversation

@max-sixty

@max-sixty max-sixty commented Apr 11, 2026 •

Copy link
Copy Markdown
Owner

This branch bundles two cost-related changes that built on each other.

1. token-report.sh fixes

  • Accepts additional workflow name prefixes as positional args after the hours parameter, matching the pattern list-recent-runs.sh already uses
  • Aggregates all token-usage.json files per run instead of picking the first one — fixes undercounting for matrix workflows like review-reviewers (3 jobs per run)
  • Adds .claude/skills/running-tend/SKILL.md documenting tend's non-standard workflows and how to include them in usage analysis

Before this change, review-reviewers was invisible to the token report despite being 75% of all token usage on tend.

2. Notifications cost cut (3-layer fix)

tend-notifications was burning ~$50/day on worktrunk because most "unread" notifications were leftovers from events that dedicated workflows already handled. Each notification cost $2-6 in Claude turns to investigate and skip.

  • Layer A (action.yaml) — Post-step marks the event's notification thread as read on success. Scoped by updated_at <= run_started_at so newer activity stays unread. Handles issue_comment's PR-vs-issue distinction via .issue.pull_request.url.

  • Layer B (workflows.py pre-check) — tend-notifications workflow's existing pre-check now also sweeps notifications shadowed by recent dedicated workflow runs in bash before invoking Claude. Catches the case where Claude failed mid-run (Layer A's post-step is gated by if: success()).

  • Layer C (notifications skill) — Step 4a collapsed to a single comment+review check. Removed the workflow-runs investigation that Layer B now handles in bash.

Bonus: fine-grained PAT scope updated from notifications:read to notifications:write (the post-step needs PATCH access).

Combined, this should drop tend-notifications cost from ~$56/day across both repos to under ~$10/day.

This was written by Claude Code on behalf of @max-sixty

max-sixty and others added 3 commits April 11, 2026 13:54
…jobs

token-report.sh only discovered `tend-*` workflows and picked a single
token-usage.json per run. This missed `review-reviewers` entirely (75% of
token usage) and undercounted matrix workflows by only reading one of N
job artifacts.

Accept additional workflow prefixes as positional args after HOURS, and
aggregate all token-usage.json files per run. Add running-tend skill to
document tend's non-standard workflows for usage analysis.

Co-Authored-By: Claude <[email protected]>
Combines matrix job aggregation (sum all token-usage.json files per run)
with cost_usd field from the usage-cost branch.

Co-Authored-By: Claude <[email protected]>
Keeps both the extra-prefix shift/args handling and the BSD date fallback.

Co-Authored-By: Claude <[email protected]>
Most tend-notifications runs were spending $2-6 in Claude turns investigating
notifications that dedicated workflows already handled. Three layered fixes:

1. action.yaml post-step marks the event's notification thread as read on
   success, scoped by updated_at <= run_started_at to avoid clobbering newer
   activity. Handles issue_comment's PR-vs-issue distinction via
   .issue.pull_request.url.

2. tend-notifications pre-check (workflows.py) sweeps notifications shadowed by
   recent dedicated workflow runs in bash before invoking Claude. Catches
   failed-Claude runs where the post-step's success guard skipped marking.

3. notifications skill Step 4a collapsed to a single comment+review check;
   removed the workflow-runs investigation now handled by the pre-check.

Fine-grained PAT scope updated to notifications:write.

Co-Authored-By: Claude <[email protected]>
@max-sixty max-sixty changed the title fix(token-report): include non-tend-* workflows and aggregate matrix jobs feat: notifications cost cut + token-report fixes Apr 11, 2026
Previous commit shipped the workflows.py changes but the on-disk YAML
hadn't been refreshed (uvx cached an older build). actionlint flagged
SC2015 on the stale [-n A] && B || true pattern that the source had
already replaced with || continue.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 28504f1 into main Apr 11, 2026
5 checks passed
@max-sixty
max-sixty deleted the usage branch April 11, 2026 22:34
max-sixty added a commit that referenced this pull request Apr 14, 2026
Bumps generator version to 0.0.12 and syncs lockfile.

50 commits since 0.0.11: notifications cost cut + freshness gate (#251, #254),
token-report per-run table and cost estimate (#249, #250), review-reviewers
outcome-focused Haiku analysis (#255), config workflow_extra/jobs pass-through
(#227), canonical author_association tiers across skills (#261, #263), action
token aggregation fix (#266), plus numerous review/mention/ci-runner fixes.

Co-Authored-By: Claude <[email protected]>
@max-sixty max-sixty mentioned this pull request Apr 14, 2026
max-sixty added a commit that referenced this pull request Apr 14, 2026
Bumps generator version to 0.0.12 and syncs lockfile.

50 commits since 0.0.11. Highlights:
- feat: notifications cost cut + freshness gate (#251, #254)
- feat: token-report per-run table + cost estimate (#249, #250)
- feat: review-reviewers outcome-focused Haiku analysis (#255)
- feat: config `workflow_extra` / `jobs` pass-through (#227)
- skills: canonical `author_association` tiers (#261, #263)
- fix: action token aggregation (#266), plus numerous
review/mention/ci-runner fixes

> _This was written by Claude Code on behalf of Maximilian_

Co-authored-by: Claude <[email protected]>
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