Skip to content

feat(roadmap): keep the tokens of each implement attempt #4587

Closed

Description

@dan-petty

Problem or Motivation

The record implement.spend keeps only one figure for each step: first_request_tokens. It does not keep the requests, the input tokens, the output tokens, the repair rounds or the largest request of a step. The totals of the record add all steps of all Jobs of the item, so a reader cannot tell which step or which attempt used the tokens.

Evidence on origin/main 5f75d25:

  • _step_spend (src/devops_cli/roadmap/implement/implement_run.py:437) writes only step, first_request_tokens and an optional extension for each step.
  • StepOutcome (src/devops_cli/roadmap/implement/implement_step.py:469) already holds requests, input_tokens, output_tokens and repair_rounds of the step. No field holds the largest request.
  • The trace implement.trace drops its oldest model events when a run is long (fix(roadmap): keep tool events in the trace of a long run #4393), so the trace cannot give these figures for a long run.
  • In a study of implement runs, the median first request was 27,924 tokens. The 97,821 tokens in chore(roadmap): inventory the start context of a step #4385 is a request from the middle of a run, not a first request. Without the largest request of each step, the record cannot show this.

The investigations #4385 and #4386, and the work in #4075 and #4394, need these figures for each step.

Proposed Solution & Architectural Design

  1. Add largest_request_tokens to _Run and StepOutcome in implement_step.py: the largest usage.input_tokens of one reply of the step.
  2. In _step_spend, also write requests, input_tokens, output_tokens, repair_rounds and largest_request_tokens of the step.
  3. The usage of pydantic-ai 2.59.0 gives cache_read_tokens for each reply. Pull request fix(roadmap): the step budget counts new tokens, not cached input #4553 (chore(roadmap): count cached tokens in the step budget #4387) adds cache_read_tokens to StepOutcome. When that field is on main, _step_spend also writes it, so a reader gets the cached and the uncached input tokens of each step apart.
  4. Do not change the budget count in implement_limits.py (chore(roadmap): count cached tokens in the step budget #4387 changes it).

Test first: a fake-model step with two requests of different size records each new field, and the largest request equals the largest tokens_in of the model events of the step.

Target Subsystem

roadmap implement job (src/devops_cli/roadmap/implement/).

Existing Tool Considered

pydantic-ai RequestUsage gives the counts of each reply. This change only writes the counts that the job already has. No new library is necessary.

Measure

The new fields are in each entry of implement.spend.steps of a new implement run.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It improves cost observability for implement runs but does not block a broken feature.
    • Value: Medium. Readers can finally see which step and attempt used the tokens, aiding cost analysis and debugging.
    • Effort: Medium. Add fields to two classes, extend one write function, and add a test with a fake model.
    • Related: feat(roadmap): a step stops at its budgets and records attempts #3568, which asks for a different change. Both extend the implement.spend record, but #3568 adds budget limits and attempt counts while this candidate adds per-step token breakdowns (requests, input, output, repair_rounds, largest_request_tokens).
  3. added
    priority/p2-medium
    owner/agent
    status/in-review
    and removed
    status/new
    on Nov 11, 2026
  4. removed
    status/in-review
    owner/agent
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 14:13 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions