Skip to content

fix(roadmap): a plan request leaves room for the planner tools #3477

Closed

Description

@dan-petty

Problem

The stage planner calls no tool. The first request is larger than the limit at which the run hook removes the tools, so the first reply of the model is the output tool. The model then writes facts about code that it did not read.

The cause of the onset is unverified. The first zero-call run follows #3178 (context gets tests and callers) and #3176 (probes). These two are the suspects. #3223 merged at 16:30Z, after #3076, and its diff changes no window share and no configmap value.

Expected

A typical plan request stays below the tool limit and leaves room for tool answers. The planner reads capabilities on demand. This issue adds no metric: #3240 owns them. #3246, #3258 and #3428 add context to the same request, so they must not merge first, or they must fit the new bound.

Acceptance criteria

  • A test builds a plan request with the context at its cap. The request is below the limit, with a stated reserve for tool answers.
  • A test shows that the context and the capabilities together stay under one stated share of the window.
  • The stage request sends capabilities through read_spec on demand, or in another form that meets the bound.
  • The context_window value of analysis is documented with its source. k8s/llm/gateway/config.yaml:260 sets max_input_tokens 1048576 for deepseek-v4.1-flash-1017, the model of analysis.
  • A test sets the window to 1,048,576 and shows that the context and body caps do not grow.
  • RunTrace (agent_run.py:145) records the tools offered for each request.
  • A test shows that the stage comment states the reason for a run with no tool call.
  • A live run on 5 Ready items shows tool calls in each plan.
  • A measure states whether the refine request (refine.py:2032, the same window) passes the limit.

Existing tool considered

pydantic-ai PrepareTools already holds the hook (refine_investigation.py:390). read_spec already exists (stage_tools.py:232). No new tool.

Related

Related: #3241, #3246, #3258, #3428, #3266, #3240, #3207, #3239

Proposed design

Problem statement

The stage planner makes no tool call because the first request exceeds the limit at which the run hook removes the tools. The model then writes facts about code that it did not read. The fix keeps the request below the limit, reserves tokens for tool answers, and reads capabilities on demand.

Acceptance criteria

Requirement: Plan request reserve

The first plan request MUST stay below the tool-removal limit and leave at least 8,192 tokens for tool answers.

Scenario: Context at cap

  • WHEN A test builds a plan request with the context at its 20,480-token cap and the body at its 8,192-token cap.
  • THEN The request counts at most 40,960 tokens and stays at least 8,192 tokens below the tool-removal limit.

Requirement: Context and capability share

The context and the capability text of one plan request MUST stay under 50 percent of the configured window.

Scenario: Capability read on demand

  • WHEN A test adds the largest capability text that read_spec returns to the context at its cap.
  • THEN The combined token count stays below 32,768 tokens for the 65,536-token window.

Requirement: Capabilities on demand

The stage request MUST send capabilities through read_spec on demand and MUST NOT include the full capability JSON in the first request.

Scenario: First request excludes capabilities

  • WHEN A test builds the first plan request with the stage toolset.
  • THEN The request holds the read_spec tool and holds no full capability JSON.

Requirement: Analysis window documentation

The documentation MUST state the analysis context_window value and its source.

Scenario: Documentation check

  • WHEN A test reads the analysis documentation.
  • THEN The text states context_window 65536 from k8s/devops/configmap.example.yaml:29 and cites max_input_tokens 1048576 from k8s/llm/gateway/config.yaml:260.

Requirement: Fixed caps on a large window

The context and body caps MUST stay fixed when the configured window is 1,048,576 tokens.

Scenario: Large window

  • WHEN A test sets context_window to 1,048,576 and builds a plan request.
  • THEN The context cap stays 20,480 tokens and the body cap stays 8,192 tokens.

Requirement: RunTrace tools offered

RunTrace MUST record the tools offered for each model request.

Scenario: Trace of a scripted run

  • WHEN A scripted plan run makes two requests with different offered tools.
  • THEN The RunTrace holds the offered tool names for each request.

Requirement: No-tool reason in stage comment

The stage comment MUST state the reason for a run with no tool call.

Scenario: No tool call

  • WHEN A scripted plan run offers no tool and returns an output.
  • THEN The stage comment states that the request reached the tool-removal limit.

Requirement: Refine request measure

A test MUST measure the refine request at the same window and state whether it stays below the tool-removal limit.

Scenario: Refine request count

  • WHEN A test builds the refine request with context_window 65536.
  • THEN The test writes the token count and the 49,152-token limit to its output.

Existing Tool Considered

No alternatives check has run. pydantic-ai PrepareTools already holds the hook and read_spec already exists; they cover the need. They lack the request-size bound and on-demand capability delivery that this issue adds, so no new tool is needed.

Key questions

  • What caps and reserve keep the plan request below the tool limit?: Use fixed caps of 20,480 tokens for context and 8,192 tokens for body. Cap the first plan request at 40,960 tokens and keep at least 8,192 tokens below the 49,152-token tool-removal limit for the 65,536-token window. (best practice) [sources: src/devops_cli/roadmap/refine_investigation.py:293, src/devops_cli/roadmap/stage.py:802, k8s/devops/configmap.example.yaml:29]
    • Rejected: Keep the window fractions. The 32,768-token context cap and the 16,384-token body cap with prompts exceed the 49,152-token limit.
    • Chosen: Use fixed caps. The 20,480-token context cap and the 8,192-token body cap leave 16,685 tokens below the limit.
    • Rejected: Remove the tool limit. The model then exceeds the model window and the run stops.
  • How does the stage request deliver capabilities without including them all?: Use the existing read_spec tool. The first request excludes the full capability JSON, and read_spec returns at most 8,192 tokens of capability text. (best practice) [sources: src/devops_cli/roadmap/stage_tools.py:232, src/devops_cli/roadmap/refine_investigation.py:390]
    • Rejected: Keep capabilities inline. The full JSON adds about 31,270 tokens and pushes the request over the limit.
    • Rejected: Add a new capability tool. read_spec already exists and covers the need.
    • Chosen: Use read_spec on demand. It removes the full JSON from the first request and returns one spec at a time.
  • Which context window and source document the analysis task?: The active setting is context_window 65536 in k8s/devops/configmap.example.yaml:29. The gateway model deepseek-v4.1-flash-1017 has max_input_tokens 1048576 in k8s/llm/gateway/config.yaml:260. Document both values and keep the request caps fixed. [sources: k8s/devops/configmap.example.yaml:29, k8s/llm/gateway/config.yaml:260]
  • What records the tools offered for each request?: Add the offered tool names to RunTrace for each model request. The stage and refine runs pass the trace to the comment and the log. (best practice) [sources: src/devops_cli/roadmap/agent_run.py:145, src/devops_cli/roadmap/stage.py:802, src/devops_cli/roadmap/refine_investigation.py:390]
  • How does the stage comment state the reason for a run with no tool call?: The stage comment reads the RunTrace of the plan run. It states that the request reached the tool-removal limit when no tool was offered. (best practice) [sources: src/devops_cli/roadmap/agent_run.py:145, src/devops_cli/roadmap/stage.py:802]
    • Rejected: Keep the generic message. The message does not name the cause.
    • Chosen: State the trace reason. The trace holds the offered tools and the request count.
    • Rejected: Fail the run. A run with no tool call can still return a valid plan.
  • Does the refine request pass the same limit?: Add an offline measure that builds the refine request at context_window 65536. The measure reports its token count and the 49,152-token limit; this issue does not change refine behavior. (best practice) [sources: src/devops_cli/roadmap/refine.py:2032, src/devops_cli/roadmap/refine_investigation.py:293]
    • Rejected: Change refine in this issue. The body limits this fix to the stage request and asks only for a measure of refine.
    • Chosen: Measure refine without a change. The measure answers the question and keeps the fix in one pull request.
    • Rejected: Ignore refine. The body requires the measure.

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 4, 2026
  2. dan-petty commented on Nov 4, 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. 38 of 38 plan runs report no tool call, so the planner cannot read code and writes facts about unread code.
    • Value: High. The planner is the core of the roadmap pipeline; without tool access it produces unreliable plans.
    • Effort: Medium. Requires restructuring capability delivery, adding tests for token bounds, documenting config, and adding RunTrace fields.
    • Related: fix(roadmap): Refuse Feasibility claims the run did not support #3266, which asks for a different change. Both address the planner making no tool call, but the candidate fixes the token window so tools are offered, while #3266 adds a gate that rejects plans citing tools when none were called.
  3. added
    priority/p1-high
    on Nov 4, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 4, 2026
  5. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 46cf288 (see proposed design in issue body).

    Moved to new items: #3489.

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

    @devops-cli-service
    Contributor

    Live since 2026-11-04 22:15 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