Skip to content

fix(roadmap): stage and refine send no answer count or row #4475

Closed

Description

@dan-petty

Problem Description

Since #4237, the stage, refine and alternatives runs send no model answer count, and no AI series can tell one roadmap row from another.

#4237 removed the record_run_spend call from investigate (src/devops_cli/roadmap/refine/refine_investigation.py). The stage, refine and alternatives rows all run their model through investigate. #4237 added a hook in build_agent (src/devops_cli/ai/client/factory.py) that writes one spend record for each model request. That hook writes the ledger row and the request, token and spend counters, but it does not add to devops_cli_ai_model_answers_total. Only record_run_spend adds to that counter, and only the implement step calls it now. The implement step runs in a runner Job, not in the Service.

Also, the series devops_cli_ai_requests_total, devops_cli_ai_tokens_total, devops_cli_ai_spend_usd_total and devops_cli_ai_model_answers_total have no row label. The ledger gives the stage, refine and alternatives requests the same stage, analysis. So no query can split the tokens of the Service by row (intake, refine, alternatives, stage, implement).

Reproduction Steps

  1. git log -S record_run_spend --oneline shows refactor(ai): replace PydanticAgent with pydantic-ai Agent #4237 (5edd7a5). Its diff removes record_run_spend(model, messages, ..., stage="analysis") from refine_investigation.py.
  2. Prometheus: max by (job) (max_over_time(timestamp(devops_cli_ai_model_answers_total)[2d:5m])). The last sample of job roadmap-service is at 2026-11-09T17:32:53Z, the rollout of refactor(ai): replace PydanticAgent with pydantic-ai Agent #4237. The runner Jobs (job devops-cli-job) still send it.
  3. Prometheus: sum by (type) (increase(devops_cli_ai_tokens_total{job="roadmap-service"}[6h])). The tokens continue after 17:32Z, and the reasoning type, which only the build_agent hook sends, grows from about 72K to about 1.4M tokens in 6 hours. So the spend records do not stop; only the answer count stops.
  4. devops_cli_ai_tokens_total has the labels provider, model, server, backend, operation, local and type. It has no row.

Expected vs Actual Behavior

Expected: each model request of an agent run adds one answer count (asked, answered, fallback), and the request, token, spend and answer series of the Service carry the job row (row) whose work sent the request. A request counts one time only.

Actual: the Service sends no answer count after 2026-11-09T17:32Z, and its AI series have no row.

Environment Diagnostics

origin/main c653bde. roadmap-service in namespace devops, Prometheus of the homelab cluster.

Logs, Traces, or Terminal Output

Last devops_cli_ai_model_answers_total samples by job: roadmap-service 2026-11-09T17:32:53Z, devops-cli-job 2026-11-10T20:36:29Z.

Series in the last 7 days for job roadmap-service: tokens 32, spend 8, requests 11, answers 2.

The request_scope context variable (src/devops_cli/github/request_scope.py) already holds the job row of each Service row for devops_cli_github_requests_total. Its values are the rows of the due table and other, so a row label from it is bounded.

The price of DeepSeek models (spend 0 USD) is #4403 and is not part of this item.

Pre-Submission Checklist

Activity

  1. added
    source/agent
    type/bug
    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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Monitoring is broken since #4237 but no user-facing function is lost; it is an observability gap. The regression commit 5edd7a5 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 with the label priority/p0-critical.
    • Value: Medium. Restores a broken counter and adds a label that operators need to split Service spend by row.
    • Effort: Medium. Requires restoring the answer count in the build_agent hook and wiring the request_scope row into four Prometheus series.
    • Related: feat(cli): stage-attributed spend ledger and one genai-prices price source #594, which asks for a different change. Both attribute AI spend to a stage or row, but #594 changes the ledger structure while the candidate fixes a Prometheus counter regression and adds a row label to existing series.
  3. added
    priority/p2-medium
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 11, 2026
  4. removed
    status/in-progress
    owner/agent
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor
  6. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 05:46 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/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions