Repository navigation
Description
Problem or Motivation
#4387 asked five questions about the token budget and the provider cache. PR #4553 answers three of them for the implement step and makes the step budget count new tokens. Two points of #4387 are open for the stage planner (devops roadmap stage):
- Point 2: the share of cached input tokens in a real stage plan run. PR fix(roadmap): the step budget counts new tokens, not cached input #4553 measured the implement step (98.6% cache reads in the runner Jobs) and the Service row
refine(about 79%), but not a stage plan run. - Point 5: whether the prompt of the stage planner puts the stable text first and the changing text last, so that the provider cache serves the shared prefix. PR fix(roadmap): the step budget counts new tokens, not cached input #4553 did not check the order of the stage planner prompt.
Without these two answers, nobody knows if the stage planner pays the full input price on each request, and if a change of its prompt order makes its runs cheaper.
Proposed Solution & Architectural Design
- Measure the cache share of one or more real stage plan runs. The CLI records
cache_read_tokensof each agent run (track_request_spendinsrc/devops_cli/roadmap/agent_run.py), and the gateway metricslitellm_provider_cache_read_input_tokens_metric_totalandlitellm_input_tokens_metric_totalgive the same counts for each end user. Give the share as a percentage, with the time window and the query. - Read the stage planner prompt (
src/devops_cli/roadmap/stage/): the system text, the tool definitions and the first user message. State if the stable text comes first and the text of the item comes last. Give one verdict: follows the order, or does not follow it, with the file and the line of each part. - If the order does not follow the rule, or the share is much lower than the implement step, file one fix issue for each change. Otherwise close this issue with the evidence in a comment.
No production code is part of this issue.
Acceptance:
- A comment on this issue gives the cache share of a stage plan run as a percentage, with its source.
- A comment on this issue gives the verdict on the prompt order of the stage planner, with file and line references.
- Each recommended change has one issue URL.
Target Subsystem
roadmap stage (planner), AI gateway usage metrics.
Existing Tool Considered
The LiteLLM gateway metrics and the pydantic-ai usage fields (cache_read_tokens) already give the counts. The item needs no new tool.
Source: points 2 and 5 of #4387, left open by PR #4553.
Source: #4553
Dependencies
- chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental work on the stage, implement and fix-checks jobs waits for the re-architecture)
Alternatives check of 2026-11-20: not-applicable.
Class: chore, no search.
Tool: none found.
Proposed design
Problem statement
Nobody knows the share of cached input tokens in a real stage plan run, or if the stage planner prompt puts the stable text first and the item text last. This item records the cache share with its time window and query, gives one verdict on the prompt order with file and line references, and links one fix issue for each recommended change. The change adds no production code.
Acceptance criteria
Requirement: Cache share recorded
A comment on issue #4583 MUST give the cache-read share of a real stage plan run as a percentage, with its time window and its query.
Scenario: The evidence comment shows the share, the window and the query
- WHEN A person runs
gh issue view 4583 --commentsafter the evidence comment lands - THEN The output shows the share as a percentage, the time window, and the query that reads the gateway cache-read series over
litellm_input_tokens_metric_total.
Requirement: Prompt order verdict
A comment on issue #4583 MUST give one verdict on the prompt order of the stage planner, with the file and line of each part.
Scenario: The verdict names each prompt part and its location
- WHEN A person runs
gh issue view 4583 --commentsafter the evidence comment lands - THEN The output shows the verdict that the stable text comes after the item text, and the file and line of the system text, the tool definitions, the first user message,
CONTEXT.md, ADR 0001 to 0005 andcapabilities.
Requirement: One issue for each change
The evidence comment MUST give one issue URL for each recommended change.
Scenario: Each recommended change has one linked issue
- WHEN A person runs
gh issue view 4583 --commentsafter the evidence comment lands - THEN The output holds one issue URL for the prompt reorder and one issue URL for the ADR index, and each URL opens an open issue.
Existing Tool Considered
The alternatives check of 2026-11-13 in the issue body gives not-applicable (class chore, no search) and names no tool. The counts come from tools that the repository already uses: the LiteLLM gateway cache metrics that k8s/README.md:142 documents, where the cache hit share is the cached-input series over litellm_input_tokens_metric_total, and the pydantic-ai cache_read_tokens that track_request_spend writes (src/devops_cli/ai/spend/ledger.py:947). The change builds no code, so it has no build, upkeep or fix cost. The alternatives check in the issue body holds what the tools cover and lack.
Key questions
- What share of the input tokens of a real stage plan run comes from the provider cache?: DeepSeek read 96-98% of the stage and implement input from its cache in the 3 days to 2026-11-13. This is an estimate from the spend divided by the price, because
devops_cli_ai_tokens_totalhas nocache_readtype; feat(roadmap): run records give the run, step and path class of tool calls #5460 adds it. A direct count exists for request 1 of feat(ci): Add ast-grep rules for RLIMIT_NPROC, O_NONBLOCK, os.killpg #1976: 10,368 of 41,597 input tokens were cache reads, about 24.9%. [sources: src/devops_cli/roadmap/agent_run.py, src/devops_cli/ai/spend/ledger.py:947, k8s/README.md:142, tests/ai/spend/test_ai_spend_ledger_cache_tokens.py] - Does the stage planner prompt put the stable text first and the item text last?: No. The first user message puts
number,titleandbodyfirst. Then comeCONTEXT.md(5,448 tokens), ADR 0001 to 0005 (about 4.8k tokens) andcapabilities(2,154 tokens). About 12.4k stable tokens follow the item text, so items do not share them as a cache prefix. [sources: CONTEXT.md, docs/adr/0001-github-is-the-roadmap-source.md, docs/adr/0005-review-findings-come-from-tools-not-models.md] - Which gateway metric gives the cached input tokens of a run?:
k8s/README.md:142nameslitellm_input_cached_tokens_metric_totalandlitellm_input_cache_creation_tokens_metric_total, and gives the cache hit share as the first series overlitellm_input_tokens_metric_total. The issue body nameslitellm_provider_cache_read_input_tokens_metric_total. The evidence comment uses the series that the gateway exposes, and it confirms the name before it posts the query. [sources: k8s/README.md:142, tests/fixtures/dashboard_queries/ai-spend.yaml] - Does the stage review run share a cache prefix with the stage planner?: No. The review run sends
roadmap_stage_verify.mdand the review tool rules as its system text, and its request is a different payload. The stake is about $0.02 in 3 days, so this issue asks for no change to the review run. [sources: src/devops_cli/roadmap/agent_run.py] - Should this issue reorder the stage planner prompt itself?: No. This issue records the verdict and links one fix issue for each change. A separate issue does the reorder with an allocation table (feat(roadmap): the stage context gives each block a bound and a cut order #5469), and another replaces the five ADR files with an index (fix(roadmap): the plan context lists the ADRs in force, not ADR 0001-0005 #5465). The saving on DeepSeek is small (about $0.29 of uncached cost in 3 days); the gain is room in the item bound and attention. (best practice) [sources: CONTEXT.md, k8s/README.md:142]
- Chosen: File one fix issue and link it. The issue asks for one fix issue for each change, and the reply on the issue names feat(roadmap): the stage context gives each block a bound and a cut order #5469 for the reorder with its allocation table.
- Rejected: Reorder the prompt in this issue. It mixes a measurement with a prompt change and its test, and the reorder needs an allocation table and a stage eval.
- Rejected: Keep the current prompt order. About 12.4k stable tokens follow the item text, so items share no cache prefix and the item bound loses that room.
- Does this issue run the
CONTEXT.mdterm-index experiment?: No. The experiment waits on feat(roadmap): the stage context gives each block a bound and a cut order #5469 and the harness of the pipeline split (E1 and E5). It runs with the same 51 stage cases: arm A gives the full text in the stable part (about 5.4k tokens), and arm B gives a term index (about 400 tokens) andread_filefor the full text. It decides on paired model requests and tokens, a deterministic count of the_Avoid_aliases ofCONTEXT.md, and a non-inferiority margin set before the run. A separate issue can hold it. (best practice) [sources: CONTEXT.md]- Chosen: Keep the experiment out of this issue. It waits on feat(roadmap): the stage context gives each block a bound and a cut order #5469 and the harness of the pipeline split, and this issue adds no code.
- Rejected: Run the experiment here. The harness and feat(roadmap): the stage context gives each block a bound and a cut order #5469 do not exist yet, so no arm can run now.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
choreprefix of the title gives the type.(roadmap)scope of the title gives the scope.This is an informational measurement with no user-facing change and no blocking effect.The result tells the team whether the stage planner pays full input price, which guides future cost decisions.The task reads existing metrics and one prompt file, then writes a comment; no code change is needed.Both track cached tokens in the roadmap stage area, but #4387 asks for a budget count while this candidate asks for a one-time cache-share measurement and prompt-order verdict.fix(roadmap): the step budget counts new tokens, not cached input (#4553
devops-cli-service commentedon Nov 13, 2026
Alternatives check: not-applicable
Class: chore. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-13. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 13, 2026
Answers from the start-context review of the roadmap jobs (2026-11-13):
Point 2, the cache share. DeepSeek read 96-98% of the stage and implement input from its cache in the 3 days to 2026-11-13. This is an estimate from the spend divided by the price, because
devops_cli_ai_tokens_totalhas nocache_readtype (#5460 adds it). On request 1 of #1976, 10,368 of 41,597 input tokens were cache reads.Point 5, the order. The user message puts
number,titleandbodyfirst. Then comeCONTEXT.md(5,448 tokens), ADR 0001-0005 (about 4.8k) andcapabilities(2,154). So about 12.4k stable tokens come after the item text, and items do not share them as a cache prefix. The uncached cost of that is about 3.8M tokens in 3 days, about $0.29.Verdict: a reorder saves little money on DeepSeek. The gain is room in the item bound and attention. Rule for each new block:
roadmap_stage_verify.mdand the review tool rules, and its request is a different payload. The stake is about $0.02 in 3 days.Experiment for
CONTEXT.md, after #5469, in the harness of the pipeline split (E1 and E5) with the same 51 stage cases:read_filefor the full text._Avoid_aliases ofCONTEXT.md(66_Avoid_lines) in the plan text. The stage eval has no defect type for term drift.CONTEXT.mdwith a tool in 0 of 54 items. That does not show that the text is unused, because the request gives it.devops-cli-service commentedon Nov 19, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
dan-petty commentedon Nov 20, 2026
Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.