Skip to content

feat(roadmap): stage prepare hands the agent its GitHub reads #6831

Done

Description

@dan-petty

Problem

The stage planner reads GitHub while it plans: read_issue and find_issues (planner and verifier), the open pull requests that meet a path the plan names, and the files of a pull request that the body names. In the 14 days to 2026-11-23 the planner made 931 read_issue and 442 find_issues calls that returned data, and the verifier made 396 and 151, about 3.4 calls per planned attempt. The prompt of the extended toolset tells the model to read each #N and to search the issues before the plan names what it depends on.

From #6814 the agent phase of stage runs in a container that holds no GitHub credential, and the agent of #6705 holds none either. Each read then answers "GitHub could not be read", so the plans miss done or parked items, decisions in comments, overlaps and dependencies.

Change

  • prepare reads this data before the agent phase and writes it to the run folder as files:
    • each issue that the item body names, with its comments;
    • the open pull requests and the paths that each one changes;
    • the files of each pull request that the body names;
    • a snapshot of the open issues (number, title, labels, body) for a local search.
  • The read tools of the agent phase answer from these files. The agent of refactor(roadmap): the stage agent is stock Coder #6705 reads the same files with its shell.
  • With --phase all nothing changes.

Acceptance criteria

  • A test of a separate agent phase with no credential gets the same answers from read_issue, the open-pull overlap and the files of a named pull request as --phase all gets.
  • A test shows that find_issues in a separate agent phase finds an open issue by a word of its title or body.

Dependencies

Source

Source: #6813

Alternatives check of 2026-11-23: in-use.
The repository already uses this tool.
Tool: cli/cli (https://github.com/cli/cli), MIT, last activity 2026-11-20, maintained.
Reason: Searches found no tool that snapshots GitHub reads for an agent with no credential; the GitHub CLI covers the fetching half (issue with comments, PR files, open-PR paths, issue list as JSON), while the run-folder store and file-backed read tools stay project code.

Covers:

  • Fetches one issue with its comments as JSON
  • Lists open pull requests with their changed paths
  • Reads the files of a named pull request
  • Lists open issues with number, title, labels and body

Lacks:

  • No on-disk snapshot that later reads answer from
  • No local search over the issue snapshot
  • Needs a live GitHub credential at each call
  • No run-folder layout or read-tool adapters

Proposed design

Problem statement

The agent phase of stage runs in a container with no GitHub credential. The stage planner reads issues, open pull requests and pull-request files while it plans, so each read fails. The plan then misses done items, decisions in comments, overlaps and dependencies. The agent phase now uses the stock Coder and offers no custom GitHub read tool. prepare will fetch these reads with the Service token and write them under work/github/. The stock Coder will read the files with its shell and the roadmap_stage_coder.md prompt.

Acceptance criteria

Requirement: Prepare writes named issues with comments

The prepare phase SHALL write each issue that the item body names, with its comments, to work/github/issues/<number>.json before the agent phase starts.

Scenario: Two named issues

Requirement: Prepare writes open pull requests with paths

The prepare phase SHALL write each open pull request with the paths that it changes to work/github/pulls.json.

Scenario: Two open pull requests

  • WHEN a test runs prepare with a fake client that returns two open pull requests, one of which changes src/app.py
  • THEN work/github/pulls.json holds both numbers and titles, and the paths of the second include src/app.py

Requirement: Prepare writes files of a named pull request

The prepare phase SHALL write the files of each pull request that the item body names to work/github/pull-files/<number>.json.

Scenario: Named pull request

Requirement: Issue index is newline-delimited and bounded

The prepare phase SHALL write the open issues to work/github/issue-index.jsonl as one JSON object per line, with at most 1000 records and a body of at most 500 characters.

Scenario: Repository with 3000 open issues

  • WHEN a test runs prepare with a fake client that returns 3000 open issues, each with a body of 2000 characters
  • THEN work/github/issue-index.jsonl holds at most 1000 lines, each body is at most 500 characters, and the file is at most 1 MiB

Requirement: A shell search finds an issue in the index

The open-issue index MUST let a shell search find an open issue by a word of its title or body.

Scenario: Word that only one open issue has

Requirement: Coder prompt names the snapshot files

The stage Coder prompt roadmap_stage_coder.md SHALL name work/github/issues/, work/github/pulls.json, work/github/pull-files/ and work/github/issue-index.jsonl and tell the Coder to read them with its shell.

Scenario: Prompt for the stock Coder

  • WHEN a test builds the stage Coder prompt
  • THEN the prompt holds each path and a shell command that searches work/github/issue-index.jsonl

Requirement: Agent phase offers no custom GitHub read tool

The --phase agent stage run SHALL offer only the stock Coder tools and no read_issue or find_issues tool.

Scenario: Agent phase tool list

  • WHEN a test runs the stage agent phase with a fake Coder
  • THEN script.tools_offered equals stock.tools_offered

Requirement: Phase all keeps the live reads

A run of --phase all MUST keep the live GitHub reads and write no file under work/github/.

Scenario: Phase all run

  • WHEN a test runs --phase all for an item with a fake GitHub client
  • THEN the client receives the issue reads and no file under work/github/ is written

Requirement: A failed read does not stop prepare

The prepare phase SHALL record a failed GitHub read in work/github/errors.json and continue with the other reads.

Scenario: One read fails

Existing Tool Considered

The alternatives check of 2026-11-23 in the issue body gives cli/cli (MIT, maintained) the verdict in-use. That block lists what the tool covers and lacks. prepare uses cli/cli for the fetches. The project code fills the lacks that the block names: the work/github/ snapshot store, the newline-delimited issue index and the Coder prompt that reads them with the shell. This is about 150 lines of Python and Markdown: about 40k tokens to build, about 10k tokens a month to keep and fix, over about 1 day.

Key questions

  • Which files does prepare write, and where does the stock Coder read them?: prepare writes work/github/issues/<n>.json, work/github/pulls.json, work/github/pull-files/<n>.json and work/github/issue-index.jsonl. The stock Coder reads these files with its shell. The prompt roadmap_stage_coder.md names them. (best practice) [sources: src/devops_cli/roadmap/stage/stage_job_phases.py:689, src/devops_cli/roadmap/stage/stage_agent.py:105, openspec/specs/roadmap-stage/phases/spec.md:60, tests/roadmap/stage/test_roadmap_stage_agent.py:104]
    • Chosen: One file for each read under work/github/. The stock Coder reads the run folder with its shell, and refactor(roadmap): the stage agent is stock Coder #6705 uses work/ for the agent copy.
    • Rejected: Write under state/github/ and copy to work/github/. The agent phase needs no second copy, and the extra copy adds a failure mode.
    • Rejected: Write all reads to one file work/github.json. The issue index alone can reach the run-file size limit.
  • How does the open-issue index stay within the run-file size limit?: It has its own file, work/github/issue-index.jsonl. It holds at most 1000 records, cuts each body to 500 characters, and stays at most 1 MiB. (best practice) [sources: src/devops_cli/roadmap/stage/stage_tools.py:419, docs/roadmap/stage.md:50]
    • Chosen: A separate newline-delimited index with at most 1000 records and 500 characters of body. The whole open-issue listing is about 11 MB, over the 1 MiB limit of a run file.
    • Rejected: Reuse state/issues.json of refactor(roadmap): the stage agent is stock Coder #6705. That file holds only the item and the issues of active change folders, so a search over the open issues finds nothing.
    • Rejected: One file for each open issue. About 2000 files in one run folder are slow to write and to read.
  • How does the stock Coder search the open-issue index?: It uses its shell with grep or rg on work/github/issue-index.jsonl. The prompt tells it to search before it plans. A custom find_issues tool in --phase agent would break ADR 0036 and the stock Coder contract. (best practice) [sources: src/devops_cli/roadmap/stage/stage_agent.py:105, tests/roadmap/stage/test_roadmap_stage_agent.py:104, openspec/specs/roadmap-stage/phases/spec.md:60]
    • Chosen: A shell search over work/github/issue-index.jsonl. The stock Coder has a shell, and the index is small enough to search with no custom tool.
    • Rejected: Add a custom find_issues tool to --phase agent. ADR 0036 and phases/spec.md keep the agent phase on the stock Coder tools.
    • Rejected: A SQLite full-text index. It adds a build step and a file format for a search of at most 1000 records.
  • What does prepare do when a GitHub read fails?: It records the failure in work/github/errors.json, writes no file for that read, and continues with the other reads. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, docs/roadmap/stage.md:50]
    • Chosen: Record the failure and continue. One failed read must not stop the plan, and the other reads still help the Coder.
    • Rejected: Stop the run. A rate limit or one missing pull request would stop every plan of the run.
  • Should --phase all write the snapshot files?: No. --phase all keeps the live GitHub reads and writes no file under work/github/. Only a separate prepare phase writes the snapshot. (best practice) [sources: src/devops_cli/roadmap/stage/stage_job_phases.py:689, openspec/specs/roadmap-stage/phases/spec.md:60]
    • Chosen: Keep the live reads in --phase all. The issue states that --phase all does not change, and the old custom engine still reads GitHub.
    • Rejected: Write snapshots in --phase all too. This changes the current behavior and adds files that no tool reads in that mode.
  • Which tool covers the GitHub reads?: cli/cli covers the GitHub reads, with the verdict in-use in the alternatives check of 2026-11-23 in the issue body. The project adds the snapshot store, the newline-delimited index and the Coder prompt. (best practice) [sources: src/devops_cli/roadmap/stage/stage_job_phases.py:689]
    • Chosen: Use cli/cli for the fetches. The tool is open, maintained and already in use, and it covers the fetch half of the need.
    • Rejected: Build a GitHub fetch client in the project. It repeats an open, maintained tool and adds cost with no gain.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    source/agent
    scope/roadmap
    status/new
    value/medium
    on Nov 23, 2026
  2. dan-petty commented on Nov 23, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 23, 2026
  4. dan-petty commented on Nov 23, 2026

    @dan-petty
    OwnerAuthor

    The dependency changes: #6813 is closed as not planned, and #6705 now builds the phases of stage together with the Coder agent. This item needs the prepare phase of #6705. The agent of #6705 reads these files with its shell.

  5. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • gh CLI export issues with comments and pull request files as JSON, results: 5
    • tool to snapshot GitHub issues and pull requests to local files for offline use, results: 5
    • github-backup offline mirror issues comments pull requests repository tool, results: 5
    • cli github cli "gh issue list" json export comments local search, results: 5
    • ripgrep, results: 5
    • github cli, results: 5
    • gh cli issue view json comments pr diff files automation, results: 5
    • cache GitHub API responses to disk for offline agent, results: 5
    • cli.github.com manual gh issue view json comments, results: 5
    • GitHub MCP server issue_read pull request files search issues agent, results: 5

    Sources:

  6. dan-petty commented on Nov 23, 2026

    @dan-petty
    OwnerAuthor

    prepare of #6705 writes the issue listing of the stage run, and this item builds on it. The listing is state/issues.json, with a copy for the agent in work/, in the record form of IssueRecord. It holds only the records that devops roadmap plan-recheck --issues reads: the item with its body, and the number and state of each issue that an active change folder names. The whole listing of the repository is about 11 MB, over the limit of 1 MiB of a run file. So the snapshot of the open issues for the local search of this item needs a file and a limit of its own. The plan: openspec/changes/6705-stage-agent-stock-coder/ on main.

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

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  9. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    This issue cannot be built as written after #6705 (443130279, ADR 0036). The acceptance criteria and refined design require read_issue, find_issues, open-pull overlap checks, and named pull-request file reads inside --phase agent. After #6705, run_stage_agent (src/devops_cli/roadmap/stage/stage_job_phases.py:689) runs stock Coder (src/devops_cli/roadmap/stage/stage_agent.py:105) with no custom tools (openspec/specs/roadmap-stage/phases/spec.md:60, tests/roadmap/stage/test_roadmap_stage_agent.py:104: script.tools_offered == stock.tools_offered). Adding read_issue or find_issues to --phase agent breaks ADR 0036 and phases/spec.md, while --phase all uses the old custom engine until #6846. Please refine #6831 for stock Coder reading prepare snapshot files from work/github/ via its shell and prompt (roadmap_stage_coder.md).

  10. added
    status/new
    and removed
    status/ready
    on Nov 25, 2026
  11. added
    status/ready
    and removed
    status/new
    on Nov 25, 2026
  12. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  13. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 25, 2026
  14. removed
    status/in-review
    on Nov 25, 2026
  15. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 17:09 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/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions