Skip to content

fix: skip runs that skipped every job in the token report - #1644

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-1642-token-report
Nov 3, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-1642-token-report

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

tend runtime token-report ran gh run download for every completed run in its window, including runs whose jobs were all skipped by their if:. Those runs ran no session and uploaded no session logs, but each still cost at least one REST call. The run listing now also asks for conclusion, and runs with conclusion skipped never reach the download loop. On leaf's 2026-11-02 sweep, which the issue cites, that is 621 of 2,297 runs.

test_a_skipped_run_is_never_downloaded fails on the old code, which downloads the skipped run, and passes now. Skipped runs also drop out of the "uploaded no readable session-logs artifact" count, which was meant for runs that ended before the upload.

This doesn't take the issue's other two ideas: one artifact listing for the whole repository instead of one per run, and a rate-limit floor that ends the report early with partial results. Both add mechanism. Whether the report's remaining one call per run is worth it is for a maintainer to judge.

Refs #1642 — automated triage

A run whose jobs were all skipped by their if: ran no session and uploaded no
session logs, yet the report still spent a gh run download call on it.

Refs #1642
@max-sixty
max-sixty merged commit 9379f3c into main Nov 3, 2026
12 checks passed
@max-sixty
max-sixty deleted the fix/issue-1642-token-report branch November 3, 2026 08:21
max-sixty added a commit that referenced this pull request Nov 5, 2026
`tend runtime token-report`, which each consumer's nightly sweep runs,
made one `gh run download` per run in its window, and every Tend
workflow on the account shares that account's 5,000-request hourly
allowance. On max-sixty/leaf on 2 Nov the report spent 3,977 of those
requests in three minutes and starved the account's other Tend workflows
for most of an hour (#1642). #1644 dropped runs that skipped every job.
This drops the requests for runs that uploaded no session log, which is
most of what remains.

The report now pages the repository's artifact listing once, newest
first, back to the run fetch's creation bound. It downloads each
session-log artifact of a run it covers by artifact id, so a run without
one costs nothing. Most runs in a busy window upload none: landing
checks, mention relays, CI-failure verdicts and mentions not addressed
to the bot.

Measured on max-sixty/leaf over the 24 hours to 2026-11-05 17:48 UTC:
832 runs in the window after skipped ones, 328 of them with a session
log (329 artifacts). The per-run requests go from 832 + 329 = 1,161 to
13 listing pages + 329 = 342. On the same one-hour window against leaf,
the old and new code gave byte-identical JSON and summaries, at 103 and
59 requests.

- `_common.gh` takes a `stdout` file, so the zip download still goes
through the one `gh` call site.
- A `token-usage.json` holding a value that isn't an object now costs
only its own run. Its `TypeError` used to escape the per-run handler and
end the report.
- A failed listing page now fails the report outright, where the old
path counted each failed per-run download as a missing upload and
under-reported without saying so. Of 27 calls at 100 per page, 7 failed
with HTTP 500 in a burst, and none of the 30 since.

Known, and unchanged here:
- The missing-upload footnote says those runs "ended before the upload
or had torn uploads". On leaf, nearly all of the roughly 500 a day it
counts never ran an agent, which hides any real torn upload.
- `tend-land` completed 413 runs in a day on leaf, so a long window plus
the 24-hour creation cushion could pass the 1,000-run listing ceiling.
The report warns when that happens.

Refs #1642

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty max-sixty mentioned this pull request Nov 9, 2026
max-sixty added a commit that referenced this pull request Nov 9, 2026
Release 0.3.24, shipping #1648's per-issue triage concurrency, so a
consumer's triage sessions for different issues run at once instead of
in one lane. Also ships #1652's CI handoff to tend-land when the
review's CI wait is off, the token report's API savings (#1644, #1653),
and the fixes and tool bumps listed in the changelog.

Validation: full `wt test` and all pre-commit hooks passed on the
release commit. The Codex subscription smoke passed on `d1f7c5ef` after
`CODEX_AUTH_JSON` in the `tend` environment was refreshed with an
access-only login; it runs again on the exact release commit before the
tag.

> _This was written by Claude Code on behalf of max-sixty_
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