Skip to content

feat(roadmap): the implement agent can amend the plan when the plan is wrong #3057

Closed

Description

@dan-petty

What happened

34 of 37 plans had defects. An implement agent that finds a wrong path or a wrong premise today can only stop. Rule 2 of AGENTS.md says to return an infeasible item with evidence, but no step exists for a plan that is wrong but fixable.

What should happen

  • A step can raise a plan amendment: it states the defect, the evidence and the corrected text. A bounded set of amendments (wrong path, a missing task, a group that exceeds its budget, a wrong verify command) is applied in the same pull request, with the change recorded in the change folder's tasks.md. A premise failure returns the item (rule 2). A change of scope waits for a person with a question on the issue (G2).
  • A group that exceeds its token budget is re-split by the existing split step and continues.

Acceptance criteria

  • A replay with a wrong test path in the plan ends in a delivered pull request that has the corrected path in its tasks.md.
  • A replay with a false premise returns the item with the evidence and no code.
  • The amendment appears in the PR comment with the evidence.
  • An amendment never changes a spec requirement or an acceptance criterion without a person.

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 implement agent can only stop when it finds a defect in the plan. Thirty-four of thirty-seven plans had defects. A step that amends a bounded defect in the plan is missing. The agent needs a way to fix a wrong path, a missing task, a budget-exceeding group, or a wrong verify command in the same pull request, while still returning the item on a false premise and waiting for a person on a scope change.

Acceptance criteria

Requirement: Bounded plan amendment

The implement agent SHALL apply a bounded plan amendment in the same pull request when it detects a wrong path, a missing task, a group that exceeds its budget, or a wrong verify command.

Scenario: Wrong test path in plan

  • WHEN A replay plan contains a test path that does not exist in the repository
  • THEN The delivered pull request contains the corrected path in its tasks.md

Requirement: Amendment recorded in tasks.md

The implement agent SHALL record each applied amendment in the change folder's tasks.md with the defect, the evidence, and the corrected text.

Scenario: Amendment entry in tasks.md

  • WHEN The implement agent applies a bounded amendment
  • THEN The tasks.md of the change folder contains an entry that states the defect, the evidence, and the corrected text

Requirement: Amendment in PR comment

The implement agent SHALL post the amendment and its evidence as a comment on the pull request.

Scenario: PR comment with amendment

  • WHEN The implement agent applies a bounded amendment
  • THEN The pull request has a comment that contains the amendment text and its evidence

Requirement: Premise failure returns item

The implement agent SHALL return the item to New with the evidence and no code when it detects a false premise.

Scenario: False premise replay

  • WHEN A replay plan contains a premise that is false against the real system
  • THEN The item is returned to New with the evidence and no code is committed

Requirement: Amendment scope boundary

A plan amendment SHALL NOT change a spec requirement or an acceptance criterion without a person's approval.

Scenario: Scope change blocked

  • WHEN The implement agent detects a defect that requires changing a spec requirement or an acceptance criterion
  • THEN The agent posts a question on the issue and does not apply the change

Requirement: Budget-exceeding group re-split

The implement agent SHALL re-split a group that exceeds its token budget using the existing split step and continue with the new groups.

Scenario: Group exceeds budget

  • WHEN A task group's inputs exceed the token budget
  • THEN The existing split step re-splits the group and the implement agent continues with the new groups

Existing Tool Considered

No check has run. No open, maintained tool or library covers the need of adding a plan-amendment step to the implement agent's workflow. The project builds its own code. The cost is the tokens to build, keep, and fix the amendment step, its classification rules, its tasks.md recording, its PR comment, and its replay tests, and the elapsed time to integrate it into the existing implement job.

