Repository navigation
fix: keep token-report running when an artifact listing page fails - #1672
Conversation
A failed page of the repository-wide artifact listing now ends the read with the pages already read kept, and each run the listing had not reached is asked for its own artifacts instead. Closes #1668
|
@tend-agent The new per-run fallback reads only
|
A run whose session log sits past its first hundred artifacts was counted as skipped. The fake gh now slices the per-run listing by per_page and page, so the fixture's hundred CI artifacts put run 2's log on page 2.
|
Done in dc16506. The per-run fallback now pages through |
…eport test docstrings (#1702) Test-only cleanup from the nightly survey: two prompt tests that couldn't fail on a mangled prompt now check the prompt the agent receives, and several test docstrings and names that described the older `jq`-based token report now describe the current code. - **`test_config_edge_cases.py`.** `test_very_long_prompt_nightly` and `test_prompt_with_multiline` only asserted that the generated workflow parses as a mapping, so a truncated prompt or one with its line breaks lost would still pass. Both now compare the parsed `prompt:` input exactly (via the shared `agent_prompt` helper, as the placeholder test above them already does). Two variables in `test_setup_steps_preserves_order` were still named after old setup steps (`node_pos`, `cache_pos`); they are renamed to match the `echo first`/`echo last` steps they locate. - **`test_token_report.py`.** The docstring of `test_one_unreadable_artifact_costs_its_own_run_and_no_other` described `jq` failing under `set -euo pipefail`. `token_report.main` now parses `token-usage.json` in Python and skips the run on `TypeError`/`ValueError`. `test_workflow_prefix_is_passed_to_jq_as_data` is renamed, since prefixes are matched with `str.startswith` and never reach `jq`. A docstring citing the removed `EXTRA_PREFIXES` variable now says "extra prefix arguments", and an unused `REPO_ROOT` constant is gone. - **`test_list_recent_runs.py`.** Drops a function-local `from datetime import datetime` that repeated the module-level import. The three files pass locally (177 tests). None of these edits touch the hunks open PR #1672 changes in `test_token_report.py`. Co-authored-by: tend-agent <[email protected]>
Since #1653,
token-reportfound session logs by paging the repository-wide artifact listing, and_session_logsread each page outside any handler. So one 5xx page (gh'sunexpected end of JSON input) aborted the whole report. A page that fails to read, including a 200 whose body has noartifactsarray, now stops the listing and keeps the pages already read. The report prints a warning naming the failed page, then asks each run the listing hadn't reached for its own artifacts (actions/runs/{id}/artifacts). That costs the same per-run requests as before #1653, and only when the listing breaks. If one of those per-run reads fails, only that run is lost, and it is counted inskippedas before.test_a_failed_listing_page_falls_back_to_each_unseen_runfails page 2 of the listing. On the old code it exits 1 withunexpected end of JSON input, which is the reported symptom. With the fix it prices the run found on page 1, recovers the run whose log sat on page 2 through the per-run listing, and counts the run with no upload as skipped. It also asserts that per-run reads go only to runs the listing hadn't reached. The rest oftest_token_report.pypasses unchanged.What this leaves out
Closes #1668 — automated triage