Skip to content

fix(roadmap): the stage job fails when the window starves the planner #3880

Closed

Description

@dan-petty

Problem

The stage job of the Service fails every item since 2026-11-06 20:34Z. The model deepseek-v4.1-flash-1017 answers with the placeholder x in every text field of the plan (why, existing_tool, feasibility, the implementation of group 1, and a changes path), or with a reply that breaks the schema. The deployed ConfigMap sets ai.tasks.analysis.context_window to 65536, and the task stage inherits it (k8s/devops/configmap.example.yaml).

Evidence (2026-11-07, devops roadmap stage --item 3224 --plan, live item, model deepseek-v4.1-flash-1017, ai.max_retries 1, toolset extended, one run for each row):

Window of analysis Result Plan requests Tool calls Input tokens Output tokens
65536 Failed, x in every text 5 and 3 (two tries) 6 and 4 213,898 and 120,930 952 and 732
262144 Staged, 5 task groups 23 40 1,494,303 15,170

Only the window changed between the two rows. The first request of a plan counts about 38,000 tokens. At 65536 the hook of the run stops the tools at 49,152 tokens, after 2 or 3 requests. The model then has read almost nothing, and it answers with x. The check refuses the reply, the job sends it back once, the second reply is x again, and the item fails. The run needs about 1.5 million input tokens in 23 requests, and it stops its tools at three quarters of the window.

ai.max_retries is not the cause: the run at 262144 used 1, and it staged. The reply returns of the plan run are fixed (_REPLY_RETURNS in src/devops_cli/roadmap/stage.py). The live item, the prompt and the gateway group were the same in both rows.

docs/roadmap/stage.md says that the model "writes a plan about code that it did not read" when the window ends the tools. In fact it writes no plan.

Expected

  1. The window of the ConfigMap fits the model. The model has max_input_tokens 1,048,576, and the smallest fp8 provider of the group offers 256,000 tokens, the window that ai.tasks.implement already uses. The analysis window in the example is 256000. The verification window moved to fix(k8s): set the verification window in the example ConfigMap #3911. A person applies the value to the deployed ConfigMap.
  2. The stage job fails at once, and names the setting, when the window ends the tools of a plan run before the model has made a minimum number of tool calls. The error is not a list of placeholder faults.
  3. A test fails if the example ConfigMap sets a planner window that is smaller than the run needs.

Acceptance criteria

  • The example ConfigMap sets ai.tasks.analysis.context_window to 256000, with a comment that gives the reason. The window of the task verification moved to fix(k8s): set the verification window in the example ConfigMap #3911, because the pull request of feat(k8s): the Service uses one model for every chat slot #3874 edits the lines of that task in the same file.
  • A plan run whose tools end at the window before a minimum number of tool calls raises RoadmapStageError that names ai.tasks.stage.context_window (or the parent analysis), and the job records that error and not the placeholder faults.
  • A test fails when the planner window of the example ConfigMap is below the minimum that the first request and the minimum tool turns need.
  • docs/roadmap/stage.md states what the model does when the window ends the tools.

Existing tool considered

The change uses the settings and the hook that exist (PrepareTools of pydantic-ai in src/devops_cli/roadmap/refine_investigation.py). No new library is needed.

Related

#3241 (tune the stage planner caps from run data), #3874 (the Service uses deepseek-v4.1-flash-1017 for every chat slot; it edits the same example ConfigMap), #3523 (the plan request leaves room for the planner tools).

Proposed design

Problem statement

The stage job fails every item when the context window of the analysis task is 65536. The window ends the planner tools after 2 or 3 requests, the model returns x in every text field, and the job reports placeholder faults. The change sets the example analysis and verification windows to 256000, fails a starved plan run at once with a RoadmapStageError that names the setting, guards the example window with a test, and corrects docs/roadmap/stage.md.

Acceptance criteria

Requirement: Example ConfigMap planner windows

The example ConfigMap SHALL set ai.tasks.analysis.context_window and ai.tasks.verification.context_window to 256000 with a comment that gives the reason.

Scenario: Example ConfigMap sets both windows

  • WHEN A test reads k8s/devops/configmap.example.yaml.
  • THEN The test finds both context windows set to 256000 and a comment above them that names the smallest fp8 provider window of the gateway group.

Requirement: Window starvation error

A starved plan run SHALL raise RoadmapStageError that names ai.tasks.stage.context_window and its parent ai.tasks.analysis.context_window.

