Skip to content

refactor(roadmap): run stage on Coder in the runner image #6528

Not planned
2 of 2 issues completed
Not planned

Description

@dan-petty

Problem

The stage job succeeds in 47% of graded attempts (7 days to 2026-11-20). That is under the 60% band, so the owner rule asks for a re-architecture (#6519). Stage runs in the Service image, with read-only tools that cap each answer and with no shell. It returns one strict StageProposal object with one schema retry. About 20 gates run after the run, so the model never sees their results. Each refused plan starts a new run with no history.

Change

Run stage as a Coder agent in the runner image (#6417):

  • The agent writes the plan files itself. It runs devops openspec new, devops openspec check and openspec validate in its shell.
  • The cheap plan checks run inside the loop as output validators, so the model sees a refusal and fixes it.
  • A refused plan continues the same conversation.
  • Delete the hand-written stage read tools.

Add no new gate, cap or screen.

Acceptance

  • A test finds the stage agent built on Coder with the stock shell and no hand-written read tools.
  • 30 or more stage attempts on this version are graded. Every attempt counts.

Dependencies

Source: #6519

Alternatives check of 2026-11-20: not-applicable.
Class: refactor, no search.
Tool: none found.

Proposed design

Problem statement

The stage job succeeds in 47% of graded attempts in the 7 days to 2026-11-20. That is under the 60% band, so the owner rule asks for a re-architecture (#6519). Stage runs in the Service image with read-only tools, no shell and one strict StageProposal reply. The model never sees the plan checks, and each refused plan starts a new run. This item runs stage as a stock Coder agent in the runner image after #6417 and #5098, runs the plan checks in the loop, continues the same conversation after a refusal, and removes the hand-written stage read tools. The 30-attempt grade goes to a follow-up issue.

Acceptance criteria

Requirement: Stage agent uses stock Coder

The stage plan step SHALL build its agent from the stock Coder of pydantic-ai-harness 0.71.

Scenario: The stage step builds a Coder agent

  • WHEN A test runs the stage plan step with the scripted model of tests/support/model_script.py.
  • THEN The step builds a Coder agent from pydantic-ai-harness and sends it the plan prompt.

Requirement: Stage agent uses the stock Coder tool list

The stage agent MUST use the stock tool list of Coder, including its shell, and MUST hold no hand-written stage read tool.

Scenario: The tool list holds the stock shell and no stage read tool

  • WHEN A test builds the tool list of the stage agent.
  • THEN The list equals the stock tool list of Coder and the stage module exposes no hand-written stage read tool.

Requirement: Plan checks use RequireVerification

The stage step SHALL run the plan checks through RequireVerification of pydantic-ai-harness 0.71.

Scenario: The verification list holds the plan checks

  • WHEN A test builds the verification configuration of the stage step.
  • THEN The configuration holds devops openspec check, openspec validate and devops roadmap plan-recheck --source . --branch HEAD.

Requirement: A refused plan continues the same conversation

The stage step SHALL return each RequireVerification refusal to the same agent conversation.

Scenario: The agent fixes a refused plan in one conversation

  • WHEN A test gives the stage step a first plan that fails a plan check and a second plan that passes.
  • THEN The step opens one agent conversation, sends the refusal text to it, and ends with the passing plan.

Requirement: Stage prompt names the plan commands

The stage prompt MUST name devops openspec new, devops openspec check, openspec validate and devops roadmap plan-recheck --source . --branch HEAD.

Scenario: The stage prompt lists the plan commands

  • WHEN A test builds the stage prompt.
  • THEN The prompt holds the four command lines.

Requirement: Stage result comes from the written change

The stage step SHALL build its StageProposal from the files of the change folder that the agent wrote.

Scenario: The written change folder becomes the proposal

  • WHEN A test runs the stage step with an agent that writes a change folder.
  • THEN The step reads the files of that folder with read_change of src/devops_cli/roadmap/plan_read.py and returns the StageProposal it gives.

Existing Tool Considered

The alternatives check in the issue body records not-applicable on 2026-11-20 and names no external tool. The change uses the open, maintained pydantic-ai-harness 0.71 that the repository already installs. Its Coder gives the stock shell agent, and its RequireVerification gives the in-loop plan checks. The library lacks the stage prompt, the plan-check command list, the StageProposal read-back and the removal of the hand-written stage read tools; this item adds those.

Key questions

  • Which open, maintained tool or library covers the need?: The alternatives check in the issue body records not-applicable on 2026-11-20 and names no external tool. The change uses the open pydantic-ai-harness 0.71 that the repository already installs. Its Coder gives the stock shell agent, and its RequireVerification gives the in-loop plan checks. The library lacks the stage prompt, the plan-check command list, the StageProposal read-back and the removal of the hand-written stage read tools; this item adds those. (best practice) [sources: pyproject.toml:41, src/devops_cli/roadmap/tools.py, tests/support/model_script.py, src/devops_cli/roadmap/plan_read.py]
    • Chosen: Use pydantic-ai-harness 0.71. The repository already uses its Coder, and it gives the in-loop verification.
    • Rejected: Build a custom stage harness. The installed library already gives the agent shell and the verification loop.
  • Where do the cheap plan checks run?: In the agent loop through RequireVerification of pydantic-ai-harness 0.71. The checks are devops openspec check, openspec validate and devops roadmap plan-recheck --source . --branch HEAD. A refusal returns to the same conversation. (best practice) [sources: src/devops_cli/roadmap/plan_check.py:530, tests/roadmap/test_roadmap_plan_recheck.py, tests/support/model_script.py]
    • Chosen: RequireVerification of pydantic-ai-harness 0.71. The installed upstream library gives the in-loop verification and returns a refusal to the same conversation.
    • Rejected: Custom output validators. The installed library already gives the loop, so custom code adds cost.
    • Rejected: run_command with ShellRefusal. The stock Coder shell replaces this policy path.
  • How does the stage step build its StageProposal after the agent writes the files?: It reads the files of the written change folder with read_change of src/devops_cli/roadmap/plan_read.py. The gates keep the StageProposal shape. (best practice) [sources: src/devops_cli/roadmap/plan_read.py:647, src/devops_cli/roadmap/stage/stage_change.py:701, src/devops_cli/roadmap/plan_check.py:530]
    • Chosen: Read the change folder with read_change. read_change takes the files of a change folder as text and returns the plan in the shape that the gates read.
    • Rejected: Parse the model reply. The agent writes the files, so the reply is no longer the source of the plan.
  • How does the item check the 60% band?: A follow-up issue grades 30 or more stage attempts on the released version. This item delivers the code and adds no measurement. (best practice) [sources: CONTEXT.md, docs/roadmap/job-success.md]
    • Chosen: Defer the grade to a new issue. The attempts need the release and elapsed time, and a pull request cannot deliver them.
    • Rejected: Grade the attempts in this item. The item cannot wait for 30 released attempts inside one pull request.
  • Which pull request order and base does the item use?: One pull request from main, after feat(k8s): run the stage job in the runner image #6417 and build(deps): move pydantic-ai to 2.68 and its retry parts #5098 merge. The item does not stack on feat(k8s): run the stage job in the runner image #6417. (best practice) [sources: CONTEXT.md, k8s/devops/cronjob-stage.yaml:87]
  • What does the stage planner use today?: A read-only toolbox with no shell and no write tool. The base set has nine tools; extended adds references, read_issue and find_issues; each set has read_comment. [sources: src/devops_cli/roadmap/stage/stage_tools.py:1]
  • Which image does the stage Job run today?: The Service image. k8s/devops/cronjob-stage.yaml:87 names ghcr.io/dan-petty/devops-cli/service; feat(k8s): run the stage job in the runner image #6417 moves the stage Job to the runner image. [sources: k8s/devops/cronjob-stage.yaml:87, docs/ROADMAP_WORKFLOW.md:455]
  • How does the stage agent get its shell?: It uses the stock shell of Coder in the runner image. The item adds no shell policy, no cap and no screen. (best practice) [sources: src/devops_cli/roadmap/tools.py, src/devops_cli/roadmap/implement/implement_shell_policy.py:126]
    • Chosen: Use the stock Coder shell. The stock Coder shell replaces the policy path, and the item adds no new cap.
    • Rejected: Add openspec to SHELL_PROGRAMS. The stock Coder shell already gives the command, so this adds a second policy path.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#6417, #5098

Moved to new items

#6637

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    type/refactor
    source/agent
    scope/roadmap
    status/new
    effort/medium
    value/high
    on Nov 20, 2026
  2. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. The stage job fails 53% of graded attempts, an increased error rate in a core pipeline stage.
    • Related: feat(k8s): run the stage job in the runner image #6417, which asks for a different change. Both target running stage in the runner image, but #6417 switches the k8s Job template while the candidate re-architects the agent to a Coder with in-loop validation and conversation continuation.
  3. added
    priority/p1-high
    on Nov 20, 2026
  4. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  5. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    Owner decisions (2026-11-20, direct answers), after a scoping pass of this item:

    1. Order. PR 1 is feat(k8s): run the stage job in the runner image #6417: the stage CronJob moves to the runner image, with no shell and no engine change. It is in build now. PR 2 is this item. It is built from main after feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702 part B merges, not stacked.
    2. Shell. The stage agent gets a real shell only after feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702 part B. The agent phase then holds no App key, and the publish module of B pushes. Today stage pushes with plain git from the agent tree, which is safe only while the agent has no shell (feat(roadmap): run the implement agent shell in a real sandbox #2695).
    3. Plan checks in the loop. Use upstream RequireVerification of pydantic-ai-harness (0.71, installed). The checks are devops openspec check, openspec validate and devops roadmap plan-recheck --source . --branch HEAD. This replaces three parts of the refined design above: the custom output validators, run_command with ShellRefusal, and the addition of openspec to SHELL_PROGRAMS. The agent is stock Coder (not slots.py).
    4. Verify pass. Owner: "this should be a separate job that runs outside of the plan/implement job against pull requests". PR 2 removes the verify pass from the stage Job. The review step (src/devops_cli/roadmap/steps/review.py, feat(roadmap): a review job gives each bot PR its verdict #5969) already gives each bot pull request, a plan included, one verdict. It runs in mode plan now. A check of the verify pass that the review step does not make goes to the review step, in its own issue.
  6. added
    owner/agent
    on Nov 20, 2026
  7. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  8. added
    status/ready
    and removed
    status/new
    on Nov 21, 2026
  9. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  10. added
    status/in-progress
    and removed
    status/ready
    on Nov 21, 2026
  11. dan-petty commented on Nov 24, 2026

    @dan-petty
    OwnerAuthor

    Split issue #6705 replaced this item. Pull request #6883 merged #6705 into main in commit 4431302. The change ran the stage agent on stock Coder with the required verification checks. This item closes as not planned per AGENTS.md Rule 2.

  12. removed
    status/in-progress
    owner/agent
    on Nov 24, 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/mediumpriority/p1-highscope/roadmapsource/agenttype/refactorvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions