Skip to content

fix(roadmap): a refused kept plan uses no stage gate return #4950

Closed

Description

@dan-petty

Problem Description

The stage job keeps the plan of an item that passed the gates as a file (#4167). On a hit, _gated in src/devops_cli/roadmap/stage/stage.py uses the kept plan as the first reply (proposal = first or self._ask_plan(...)) and gates it again on the current staged commit. The commit moved, so the path:LINE:text citations of the kept plan point at moved lines, and newer gates also refuse it. That refusal goes through _returned and uses one of the roadmap.stage.gate_returns returns (default 3, at most 3, #4802, #4900). So an item with a kept plan gets 3 planner runs, and an item without one gets 4 (the first reply and 3 returns). The kept plan made no model request, so it should use no return.

Reproduction Steps

  1. Plan an item with devops roadmap stage --plan so that the plan passes the gates and the plan file is kept, then let the review or a later step fail.
  2. Move the staged commit so that a gate refuses the kept plan (for example, a cited line moves).
  3. Plan the item again with a planner that gives refused replies.
  4. Count the planner requests and read the stage gate returns: line.

Expected vs Actual Behavior

Expected: a refused kept plan uses no gate return. The planner gets a new first reply with the kept plan and its problems, then the normal roadmap.stage.gate_returns returns, as an item without a kept plan does (4 planner runs at the default). The stage gate returns: line counts only the returns after that first reply. After the Service stops, no new planner request starts (#4900).

Actual: the refused kept plan counts as the first reply, so the planner gets only 3 runs, and a new first reply that passes logs returns=1.

Environment Diagnostics

devops-cli 0.116.1 on the roadmap Service (roadmap-service, namespace devops), after the rollout at 2026-11-12T05:26Z.

Logs, Traces, or Terminal Output

05:29:44Z stage reply refused: item=#1858 request=1 input_tokens=0 tools_offered=False tool_calls=0 limit=none finish_reason=none answered=none result=refused
05:37:36Z stage reply refused: item=#1858 request=19 input_tokens=97441 tools_offered=True tool_calls=40 ... result=refused
05:46:20Z stage reply refused: item=#1858 request=19 input_tokens=117440 tools_offered=True tool_calls=41 ... result=refused
05:52:37Z stage reply refused: item=#1858 request=13 input_tokens=78323 tools_offered=True tool_calls=25 ... result=refused
05:52:37Z stage gate returns: repo=dan-petty/devops-cli item=#1858 returns=3 result=refused version=0.116.1

The first line is the kept plan: request=1 and input_tokens=0 mean that no model request made it. The same shape is in the log for #3049, #3387 (2026-11-12 01:23Z) and #3389 (03:48Z) before that rollout. The stage-drought diagnosis ranks this cause at about 1 of 24 failed stage rounds; devops_cli_roadmap_stage_plan_record_total{result="hit"} had 13 points in 24 hours.

#4851 depends on this fix ("a refused kept plan uses no return").

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 12, 2026
  2. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

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

    • Priority: P2-Medium. The bug gives the planner one fewer run in production and blocks #4851, but the measured impact is moderate.
    • Value: Medium. The fix restores the intended planner retry budget and prevents avoidable stage failures.
    • Effort: Low. The change is a targeted correction in '_gated' with a small test update.
    • Related: feat(roadmap): extend stage gate returns while the plan improves #4851, which asks for a different change. Both items concern stage gate returns, but #4851 extends the returns while the candidate stops a refused kept plan from using one.
  3. dan-petty commented on Nov 12, 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. The bug wastes planner runs on kept plans but does not block the stage pipeline entirely.
    • Value: Medium. It saves one planner run per refused kept plan and makes the return count accurate.
    • Effort: Low. The fix is a targeted change in _gated to skip the return counter for a kept plan.
    • Related: feat(roadmap): extend stage gate returns while the plan improves #4851, which asks for a different change. Both concern stage gate returns in _gated, but #4851 extends the return count while the candidate stops a kept plan from consuming a return.
  4. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 12, 2026
  5. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 15: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/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