Scenario: Window stops tools before the minimum

  • WHEN A test plans an item with a toolbox client whose run trace records RunLimit.WINDOW and fewer than CONST_ROADMAP_STAGE_MIN_TOOL_CALLS tool calls.
  • THEN The planner raises RoadmapStageError whose message names both settings, and _plan_each records that message as the item's failure reason instead of a placeholder problem.

Requirement: Planner window minimum test

A test SHALL fail when the example planner window is below CONST_ROADMAP_STAGE_MIN_CONTEXT_WINDOW.

Scenario: Planner window below the minimum

  • WHEN A test calls the example-window guard with the text of k8s/devops/configmap.example.yaml and with a copy whose ai.tasks.analysis.context_window is 65536.
  • THEN The guard passes on the example and fails on the copy with a message that names ai.tasks.analysis.context_window and the minimum 256000.

Requirement: Stage documentation of a starved window

The stage documentation SHALL state that a starved window makes no plan and SHALL name the minimum and the setting error.

Scenario: Documentation states the starved-window behavior

  • WHEN A test reads the section 'The window of the plan run' of docs/roadmap/stage.md.
  • THEN The section states that the model writes no plan, that the job raises RoadmapStageError naming the setting when fewer than CONST_ROADMAP_STAGE_MIN_TOOL_CALLS tool calls run, and that the example window is 256000.

Existing Tool Considered

pydantic-ai, the open and maintained model library that the project pins in uv.lock, covers the tool-stopping hook with PrepareTools in src/devops_cli/roadmap/refine_investigation.py:439; it records RunLimit.WINDOW in RunTrace (src/devops_cli/roadmap/agent_run.py:174) but has no check that the window ended the tools before enough calls. The stage planner adds that check in src/devops_cli/roadmap/stage.py, so no new library and no build cost are needed. No alternatives check has run.

Key questions

  • Which setting names the planner window, and which name must the error use?: task_window("stage") reads the window of the stage task from ai.for_task (src/devops_cli/roadmap/stage.py:1532). _TASK_PARENTS maps stage to analysis (src/devops_cli/config/settings.py:619), so a stage field that is unset takes the analysis value; the deployed setting is ai.tasks.analysis.context_window (k8s/devops/configmap.example.yaml:29). The error names ai.tasks.stage.context_window and its parent ai.tasks.analysis.context_window, so it is right for either source. [sources: src/devops_cli/roadmap/stage.py:1532, src/devops_cli/config/settings.py:619, k8s/devops/configmap.example.yaml:27, docs/roadmap/stage.md:49]
  • What minimum number of tool calls must a plan run make before the window may end its tools?: Eight tool calls (CONST_ROADMAP_STAGE_MIN_TOOL_CALLS). That is two turns of the four-call reserve that the hook keeps for a last turn (CONST_ROADMAP_REFINE_INVESTIGATION_TURN_CALLS), so the model can make a turn of calls, read the answers, and make another turn before the window may end the tools. It is above both failed counts (6 and 4) and far below the 40 calls of the successful run. (best practice) [sources: src/devops_cli/config/constants.py:3086, src/devops_cli/roadmap/refine_investigation.py:329, docs/roadmap/stage.md:59]
    • Rejected: 4 tool calls. One failed row made 6 calls, so a threshold of 4 does not catch it.
    • Rejected: 6 tool calls. One failed row made exactly 6 calls, so a threshold of 6 does not catch it.
    • Chosen: 8 tool calls. It is two turns of the 4-call reserve, it catches both failed rows (6 and 4 calls), and it is far below the 40 calls of the successful run.
    • Rejected: 12 tool calls. It would fail a small plan that uses 10 calls and still has room, and the evidence gives no need above 8.
  • Where should the minimum-tool-call check run?: In _Planner._ask, immediately after chat_structured returns and before the reply reaches _settle. _ask is the one place where every plan run returns (the first reply, its retry, and a repair round), it can take the target to raise _stage_error, and it runs before _settle computes the placeholder problems. The check reads self._traces[-1] when the planner holds the toolbox traces, as the job and devops roadmap stage --plan do; the golden-set eval passes a client that keeps its own trace, so its runs are unchanged. (best practice) [sources: src/devops_cli/roadmap/stage.py:1081, src/devops_cli/roadmap/stage.py:919, src/devops_cli/roadmap/stage.py:1103]
    • Rejected: In ToolboxClient after the run. The toolbox client serves the verifier too, has no item number, and cannot raise the item's RoadmapStageError.
    • Rejected: In _Planner.plan after the plan run. The plan run returns inside _gated, so plan runs only after _settle has already raised the placeholder faults.
    • Chosen: In _Planner._ask right after chat_structured. It is where every plan run returns, it has the target for _stage_error, and it runs before _settle.
  • How should the error name the setting when stage inherits from analysis?: The message names ai.tasks.stage.context_window and the parent ai.tasks.analysis.context_window. This covers a set stage window and an inherited analysis window. (best practice) [sources: docs/roadmap/stage.md:49, k8s/devops/configmap.example.yaml:27, src/devops_cli/config/settings.py:619]
    • Rejected: Name only ai.tasks.stage.context_window. The deployed ConfigMap sets the parent, so a person may look for a missing stage key.
    • Rejected: Name only ai.tasks.analysis.context_window. A person may set the stage task directly.
    • Chosen: Name both settings. It is correct for either source.
  • What should the example ConfigMap test assert for the planner window?: The guard asserts that ai.tasks.analysis.context_window in k8s/devops/configmap.example.yaml is at least CONST_ROADMAP_STAGE_MIN_CONTEXT_WINDOW, 256000: the smallest window that an fp8 provider of the gateway group offers and the window that ai.tasks.implement already uses. The example itself sets 256000; a larger window is valid, because the group allows 1,048,576. (best practice) [sources: k8s/devops/configmap.example.yaml:34, k8s/README.md:655, k8s/llm/gateway/config.yaml:193]
    • Rejected: Assert equality to 256000. A larger window is valid and the model allows 1,048,576.
    • Rejected: Assert at least 131072. It is below the 256000 window that the smallest fp8 provider of the group offers.
    • Chosen: Assert at least 256000. It matches the provider and the working setting; the example itself sets 256000.
  • Should the example set the verification window explicitly?: Yes. verification is not a child of analysis in _TASK_PARENTS, so an unset window falls back to the top-level default of 32,768 tokens; the verifier's request is then fitted to tool_stop(32768) - CONST_ROADMAP_STAGE_TOOL_RESERVE_TOKENS, and it reads only a few of the cited files. The model claude-sonnet-5-5 allows 1,000,000 tokens, so the example sets ai.tasks.verification.context_window to 256000. (best practice) [sources: src/devops_cli/config/settings.py:619, src/devops_cli/config/defaults.py:84, k8s/llm/gateway/config.yaml:154, k8s/devops/configmap.example.yaml:37]
    • Rejected: Let verification inherit the analysis window. verification does not inherit from analysis, so it would keep the 32,768-token default and the pass would read few cited files.
    • Chosen: Set the verification window explicitly. The issue requires it, the model allows 1,000,000 tokens, and the value stays visible.
  • Should the live deployed ConfigMap apply be part of this issue?: No. Argo CD does not apply ConfigMap devops-cli-config; a person runs devops k8s deploy-stack --stack devops and restarts the pod (k8s/README.md:754). The repository change, its test and its documentation can merge without that action, and only a person with cluster access can apply the value, so the apply is deferred to a separate chore issue. (best practice) [sources: k8s/README.md:754, docs/ROADMAP_WORKFLOW.md:325]
    • Rejected: Keep the live apply in this issue. The issue would wait on a person and a cluster action that a pull request cannot do.
    • Chosen: Defer the live apply to a separate issue. The code change is workable and testable now, and the apply is a person's step.
  • Does ai.max_retries need a change?: No. The successful run used ai.max_retries 1, and the issue evidence says the setting is not the cause. The example keeps 1. [sources: k8s/devops/configmap.example.yaml:22]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 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: P1-High. The stage job fails every item since 2026-11-06, blocking the entire pipeline.
    • Value: High. Every staged item fails, so no roadmap planning can complete.
    • Effort: Medium. Requires a ConfigMap value change, an error-raising code path, a test, and a docs edit.
    • Related: fix(roadmap): a plan request leaves room for the planner tools #3477, which asks for a different change. Both address the window ending the planner's tools, but #3477 fixed the first-request size while the candidate fixes the overall window, adds a named error, and a test.
  3. added
    priority/p1-high
    owner/agent
    on Nov 7, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 163a5c2 (see proposed design in issue body).

    Moved to new items: #3903.

  6. added
    status/in-progress
    and removed
    status/ready
    on Nov 7, 2026
  7. removed
    status/in-progress
    owner/agent
    on Nov 7, 2026
  8. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 05:06 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/p1-highscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions