Skip to content

feat(roadmap): planners and implement read the target AGENTS.md #4650

Done

Description

@dan-petty

Problem or Motivation

  • refine.collect_context (src/devops_cli/roadmap/refine/refine.py:881-903, which the stage uses at stage.py:1451) reads CONTEXT.md and the first 5 files of docs/adr in name order. devops-cli has 22 ADRs, so the planner gets 0001-0005, and 0002 is superseded.
  • vibes has a 413-line AGENTS.md and no CONTEXT.md, so its planner gets none of its rules.
  • stage_change.py:2780 calls rules_sections only to count tokens.
  • step_rules.rules_sections returns [] when AGENTS.md is missing (src/devops_cli/roadmap/step_rules.py:131-137). So in 5 of 6 repositories the implement step runs with no repository rules.

Proposed Solution & Architectural Design

  • collect_context adds the AGENTS.md of the target through rules_sections, cut to CONST_ROADMAP_IMPLEMENT_FILE_MAX_TOKENS (8,000), as the implement step does.
  • When a target has no AGENTS.md, rules_sections gives the kit rules rendered with the detected values (fix(ai): devops ai agents detects the project manifest #4641), under a heading that says that they are the generic rules.
  • CONTEXT.md stays an optional project file.
  • ADR selection by relevance is a different item and is not in this change.
  • Owner decision 7 (2026-11-11): the vibes AGENTS.md (44,535 characters, about 11,000 tokens) stays. The cut at 8,000 tokens applies to it.

Target Subsystem

SDLC, Git & PR Governance (src/devops_cli/roadmap/refine/refine.py and src/devops_cli/roadmap/step_rules.py).

Existing Tool Considered

AGENTS.md is the open standard file for agent rules, and the implement step already reads it. No tool is necessary. Cost: about 40 lines and 4 tests, about 150,000 tokens and 2 hours to build.

Acceptance Criteria

  • A test: the refine context for a repository with AGENTS.md contains its first rule line, and stays within the token cap for a 44,535-character file.
  • A test: rules_sections for a checkout with no AGENTS.md returns 1 section with the generic rules, and none of them says "Python" when the checkout has no Python manifest.
  • The stage eval replay score is not lower (both numbers in the pull request).

Dependencies

#4641.

Source: #4627

Alternatives check of 2026-11-20: none.
Tool: none found.
Reason: Searches for AGENTS.md generators and for tools that assemble a repository's rules into a capped model context found nothing relevant; the need is this repository's own collect_context and rules_sections.

Lacks:

  • No tool reads AGENTS.md at the item's commit
  • No tool renders kit rules for a checkout without AGENTS.md
  • No tool applies the implement file token cap

Proposed design

Problem statement

Refine and stage build the model context from CONTEXT.md and the first five files of docs/adr in name order; one of those five, ADR 0002, is superseded. A repository with no CONTEXT.md gives the planner none of its own rules, and the implement step's rules_sections returns no section when AGENTS.md is absent, so five of six repositories run with no repository rules. This change adds the target AGENTS.md at the item's commit to the refine context under the implement file cap, and gives the generic kit rules rendered with the detected values when the file is absent. ADR selection by relevance stays out of this change.

Acceptance criteria

Requirement: The refine context holds the target AGENTS.md

The refine context SHALL include the AGENTS.md of the target repository when the item's commit holds that file.

Scenario: A commit with an AGENTS.md

  • WHEN collect_context builds the context for a commit whose AGENTS.md holds a known first rule line
  • THEN the context holds that rule line under the rules heading

Requirement: The AGENTS.md section comes from the item's commit

collect_context SHALL read the AGENTS.md at the item's sha, not from the working tree.

Scenario: The working tree differs from the commit

  • WHEN the AGENTS.md at sha holds one rule line and the working-tree AGENTS.md holds another
  • THEN the context holds the line from sha and not the working-tree line

Requirement: Each rules section stays under the implement file cap

Each rules section SHALL hold at most CONST_ROADMAP_IMPLEMENT_FILE_MAX_TOKENS tokens.

Scenario: A 44,535-character AGENTS.md

  • WHEN collect_context builds the context for a commit whose AGENTS.md holds 44,535 characters
  • THEN the AGENTS.md section holds at most CONST_ROADMAP_IMPLEMENT_FILE_MAX_TOKENS tokens

Requirement: The context stays within the caller budget

collect_context SHALL keep the whole context within the max_tokens that its caller gives.

Scenario: A context with the AGENTS.md section

  • WHEN collect_context builds a context with the AGENTS.md section and a max_tokens value
  • THEN the token count of the context is at most max_tokens

Requirement: A checkout with no AGENTS.md gets the generic rules

rules_sections SHALL put one section of the generic kit rules first when the checkout has no AGENTS.md.

Scenario: A checkout with no AGENTS.md

  • WHEN rules_sections runs on a checkout with no AGENTS.md and no routed document
  • THEN it returns one section whose heading states that the rules are generic

Requirement: The generic rules name no toolchain that the checkout lacks

The generic rules SHALL name only the toolchain that the checkout detects.

Scenario: A checkout with no Python manifest

  • WHEN rules_sections runs on a checkout with no AGENTS.md and no Python manifest
  • THEN no line of the returned section says Python

Requirement: The refine context gets the generic rules when the commit has none

collect_context SHALL add the generic rules section when the item's commit holds no AGENTS.md.

Scenario: A commit with no AGENTS.md

  • WHEN collect_context builds the context for a commit with no AGENTS.md while the working tree holds one
  • THEN the context holds one rules section whose heading states that the rules are generic

Requirement: CONTEXT.md stays optional

collect_context SHALL read CONTEXT.md only when the item's commit holds that file.

Scenario: A commit with no CONTEXT.md

  • WHEN collect_context builds the context for a commit with AGENTS.md and no CONTEXT.md
  • THEN the context holds the AGENTS.md section and no CONTEXT.md section

Requirement: The stage replay score does not fall

The pull request SHALL state the stage eval replay score before and after the change, and the after score SHALL NOT be lower.

Scenario: Replay of the recorded stage runs

  • WHEN the stage eval replay runs on the change
  • THEN it reports a score not lower than the score before the change, and the pull request body states both scores

Existing Tool Considered

The alternatives check of 2026-11-13 ran seven searches and found no open, maintained tool or library: AGENTS.md is a convention file, and the need is this repository's own collect_context and rules_sections, which already share the implement step's section builder. No external tool renders the kit rules for a checkout with no AGENTS.md or reads the target file at the item's commit. Written cost to build, keep and fix that code instead: about 150,000 tokens and 2 hours of elapsed time, about 40 lines and 4 tests. The change deletes no internal code.

Key questions

  • Which files does the refine context read today, and where does collect_context live?: collect_context is at src/devops_cli/roadmap/refine/refine.py:955. It reads CONTEXT.md at the item's sha (refine.py:965) and the first five files of docs/adr in name order (refine.py:970-973); those five are ADR 0001-0005, and ADR 0002 is superseded. The stage calls it at stage.py:2007 and the refine round at refine.py:2582. [sources: src/devops_cli/roadmap/refine/refine.py:955, src/devops_cli/roadmap/refine/refine.py:965, src/devops_cli/roadmap/refine/refine.py:973, src/devops_cli/roadmap/stage/stage.py:2007, src/devops_cli/roadmap/refine/refine.py:2582, docs/adr/0002-roadmap-jobs-act-as-a-machine-account.md:2]
  • What does rules_sections return when the checkout has no AGENTS.md?: An empty list: step_rules.py:143-144 returns [] before it builds any section, and the archived change 3097 records that a checkout with no AGENTS.md gives nothing. [sources: src/devops_cli/roadmap/step_rules.py:143, openspec/changes/archive/2026-11-01-3097-step-gets-agents-md/tasks.md:7]
  • Is fix(ai): devops ai agents detects the project manifest #4641 delivered, so that the generic rules renderer exists?: Yes. The change folder openspec/changes/archive/2026-11-11-4641-devops-ai-agents-detects-the-project/ is archived and every task is checked. It delivers parse_project_metadata (instruction_generator.py:174) and generate_agents_md (instruction_generator.py:246), which renders src/devops_cli/templates/AGENTS.md.j2 with the detected toolchains and writes no toolchain line for a checkout with no manifest. fix(ai): devops ai agents detects the project manifest #4641 is therefore done and does not block this item. [sources: openspec/changes/archive/2026-11-11-4641-devops-ai-agents-detects-the-project/tasks.md:7, src/devops_cli/ai/instruction_generator.py:174, src/devops_cli/ai/instruction_generator.py:246, src/devops_cli/templates/AGENTS.md.j2:4]
  • How does refine build the AGENTS.md section, given that rules_sections takes a task group and reads the working tree?: One section builder in step_rules.py takes the rules text and the heading and returns the text cut to CONST_ROADMAP_IMPLEMENT_FILE_MAX_TOKENS under that heading. rules_sections supplies the working-tree AGENTS.md or the generic rules, and collect_context supplies the AGENTS.md at the item's sha or the generic rules. Neither caller copies the cap or the heading. (best practice) [sources: openspec/changes/archive/2026-11-01-3097-step-gets-agents-md/design.md:5, openspec/changes/archive/2026-11-01-3097-step-gets-agents-md/design.md:43, src/devops_cli/roadmap/step_rules.py:137, src/devops_cli/config/constants.py:3524]
    • Chosen: One text-taking section builder in step_rules.py. The implement step and the stage measure already share rules_sections, and change 3097 records that one function keeps the measure and the message equal.
    • Rejected: Pass a synthetic task group from refine. Refine has no task group, and a synthetic group couples the context to the shape of a group.
    • Rejected: Copy the AGENTS.md read into refine.py. Two copies drift, and the planner's cap and heading would differ from the implement step's.
  • Which revision of the target AGENTS.md does collect_context read?: The AGENTS.md at the item's sha, through _read_git_file, as CONTEXT.md and the ADRs are read. The working tree can hold an edit from an earlier step, and the stage already reads the staged commit rather than the working tree for the same reason. A commit with no AGENTS.md gets the generic rules, even when the working tree holds one. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:965, src/devops_cli/roadmap/refine/refine.py:731, src/devops_cli/roadmap/stage/stage.py:3105, openspec/changes/archive/2026-11-01-3097-step-gets-agents-md/design.md:43]
    • Chosen: At the item's sha. CONTEXT.md and the ADRs already come from sha, and the stage reads the commit it plans on, so the whole context describes one revision.
    • Rejected: From the working tree. An earlier step can edit the checkout, so the planner would read rules that the item's commit does not hold.
    • Rejected: Both revisions. Two copies of the same rules spend the budget twice and can conflict.
  • Where does the AGENTS.md section go in the refine context?: First, under its own heading, before CONTEXT.md and the ADRs. (best practice) [sources: openspec/changes/archive/2026-11-01-3097-step-gets-agents-md/design.md:5]
    • Chosen: First, before CONTEXT.md and the ADRs. The implement step adds the rules before the item, and the cut of the token budget takes the end first, so the rules survive a small budget.
    • Rejected: Last, after CONTEXT.md and the ADRs. The planner would read the rules after the project terms, and a small budget would cut them first.
  • What token cap applies to the AGENTS.md section?: CONST_ROADMAP_IMPLEMENT_FILE_MAX_TOKENS, which is 8,000 (constants.py:3524), the same cap the implement step uses. (best practice) [sources: src/devops_cli/config/constants.py:3524, openspec/changes/archive/2026-11-01-3097-step-gets-agents-md/design.md:43]
    • Chosen: The implement file cap, CONST_ROADMAP_IMPLEMENT_FILE_MAX_TOKENS. The implement step already cuts AGENTS.md with this constant, and one cap keeps the planner and the step equal.
    • Rejected: No cap. The vibes file holds 44,535 characters, about 11,000 tokens, and it would fill the context.
    • Rejected: A new refine-only cap. Two caps drift, and the planner and the implement step would read different text.
  • Does the vibes AGENTS.md stay at 44,535 characters?: The file stays. Owner decision 7 of 2026-11-11 in feat(roadmap): track one project profile for all repositories #4627 says the kit does not replace an existing AGENTS.md, the vibes file stays, and the owner can make it shorter by hand (fetched 2026-11-14). So this change does not shorten the file, and the 8,000-token cut applies to it as the issue body records. (best practice) [sources: https://github.com/feat(roadmap): track one project profile for all repositories #4627]
    • Chosen: Keep the file and cut it at the cap. Owner decision 7 keeps the vibes file and leaves any shortening to the owner, so the cap is the only change.
    • Rejected: Shorten the vibes AGENTS.md in this change. Owner decision 7 rejects the kit's replacement of an existing file and leaves the shortening to the owner's hand.
  • Does the refine context get the generic rules when the item's commit has no AGENTS.md?: Yes. collect_context uses the same section builder, so a target with no AGENTS.md gets one generic rules section under a heading that says it is generic, rendered by generate_agents_md from the detected facts. Without it the planner in five of six repositories reads no repository rules. (best practice) [sources: src/devops_cli/roadmap/step_rules.py:143, src/devops_cli/ai/instruction_generator.py:246, openspec/changes/archive/2026-11-11-4641-devops-ai-agents-detects-the-project/proposal.md:9]
    • Chosen: Give the generic rules to both refine and the implement step. The issue finds that five of six repositories have no AGENTS.md, and the planner needs the same rules that the implement step gets.
    • Rejected: Give the generic rules only to the implement step. The planner would still read no repository rules in five of six repositories, which is the problem the change solves.
    • Rejected: Keep the empty list for both. The implement step and the planner would keep running with no rules, and fix(ai): devops ai agents detects the project manifest #4641 already gives the renderer.
  • Does this change wire the generic kit rules into rules_sections?: Yes. rules_sections returns one generic section when AGENTS.md is absent, rendered by generate_agents_md from parse_project_metadata. fix(ai): devops ai agents detects the project manifest #4641 delivered that renderer, so this change adds the call and the generic heading and waits on no other item. (best practice) [sources: src/devops_cli/roadmap/step_rules.py:143, src/devops_cli/ai/instruction_generator.py:246, openspec/changes/archive/2026-11-11-4641-devops-ai-agents-detects-the-project/tasks.md:7]
    • Chosen: Wire the fallback here. The implement step runs with no rules in five of six repositories, and fix(ai): devops ai agents detects the project manifest #4641 already gives the rendered rules.
    • Rejected: Keep the empty list and file a separate item. The fallback is one call in rules_sections, and this change already adds the rules section.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 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: P2-Medium. The planner currently misses repository rules, but the implement step already covers them, so this is a gap not a break.
    • Value: Medium. The planner gains access to project-specific rules, improving plan quality for repositories that use AGENTS.md.
    • Effort: Low. The candidate estimates about 40 lines, 4 tests, and 2 hours of work.
    • Related: feat(roadmap): the implement step gives the agent AGENTS.md and the documents it routes to #3097, which asks for a different change. Both target the roadmap pipeline reading AGENTS.md, but #3097 changed the implement step while this candidate changes the refine/planner stage.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches returned no open, maintained tool or library for this need: AGENTS.md is a convention file, not a tool, and the issue itself says no tool is necessary. The work is an internal change to this repository's collect_context and rules_sections, which already read AGENTS.md in the implement step, so nothing external covers it.

    Tool: none found

    Lacks:

    • A tool that loads a target repository's AGENTS.md into a planner/refine context under a token cap
    • A tool that renders generic kit rules when a checkout has no AGENTS.md
    • The change is project-internal code in refine.py and step_rules.py, not a third-party capability

    Searches run:

    • AGENTS.md open standard file for agent rules, results: 5
    • tool that collects AGENTS.md repository rules into LLM agent context, results: 5
    • "AGENTS.md" convention agents instructions file standard adoption, results: 5
    • agents.md, results: 5
    • python library load AGENTS.md into prompt context, results: 5
    • repomix pack repository context for AI agents, results: 5
    • agents.md standard for AI coding agents website, results: 5

    Checked on 2026-11-13. A person decides what this means for the item. The check changes no label and closes no issue.

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

    @devops-cli-service
    Contributor

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

  8. added
    owner/service
    on Nov 24, 2026
  9. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Plan state: branch feat/4650-planners-and-implement-read-the-target, draft pull request #6985. The pull request plans the item and closes no issue. The stage job and the step fix-plan edit this comment, and a comment of each run tells what the run did.

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

    1. Render the generic kit rules when a checkout has no AGENTS.md: 38369 tokens
    2. Regenerate the step message snapshot for the generic rules: 20951 tokens
    3. Add the target AGENTS.md to the refine context: 50909 tokens
    4. State the context rules and the stage eval replay score: 25698 tokens

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • major missing_path at tasks (1): Group 1 makes rules_sections return a generic rules section for a checkout with no AGENTS.md, so the step message of such a checkout now starts with that section. tests/roadmap/implement/test_roadmap_implement_step.py compares that message with a syrupy snapshot, and neither the test nor tests/roadmap/implement/__snapshots__/test_roadmap_implement_step.ambr is read or changed by the plan, so the snapshot fails. Evidence: "# Item Release v0.1.8 #1: Make the sample shout"
    • major other at tasks (1): The plan names only _file_tokens as the case to update in tests/roadmap/stage/test_roadmap_stage_measure.py, but test_the_measure_counts_agents_md_and_the_routed_sections_that_the_step_reads measures the clone before and after writing AGENTS.md. The before measure of a clone with no AGENTS.md now holds the generic section, so the difference the test asserts no longer holds and the group's own verify command fails. Evidence: "assert after.tokens - before.tokens == count_tokens(rules) + count_tokens(testing)"
    • minor other at tasks (3): Group 3 still tells the implementer to update tests/roadmap/test_roadmap_limit_classes.py, while its changes list holds only docs/roadmap/refine.md and the feasibility says no group reads, changes or documents that file. This change adds no roadmap limit constant, so the instruction is a leftover that contradicts the plan. Evidence: "Update tests/roadmap/test_roadmap_limit_classes.py"
    • minor other at tasks (4): Group 4 changes only docs/roadmap/refine.md, and the change adds no CONST_ROADMAP_* limit, so the registry test tests/roadmap/test_roadmap_limit_classes.py needs no edit. The documentation line sends the implementer to a file the group does not change, which the implement step refuses to touch because the group does not name it. Evidence: "Update tests/roadmap/test_roadmap_limit_classes.py"
  10. 15 remaining items

  11. added
    status/in-review
    on Nov 24, 2026
  12. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    The draft pull request #7001 holds the final title and body. In mode on of roadmap.fix_checks.mode, the watch row marks it ready when its checks pass, and a fix-checks Job repairs a failed check whose name gives the class test, lint or types. In each other case the watch row stops the item: another failed check, a cancelled check, a conflict, a fix-checks Job that ended with no repair, or another mode.

    Spend: 152 model requests, 11365646 input tokens, 59348 output tokens.

  13. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-implement-devops-cli-4650-94368b ended: succeeded.
    Image digest: sha256:91fca09448126aad14b4f12455822ca9e1dd6b19a727edc7e9a28a864037c0c6

    The last lines of its log:

    (no log: the Job has no pod)

    Failure class: ci_infra.
    Action taken: none.
    Action left: retry: run the item again.

    The Job left this item without a result. The item is Blocked. When a retry can fix the class of the stop, the Service starts a new Job in the next round. The limit is roadmap.implement.continuations_per_item, and the comment of that round says so. If no continuation is left, fix the cause. Then comment implement: retry. A new runner image also clears the stop. This holds only if a retry can fix the class of the stop. The limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item must also allow it.

  14. added
    status/blocked
    status/planned
    and removed
    owner/service
    status/in-review
    status/blocked
    on Nov 24, 2026
  15. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at job by the rule continue: the runner Job devops-cli-implement-devops-cli-4650-94368b ended without a result. The class ci_infra of the stop is one that a new attempt can fix. This is continuation 1 of 4 for this item. The item is Planned again. The Service takes it in the next round. The new Job takes the branch from origin, so it keeps the work that the run pushed there.

  16. removed
    status/planned
    on Nov 24, 2026
  17. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-24 17:08 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/lowpriority/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