Skip to content

fix(roadmap): the refine proposal caps its context with a job constant #5464

Closed

Description

@dan-petty

Problem or Motivation

The refine proposal call caps its context with the window of the analysis task, not with a bound of the job:

  • src/devops_cli/roadmap/refine/refine.py:2906 sets max_tokens = ai_config.for_task("analysis").context_window or 8192.
  • The deployed analysis window is 256,000 (k8s/devops/configmap.example.yaml shows the same value). So the cap has no effect in practice.
  • For the 54 item bodies of the stage comment sample, collect_context before any cap is p50 81k, p90 141k and max 540k o200k tokens.
  • The refine row is the second largest row: about $3.16 and 124.5M prompt tokens in 3 days to 2026-11-13. It has the most uncached input of all rows, about 19.1M tokens (15%), against about 15.3M for stage.
  • A change of the analysis model or window changes the refine input with no review of the refine job.

The stage job caps the same context at CONST_ROADMAP_STAGE_CONTEXT_MAX_TOKENS (20,480).

Proposed Solution & Architectural Design

  1. Add CONST_ROADMAP_REFINE_CONTEXT_MAX_TOKENS = 20,480 to src/devops_cli/config/constants.py.
  2. The proposal call uses min(CONST_ROADMAP_REFINE_CONTEXT_MAX_TOKENS, window // share), as the stage job does (stage.py _request).
  3. The refine result line (feat(roadmap): result lines state first-pass, model calls and cost #5168) gives the context tokens before and after the cap, as counts only.

Not in scope: an item manifest for the refine investigation agent. It is an experiment, and it waits for the refine tool records of #5460:

  • Case set: a fixed set of 15 recent refine items at one commit.
  • Arms: today (the investigation gets no context) against a manifest of at most 3k tokens (cited paths with line ranges, symbol locations, requirement names, no file text).
  • Primary measure: model requests for each run.
  • Decision rule: the manifest passes only with at least 2 fewer requests for each run and no change of more than 2 of 15 judge verdicts (ready, person, retry).

Target Subsystem

SDLC, Git & PR Governance: src/devops_cli/roadmap/refine/refine.py, src/devops_cli/config/constants.py.

Existing Tool Considered

truncate_to_token_limit already cuts the context. The change sets the bound only. No tool is necessary. Cost to build: about 0.3M tokens and 1 hour, about 10 lines and 2 tests.

Acceptance Criteria

  • Test first: with an analysis window of 256,000, the proposal request for a body that cites a file of 60k tokens holds at most CONST_ROADMAP_REFINE_CONTEXT_MAX_TOKENS tokens of context.
  • Quality screen: no refine golden set exists. Run both caps in shadow on the same 15 recent refine items at one commit. Give the judge verdicts and the input tokens of both arms in the pull request comment. A change of more than 2 of 15 verdicts stops the change.
  • Measure: uncached prompt tokens of the row refine for each run, from devops_cli_ai_tokens_total and the result lines of feat(roadmap): result lines state first-pass, model calls and cost #5168.
  • Live proof after release: on real Service refine runs for 7 days, the context tokens after the cap are at most the constant, and the uncached prompt tokens for each proposal fall (expected about -49k at p50). Give the judge verdict mix of 14 days, with the note that the items of each week differ.

Dependencies

None. #4878 changes the same function for a slow git grep. Do not stack the pull requests.

Standards Compliance

  • I confirm this proposal aligns with AGENTS.md engineering principles (cyclomatic complexity <= 10, nesting <= 4 blocks, zero bare exceptions, tests that cover the changed lines).

Activity

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

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 13, 2026
  4. added
    status/in-review
    and removed
    status/in-progress
    on Nov 15, 2026
  5. removed
    status/in-review
    owner/agent
    on Nov 15, 2026
  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-15 23:51 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/lowpriority/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