Key questions

  • What is the bounded set of amendments that the agent may apply without a person?: The bounded set is: a wrong path, a missing task, a group that exceeds its budget, and a wrong verify command. A premise failure returns the item. A scope change waits for a person. [sources: AGENTS.md]
  • How does the agent classify a defect as bounded, a premise failure, or a scope change?: The agent classifies at the point of detection. If the defect is in the bounded set, it amends. If the fundamental assumption is false, it returns the item per rule 2. If the fix requires changing a spec requirement or acceptance criterion, it posts a question on the issue and waits for a person. (best practice) [sources: AGENTS.md, CONTEXT.md]
    • Chosen: Classify inline at the point of detection. Chosen. The agent already reads the plan and the repository. It can judge the defect type without a separate step. This keeps the step count low and the logic local.
    • Rejected: A separate classification step before the amendment. Rejected. It adds a step and a token cost for every defect, and the classification is simple enough to do inline.
    • Rejected: Always amend and escalate only on failure. Rejected. It risks applying a scope change before a person approves it, which violates the acceptance criterion.
  • Where in the step sequence does the amendment run?: The amendment is raised within the step that detects the defect. The step's agent amends the plan and continues, or escalates to a return or a question. No separate step type is added. (best practice) [sources: CONTEXT.md]
    • Chosen: Amend within the detecting step. Chosen. The step already holds the plan, the repository, and the defect. Amending in place avoids a round-trip and keeps the token budget of the step.
    • Rejected: A new step type that runs between task group steps. Rejected. It adds a step and a token cost, and the defect is already known to the detecting step.
    • Rejected: A post-step after all task groups. Rejected. The defect blocks the current step. Waiting until all groups finish delays the fix and wastes tokens on groups that depend on the corrected plan.
  • What format does the amendment entry in tasks.md use?: A new section titled 'Amendments' in tasks.md. Each entry states the defect, the evidence, and the corrected text. The entry is appended when the amendment is applied. (best practice) [sources: CONTEXT.md, AGENTS.md]
    • Chosen: A new 'Amendments' section in tasks.md. Chosen. The body says the change is recorded in tasks.md. A dedicated section keeps the amendment history separate from the task checklist and is easy to parse.
    • Rejected: Inline annotations on the affected task line. Rejected. It mixes the amendment record with the task state and makes the checklist harder to read.
    • Rejected: A separate amendments file in the change folder. Rejected. The body names tasks.md as the record. A separate file adds a path to maintain and a file to read.
  • Does the amendment step require a dependency on another issue?: No. The implement agent, the split step, and the change folder structure already exist. The amendment is a new behavior within the existing implement job. [sources: CONTEXT.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/medium
    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: P2-Medium. It fixes the top failure mode in the pipeline but is one step among many in the tracker, so it is high but not blocking.
    • Value: High. 34 of 37 plans had defects and the implement agent can only stop today; this prevents lost work on fixable plans.
    • Effort: Medium. It needs a bounded amendment set, a tasks.md record, a PR comment, and a gate that blocks scope changes, all within the existing step loop.
    • Related: feat(roadmap): every step repairs before it gives up, in bounded rounds #3053, which asks for a different change. Both add a repair path during the implement step, but #3053 retries after an execution failure while the candidate amends the plan text for a wrong path, missing task, or wrong verify command.
  3. added
    priority/p2-medium
    on Nov 1, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    Staged: branch feat/3057-the-implement-agent-can-amend-the, draft pull request #3184. 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. Classify a plan defect: 6386 tokens
    2. Raise the amendment from a step: 6377 tokens
    3. Return the item on a false premise: 6361 tokens
    4. Re-split a group over its budget: 6365 tokens
    5. Record the amendment behavior in the spec: 6346 tokens

    The plan run made 8 model request(s), and used 225055 input tokens and 4759 output tokens. The tool calls, in order:

    1. list_files({"directory":"src/devops_cli/roadmap"})
    2. search_code({"text":"split"})
    3. read_file({"path":"src/devops_cli/roadmap/implement_step.py"})
    4. list_files({"directory":"tests/roadmap"})
    5. file_symbols({"path":"src/devops_cli/roadmap/implement_step.py"})
    6. read_spec({"capability":"roadmap-implement-step"})
    7. search_code({"text":"split"})
    8. read_spec({"capability":"roadmap-implement-job"})
    9. search_code({"text":"def split"})
    10. file_symbols({"path":"src/devops_cli/roadmap/stage.py"})
    11. read_file({"path":"src/devops_cli/roadmap/stage.py","start_line":340,"end_line":420})
    12. read_file({"path":"src/devops_cli/roadmap/stage.py","start_line":486,"end_line":570})
    13. read_file({"path":"src/devops_cli/roadmap/stage.py","start_line":1140,"end_line":1190})
    14. read_file({"end_line":810,"path":"src/devops_cli/roadmap/stage.py","start_line":719})
    15. read_file({"end_line":330,"path":"src/devops_cli/roadmap/implement_step.py","start_line":130})
  7. added 4 commits that reference this issue on Nov 2, 2026
  8. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  9. added a commit that references this issue on Nov 3, 2026
    b267341
  10. added
    status/in-progress
    and removed
    status/planned
    on Nov 3, 2026
  11. added a commit that references this issue on Nov 3, 2026
    1f41e0a
  12. added
    status/in-review
    and removed
    status/in-progress
    on Nov 3, 2026
  13. removed
    status/in-review
    on Nov 3, 2026
  14. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-03 18:24 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/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions