Skip to content

feat(roadmap): the stage job plans with a read-only investigation toolbox #3037

Description

@dan-petty

What happened

The stage job makes one structured model call on a fixed context: the issue, at most 10 cited files, at most 5 identifier greps of 20 lines and a tree of 50 files. The prompt says "You cannot run a command". 25 of 37 plans name files that do not exist, 17 ignore code or tests that exist.

What should happen

Acceptance criteria

  • The planner runs with the toolbox in a scratch clone and has no write tool and no network tool.
  • The score of A1 on the 37 cases is higher with the toolbox than without it.
  • The tool calls and tokens of a plan run are in the trace (A3).
  • A plan run stops at its budget and reports the reason.

Related: tracker for this set (filed with it), #2908 (issue workflow), #2867 (draft PR evaluator), #3005 (task kind), #3010 to #3015 (plan gates), #2919 (stuck-item metrics), #2953 (Ollama parser).

Proposed design

Problem statement

The stage job planner makes one model call on a fixed context of at most 10 files, 5 greps, and a 50-file tree. It cannot investigate the codebase. As a result, 25 of 37 plans name files that do not exist and 17 ignore code or tests that do exist. The planner needs a read-only investigation toolbox with a bounded budget so it can ground its plans in the actual code.

Acceptance criteria

Requirement: Read-only toolbox in sandbox

The planner SHALL run with read-only tools in a scratch clone and SHALL NOT have a write tool or a network tool.

Scenario: Planner tool set is read-only

  • WHEN the planner starts a plan run in the scratch clone
  • THEN the available tools are only list files, read file, read line range, grep, git log, git show, AST graph, callers of symbol, devops ai repomap, and read base spec

Requirement: Higher A1 score with toolbox

The score of A1 on the 37 cases SHALL be higher with the toolbox than without it.

Scenario: A1 score comparison

  • WHEN the 37 cases are scored with and without the toolbox
  • THEN the score with the toolbox is strictly greater than the score without

Requirement: Trace records tool calls and tokens

The trace of a plan run SHALL record every tool call and the total token count.

Scenario: Trace contains tool calls

  • WHEN a plan run completes
  • THEN the trace lists each tool call with its arguments and the total token count

Requirement: Budget stop with reason

A plan run SHALL stop at its budget and SHALL report the reason in the trace.

Scenario: Budget exhaustion

  • WHEN the tool call count or token count reaches the budget limit
  • THEN the run stops and the trace records the limit that was hit

Existing Tool Considered

No check has run. No single open-source tool covers the full need because the tool set includes project-specific tools (AST graph, devops ai repomap, OpenSpec spec reading). The agent loop with tool calling is already in the project (the implement job step infrastructure). The written cost is the tokens to define the read-only tool schemas, enforce the call and token budget, record the trace, and wire the stage job to the existing step loop, plus the elapsed time to integrate and test against the 37 cases.

Key questions

  • What tools does the planner have?: list files, read file or line range, grep, git log, git show, AST graph, callers of symbol, devops ai repomap, and read base spec. All are read-only. [sources: CONTEXT.md, docs/adr/0005-review-findings-come-from-tools-not-models.md]
  • How is the scratch clone created and sandboxed?: Use git worktree on the staged commit. The sandbox has no network and no write access. This matches the project pattern for tool runs. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]
    • Chosen: git worktree on staged commit. Project pattern. ADR 0005 states tools run on a worktree of the reviewed commit. Supports git log and git show.
    • Rejected: git clone --local. Heavier than a worktree. Creates a full copy. No advantage over a worktree for read-only access.
    • Rejected: git archive to a directory. No git history. Cannot run git log or git show. Rejected.
  • What is the tool call and token budget?: Configurable per run. Default: 30 tool calls and 50,000 output tokens. The budget is enforced by the agent loop. When either limit is hit, the run stops and the trace records the reason. (best practice) [sources: CONTEXT.md]
    • Chosen: Fixed default of 30 calls and 50k tokens, configurable. Bounded and testable. Matches the Step pattern in CONTEXT.md where inputs fit a token budget. Larger than the current fixed context (10 files + 5 greps + 50-file tree) so the agent can investigate more.
    • Rejected: Unbounded calls with a token cap only. A token cap alone does not stop a loop of cheap calls. The call count cap is needed to bound the number of round-trips.
    • Rejected: Per-tool limits only. More complex to configure and enforce. A total budget is simpler and covers the same risk.
  • Where does the trace go?: In the job record of the stage job run, alongside the plan output. The trace lists each tool call, its arguments, its output summary, and the total token count. (best practice) [sources: CONTEXT.md]
    • Chosen: Job record alongside the plan output. Consistent with the implement job pattern. One place to find the run record. The Service already stores job records.
    • Rejected: Separate trace file in the change folder. Two places to look. The change folder is for the plan, not the run record.
    • Rejected: Issue comment. Too verbose for a trace. Pollutes the issue history.
  • Does the planner have write or network access?: No. The planner has no write tool and no network tool. The sandbox enforces this. [sources: CONTEXT.md, docs/adr/0005-review-findings-come-from-tools-not-models.md]
  • How does the planner record evidence in Feasibility?: The planner writes the commands it ran and what they showed into the Feasibility section of the plan. This matches the existing requirement that Feasibility names how the premise was confirmed against the real system. [sources: AGENTS.md, docs/adr/0010-openspec-is-the-spec-and-change-proposal-layer.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/high
    effort/high
    on Nov 1, 2026
  2. dan-petty commented on Nov 1, 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/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P1-High. It targets the root cause of 25 of 37 plans naming non-existent files and 17 ignoring existing code.
    • Value: High. It directly fixes the two dominant failure modes of the stage job's plans.
    • Effort: High. It requires an agentic loop, a scratch clone, budget enforcement, tool plumbing, and integration with five existing gates.
    • Related: feat(roadmap): the stage job probes the premise at the staging commit and returns an item whose premise is false #3011, which asks for a different change. Both give the stage job read-only access to the codebase, but #3011 runs bounded probes before the model call while the candidate lets the model choose and sequence its own read-only tool calls.
  3. added
    priority/p1-high
    on Nov 1, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 1, 2026
  5. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 9f3b701 (see proposed design in issue body).

  6. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Staged: branch feat/3037-the-stage-job-plans-with-a, draft pull request #3089. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Define read-only tool set and sandbox: 4016 tokens
    2. Enforce budget and record trace: 3979 tokens
    3. Write evidence into Feasibility: 3943 tokens
    4. Update documentation: 3875 tokens
  7. added
    status/planned
    and removed
    status/ready
    on Nov 1, 2026
  8. added
    owner/agent
    status/in-progress
    and removed
    status/planned
    on Nov 2, 2026
  9. removed
    status/in-progress
    owner/agent
    on Nov 2, 2026
  10. added a commit that references this issue on Nov 2, 2026
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/highpriority/p1-highscope/roadmapsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions