Repository navigation
fix(roadmap): the step budget counts new tokens, not cached input - #4553
Conversation
Live steps (a person)The live ConfigMap
fail-to-pass
Other checks: Measurements (2026-11-11)
The five points of the item
|
7d0df56 to
c1de42b
Compare
Review findings
For the owner: this pull request replaces the report-only acceptance criteria of #4387 with the fix that the measurements recommend. If you want #4387 to stay open for a report, change Order with #4556#4556 and this pull request change the same lines (the field |
a48d7be to
7221a9b
Compare
The token budgets of roadmap.implement added the input tokens of each reply. pydantic-ai counts the prefix that the provider read from its cache in input_tokens, and 98.6% of the input of the runner Jobs were cache reads. The step, its ceiling and the item budget now count the input that the cache did not serve and the output. The outcome, the tier spend and the record implement.spend keep the cached input. Closes #4387
7221a9b to
fda278d
Compare
Review findings, second pass (head
|
| Route | Requests | Input tokens for each request | Cache reads for each request | Output tokens for each request | New tokens for each request |
|---|---|---|---|---|---|
cached hosted (deepseek/deepseek-v4.1-flash-1017:floor) |
4911 | 83669 | 82183 | 442 | about 1930 |
local qwen3-coder:30b (the runner Jobs until 2026-11-05) |
14642 | 39274 | no series | 201 | about 39500 |
- Only the DeepSeek route has a series of cache reads.
qwen3.8:27b,qwen3-coder:30bandclaude-sonnet-5-5have none. - The new test on the old head: with the default settings, a step on the local route made 26 requests (
assert 26 >= 200). With the old count of all input tokens and the old default of 8000000, it made about 200.
Change:
- The defaults keep their values from before this pull request:
step_token_budget8000000 anditem_token_budget20000000. The ceiling stays twice the budget (fix(roadmap): default the step ceiling to twice the budget #4556): 16000000. The unit stays new tokens. - A route that reports no cache reads counts each input token in both units. So a step on the default ladder keeps about 200 requests of 39300 tokens.
- On the cached hosted route, 8000000 new tokens are about 4100 requests. The time limit of the step (5400 s, about 540 requests at 10 s each) stops the step first, at about USD 0.2. Before this pull request, the budget stopped it after about 96 requests. So the fix of chore(roadmap): count cached tokens in the step budget #4387 stays.
- I did not add a budget for each tier. It adds settings and a rule for a step that moves from a local tier to a hosted tier, and the kind of a tier does not tell if its route reports cache reads (the hosted
claude-sonnet-5-5reports none). The design records this and the defaults of 1000000 as rejected alternatives. - Tests:
test_the_default_step_budget_fits_a_route_with_and_with_no_cache_reads(no cache reads: at least 200 requests; cached: at least 540 requests), andtest_the_defaults_fit_the_measured_spend_of_steps_and_itemsexpects 8000000 and 20000000.docs/CONFIGURATION.md,tests/roadmap/test_roadmap_limit_classes.pyand the extension line ofdocs/ROADMAP_WORKFLOW.mdare the same as onmainagain.
(b) minor, src/devops_cli/roadmap/implement/implement_run.py: a record of the old image counts all its input for the new item budget. CONFIRMED
Evidence:
_item_spendreturnednew_tokens(self.earlier), and_RecordedSpend.cache_read_tokensis 0 for an older record. The new test on the old head: a record of 100100 input tokens with no unit anditem_token_budget1000 stopped the next Job withlimit_reached(assert 'limit_reached' != 'limit_reached').- One more defect of the same cause: a Job of the new image that read an old record wrote one sum of both units. The Job after it then read the old input as new tokens again.
Change:
- The record names the unit of its count.
implement.spendholdsnew_tokens, the count of the item budget, and each Job adds its own new tokens to it. The item budget readsnew_tokensand no longer computes the count from the totals. - A record that an older version wrote has no
new_tokens, so its Jobs count 0 by the rule of feat(roadmap): implement keeps phase marks and the spend of a killed Job #4070 (a missing key takes its empty value). Its input tokens hold cache reads in an unknown share. The record keeps them for the report. - Tests:
test_spend_survives_kill_a_record_of_an_older_version_counts_no_tokens_for_the_item_budget(it replaces..._gives_its_spend, which expected the old total to stop the run), andtest_spend_survives_kill_the_mark_of_a_passed_group_holds_the_spendchecksnew_tokens226.
The two majors: still fixed
- The acceptance criteria of chore(roadmap): count cached tokens in the step budget #4387: chore(roadmap): measure the cache share of a stage plan run #4583 is open, and the body names it. Only chore(roadmap): count cached tokens in the step budget #4387 follows a closing keyword.
- The frozen ceiling (fix(roadmap): default the step ceiling to twice the budget #4556): fix(roadmap): default the step ceiling to twice the budget #4556 merged (
1dfb6c8d) withstep_token_ceilingint | Noneand the propertytoken_ceiling. This branch keeps both, andStepBudgetreadslimits.token_ceiling.
Live steps (a person). They replace the live steps of the first comment
#4556 merged first (1dfb6c8d), and this branch is rebased on it. I resolved the conflicts so: defaults.py keeps the deletion of DEFAULT_ROADMAP_IMPLEMENT_STEP_TOKEN_CEILING; the description of step_token_ceiling keeps the text of #4556 and says "new tokens (see step_token_budget)"; the main spec keeps the ceiling requirement of #4556, which states its unit as the unit of step_token_budget, so this change no longer modifies it; docs/ENV_VARS.md is generated again.
The plan of the orchestrator is safe with this change: keep the line roadmap.implement.step_token_budget: 12000000 until the new image runs, then delete it. The settings load with the old image (ceiling 16000000) and with the new image (the ceiling follows the budget: 24000000). On the DeepSeek ladder of the live ConfigMap, 12000000 new tokens are about 6200 requests, so the time limit stops a step first.
- This pull request merged as
9605f554(headfda278dc, with the fixes above). - Keep
step_token_budget: 12000000in the ConfigMapdevops/devops-cli-configuntil the release that holds this pull request runs. Check the version:kubectl -n devops exec deployment/roadmap-service -- devops --version. - Then delete the line:
The runner Jobs read the ConfigMap when they start. The defaults then apply: 8000000 new tokens for a step, a ceiling of twice the budget (16000000), and 20000000 for an item. If the active
kubectl -n devops edit configmap devops-cli-config # In the key devops-cli.yaml, delete the line `step_token_budget: 12000000` under `roadmap:` / `implement:`. kubectl -n devops get configmap devops-cli-config -o jsonpath='{.data.devops-cli\.yaml}' | grep -c step_token_budget # 0 kubectl -n devops rollout restart deployment/roadmap-serviceconfig.yamlthatdevops k8s deploy-stack --stack devopsrenders holds the key, remove it there too, or the next deploy-stack writes it again. - Old records need no step. After the rollout, a continuation whose earlier Job wrote
implement.spendwith the old image counts 0 for that Job and starts a new count of new tokens.
Checks
uv run devops ci fail-to-pass --base origin/mainonfda278dc(13 min 41 s): 12 tests fail on the base and pass on this branch, andtests/roadmap/implement/test_roadmap_implement_limits.pydoes not collect on the base (nonew_tokens). The new tests above are in this set.pytest tests/roadmap/implement tests/roadmap/test_roadmap_limit_classes.py tests/security/test_config_declarations.py tests/config tests/ai/client/test_roadmap_agent_run.pyafter the rebase on fix(roadmap): default the step ceiling to twice the budget #4556: 2009 passed.uv run devops ci --check --only constructs,docs,openspec: pass.uv run devops docs generate --sync-readme: no further diff. The pre-push hook passed.- The archive is still the last commit. The code, test and document changes are in the first commit, and the spec, proposal, design and tasks changes are in the archive commit.
- The PR body is shorter (860 characters above
Closes), because the monitor refused 1175.
The record `implement.spend` kept only the first request of each step, and the trace drops its oldest model events in a long run, so no record showed which step used the tokens or its largest request. Each entry under `implement.spend.steps` now also holds the requests, the input and output tokens, the repair rounds and `largest_request_tokens` of the step. The budget count does not change. The cached and uncached split waits for #4553, which adds `cache_read_tokens` to `StepOutcome` on the same lines. Closes #4587 Change: `openspec/changes/archive/2026-11-11-4587-keep-the-tokens-of-each-implement/`
The token budgets of
roadmap.implementadded theinput_tokensof each reply, and pydantic-ai counts the cache reads in them. 98.6% of the runner input was cache reads, so steps stopped after about 100 requests.implement.spendkeepcache_read_tokens. The record keeps the item budget count asnew_tokens. An older record has none and counts 0.This fix replaces the report-only criteria of the item. #4583 holds its open stage planner points 2 and 5.
Closes #4387
Change:
openspec/changes/archive/2026-11-11-4387-the-step-budget-counts-new-tokens/