Skip to content

feat(roadmap): retry a refused pull request text once #3599

Closed

Description

@devops-cli-service

Split from #3215.

Problem: The stage and implement jobs stop an item when build_body or build_plan_body refuses a title or body. The issue asks the job to send the problems to the model once and to stop only on a second refusal. Why deferred: The implement job has no free-text model step for the pull request body. The stage job has no body retry path. A retry needs a new prompt, a new bounded step and tests. The safe stop is in this item, and the retry is a separate change. Acceptance criteria: A job that gets a refused body sends the problems to the model once. A rebuilt body that passes is written to the pull request. A second refusal stops the item with the refused-reply failure class. The job writes no ... into a title or body.

Proposed design

Problem statement

The stage job and the implement job stop an item when the pull request text breaks a form rule. A body that the model can fix stops the item at the first refusal. This change sends the problems to the model one time and rebuilds the text. A second refusal still stops the item.

Acceptance criteria

Requirement: Refused text retried once

A roadmap job SHALL send the problems of a refused pull request title or body to the model one time and rebuild the text from the reply.

Scenario: First refusal

  • WHEN The form check returns a non-empty problem list for the title or the body that the job built.
  • THEN The job makes one more model call that carries every problem, and it rebuilds the text from the reply.

Requirement: Passing rebuilt text is written

The job SHALL write the rebuilt title or body to the pull request when the rebuilt text passes the form check.

Scenario: Rebuilt text passes

  • WHEN The form check returns an empty problem list for the rebuilt text.
  • THEN The job writes the rebuilt text to the pull request and continues the step with no stop.

Requirement: Second refusal stops the item

The job MUST stop the item with the refused-reply failure class when the rebuilt text fails the form check.

Scenario: Second refusal

  • WHEN The form check returns a non-empty problem list for the rebuilt text.
  • THEN The job stops the item, records the refused-reply failure class and makes no third model call.

Requirement: No placeholder in a title or body

The job MUST NOT write a ... placeholder into the title or the body of a pull request.

Scenario: Placeholder in the reply

  • WHEN The rebuilt title or body holds a placeholder that is_placeholder refuses.
  • THEN The job treats the text as a refusal, and no ... reaches the pull request.

Existing Tool Considered

No check has run. No open, maintained library covers this need: the retry is a bounded loop over the project's own model client and the project's own form rules in src/devops_cli/roadmap/pull_form.py. The change builds the loop in the job layer. The cost is about 45k tokens to build, about 8k tokens each month to keep and fix, and about two days of elapsed time.

Key questions

  • Where does the retry step live?: One shared function beside the model client, in src/devops_cli/roadmap/messages.py. Both jobs call it. pull_form.py keeps its rule: it reads no file and makes no request. (best practice) [sources: openspec/changes/archive/2026-11-02-3198-pull-request-form-check/design.md:5, openspec/changes/archive/2026-11-02-3198-pull-request-form-check/design.md:39]
    • Chosen: A shared retry function in the job layer. Both jobs need the same loop, and one copy keeps the two stops equal.
    • Rejected: A loop in each job. Two copies drift, and the jobs can stop on different rules.
    • Rejected: The retry inside pull_form.py. pull_form.py makes no request by design, and a model call breaks that.
  • How does the implement job get a model-written body?: The retry adds one bounded model step that writes the body from the change folder and the issue. build_body checks the text of that step. (best practice) [sources: openspec/changes/archive/2026-11-02-3198-pull-request-form-check/design.md:39, src/devops_cli/roadmap/implement_run.py]
    • Chosen: One bounded model step for the body. The implement job has no free-text step for the body, and one step keeps the cost bounded.
    • Rejected: Keep the current builder and skip the retry. The implement job then stops on a body that the model can fix.
    • Rejected: Re-run the full implement step. A full step repeats the work of the group and exceeds the step budget.
  • How many times does the job send a refused text to the model?: One time. The job builds the title and the body at most twice. (best practice) [sources: openspec/changes/archive/2026-11-02-3198-pull-request-form-check/tasks.md:46]
    • Chosen: One retry. The issue asks for one retry, and one retry keeps the cost of a step bounded.
    • Rejected: A retry on every refusal. The model calls grow without a limit.
    • Rejected: No retry. A fixable body stops the item.
  • What does the retry prompt carry?: The refused text and every problem that the form check returns. The model edits the text and keeps its facts. (best practice) [sources: openspec/changes/archive/2026-11-02-3198-pull-request-form-check/proposal.md:9]
    • Chosen: The refused text and every problem. The model edits the text and keeps the facts that the job already read.
    • Rejected: The problems only. The model rebuilds the text from the sources and can lose a fact.
    • Rejected: A shorter text cut by code. pull_form.py cuts no text, and a cut loses content.
  • How does the job treat a placeholder in a rebuilt title or body?: is_placeholder refuses it, so the job treats it as a refusal. The retry carries the problem. A second placeholder stops the item. (best practice) [sources: openspec/changes/archive/2026-11-02-3198-pull-request-form-check/tasks.md:9]
    • Chosen: Refuse the text. The rule is already in the form check, and the retry gives the model one chance to remove the placeholder.
    • Rejected: Write the text with the placeholder removed. A silent edit hides a model failure.
    • Rejected: Stop the item at the first placeholder. The issue allows one retry.
  • Which failure class records the second refusal?: The refused-reply class that the job already uses. The stop record names the class, so a person sees why the item stopped. (best practice) [sources: openspec/changes/archive/2026-11-02-3198-pull-request-form-check/design.md:39]
    • Chosen: The existing refused-reply class. One class for one cause keeps the retry rule of the Service simple.
    • Rejected: A new class for a second refusal. A second class for the same cause confuses the retry rule.
  • How do the tests check the retry with no network?: Unit tests in tests/roadmap/ use a fake model client and the real form check. The tests make no request and open no pull request. (best practice) [sources: tests/roadmap/test_roadmap_pull_form.py]
    • Chosen: A fake model client. The test checks the number of calls and the stop with no network.
    • Rejected: A live model call. The result is not stable, and the test needs a network.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-07: partly.
Tool: pydantic-ai-slim (https://pypi.org/project/pydantic-ai-slim), MIT, last activity 2026-11-04, maintained.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 5, 2026
  2. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    ContributorAuthor

    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. Improves robustness of a non-critical path; the safe stop already exists.
    • Value: Medium. Prevents unnecessary item stops on a slightly malformed body, but the current stop is safe.
    • Effort: Medium. Needs a new prompt, a bounded retry step, and tests as stated in the body.
    • Related: feat(roadmap): the jobs build pull request text with pull_form #3215, which asks for a different change. Both work on PR text in the stage and implement jobs. #3215 integrates pull_form; the candidate adds a one-time model retry when the form refuses.
  3. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 5, 2026
  4. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    ContributorAuthor

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

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

    @devops-cli-service
    ContributorAuthor

    Alternatives check: partly

    Reason: Every search call this run failed with "no provider answered", so no result page could be read; the only tool facts read were the package facts of Pydantic AI, a library the project already depends on (ADR 0005 and ADR 0007 name it). Pydantic AI's agent layer already gives the reusable core of this item - a bounded retry of model output when a validator refuses it, with the problems fed back to the model - but it does not carry the project's own pull-request form rules, the placeholder refusal, the refused-reply failure class or the pull request write, so it covers only a part of the need.

    Tool: pydantic-ai-slim (https://pypi.org/project/pydantic-ai-slim)

    • License: MIT
    • Last activity: 2026-11-04
    • Maintained: yes

    Covers:

    • A model call that fails a validator can be retried with the validation problems passed back as feedback to the model
    • The retry count is bounded by the agent's configuration, so the job can stop after one rebuild and make no third call
    • Validators run on the model's output before the result is used, so a rebuilt text that passes is distinguishable from one that does not

    Lacks:

    • The project's own form rules in src/devops_cli/roadmap/pull_form.py (build_body, build_plan_body) and the is_placeholder refusal
    • The implement job's bounded free-text model step that writes the body from the change folder and the issue
    • The refused-reply failure class and the stop record of the stage and implement jobs
    • Writing the rebuilt title or body to the pull request and continuing the step
    • A shared retry function in src/devops_cli/roadmap/messages.py that both jobs call with no request inside pull_form.py

    Tools considered:

    Searches run:

    • instructor library retry LLM response on validation error, results: 0
    • pydantic-ai retry model output when validation fails ModelRetry, results: 0
    • pydantic-ai output validator retry ModelRetry, results: 0
    • retry LLM output validation errors library, results: 0
    • guardrails-ai reask, results: 0
    • pydantic-ai, results: 0
    • pydantic ai output validators retry, results: 0
    • pydantic ai agent retry validation error output, results: 0
    • LLM structured output repair loop library, results: 0
    • pydantic-ai output validator ModelRetry documentation, results: 0

    Sources:

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

  6. added
    owner/service
    on Nov 15, 2026
  7. 19 remaining items

  8. added
    status/in-review
    and removed
    status/blocked
    on Nov 16, 2026
  9. removed
    status/in-review
    on Nov 16, 2026
  10. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    ContributorAuthor
  11. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    ContributorAuthor

    Live since 2026-11-16 18:14 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