Skip to content

fix(roadmap): count the tokens of each implement Job once - #4213

Merged
dan-petty merged 3 commits into
mainfrom
fix/4200-count-implement-spend-once
Nov 9, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/4200-count-implement-spend-once

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The Service adds the tokens of a reported runner Job to devops_cli_service_implement_tokens_total. Since #4070 the record implement.spend holds the sum of all Jobs of an item, but each report added the whole sum. So the tokens of an earlier Job counted again at each later report.

The record now keeps implement.spend_counted, the total that the counter already holds. A report writes it with the Job state and adds only the difference to the counter. A retry and a return to New clear it with the spend. An old record without the key counts its whole spend once.

Closes #4200

Change: openspec/changes/archive/2026-11-09-4200-count-the-tokens-of-each-implement/

Plan the change 4200 and add the failing tests: the counter must add only the tokens of the reported Job, because implement.spend is the sum of all Jobs.
Record implement.spend_counted with the Job state, add only the tokens above it to the counter, and clear it with the spend at a retry and a return to New.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 9, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record for #4200.

Fail-to-pass (devops ci fail-to-pass --base origin/main): 9 tests fail on the base and 114 pass, with 0 errors. The two-Job test fails on the base: the counter grows by 5500 and must grow by 4000.

Full CI (devops ci): all rows passed after the archive and the last rebase. The first run had 6 failures in tests/ai/rag/test_qdrant_request_telemetry.py. The branch name held the word "token", and the span carries the branch name (existing issue #3638). The branch was renamed, and the rerun of the test row passed with 21939 tests. The test row took 10m 18s, which is the known issue #3593.

Narrow checks after the rebase onto origin/main: test_roadmap_implement_submit.py (61 passed), openspec check, docs generate --check.

Old records: a test loads a record that has implement.spend and no implement.spend_counted. It counts the whole spend once.

Not changed: no setting, ConfigMap key or Settings field. So no ConfigMap load test.

@dan-petty
dan-petty marked this pull request as ready for review November 9, 2026 04:59
@dan-petty
dan-petty merged commit a243c25 into main Nov 9, 2026
26 checks passed
@dan-petty
dan-petty deleted the fix/4200-count-implement-spend-once branch November 9, 2026 09:45
dan-petty pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.100.0](v0.99.0...v0.100.0)
(2026-11-09)


### Features

* **roadmap:** record the reference hits of a stage case in the replay
([#4211](#4211))
([06a7251](06a7251))


### Bug Fixes

* **roadmap:** accept a null reason on a stage reference
([#4215](#4215))
([ce96397](ce96397))
* **roadmap:** count the tokens of each implement Job once
([#4213](#4213))
([a243c25](a243c25))
* **roadmap:** send tool choice auto to Claude and count answers
([#4216](#4216))
([5c4cabf](5c4cabf))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): count the tokens of each implement Job once

1 participant