Skip to content

feat(roadmap): a refused alternatives reply goes back once #4864

Closed

Description

@dan-petty

Problem or Motivation

A refused alternatives reply is not logged with its reason or counted, so the alternatives success rate is not known; 1 Ready item holds alternatives.failed_error=RefusedReply now. The item waits 3 days for the next try with no return.

Proposed Solution & Architectural Design

Log the reason code of a refused reply (alternatives.py) in the #4845 line. Run the fixable check (point alternatives.reply_fixable, #4847): fixable when the reason is a schema or form error and it does not repeat. Fixable -> one return with the reason, inside the 10 searches and 30 fact reads. Not fixable -> wait 3 days as today. Mode shadow until 5 refusals in 7 days with a fixable share of 2/3.

Target Subsystem

SDLC, Git & PR Governance (roadmap alternatives).

Existing Tool Considered

The #4847 chain and the #4845 result line. Cost to build: about 0.5M tokens, 3 hours.

Acceptance Criteria

Dependencies

#4845; #4847.

Source: #4843

Alternatives check of 2026-11-14: in-use.
The repository already uses this tool.
Tool: jd/tenacity (https://github.com/jd/tenacity), Apache-2.0, last activity 2026-11-01, maintained.

Proposed design

Problem statement

The alternatives job refuses a reply and then waits 3 days with no return, and the #4845 result line names only the class RefusedReply, so the reason and the alternatives success rate are not known; one Ready item holds alternatives.failed_error=RefusedReply now. This change gives each refusal a stable reason code, writes it in the result line and in the item's job record, classifies the refusal as fixable or not with the alternatives.reply_fixable point, and sends a fixable refusal back once through the existing output_check. The point runs a rule and ships in shadow; a person turns the one return on after the gate of 5 refusals in 7 days with a fixable share of 2/3.

Acceptance criteria

Requirement: Refusal reason code on the result line

The alternatives job SHALL write a stable reason code of a refused reply in the reason field of its #4845 result line.

Scenario: A refused reply names its reason code

  • WHEN the job refuses a reply whose reason is the message alternatives_reason_no_search
  • THEN the result line holds result=refused and reason=no_search

Requirement: Last refusal code in the job record

The alternatives job SHALL keep the reason code of the last refused reply in the item's job record.

Scenario: A refusal writes its code beside the error class

  • WHEN the job refuses a reply with the reason code no_search
  • THEN the job record holds alternatives.failed_reason=no_search and keeps alternatives.failed_error=RefusedReply

Requirement: One return for a fixable refusal

The alternatives job SHALL send a fixable refusal back to the model exactly once, with the reason, when the point's mode is on.

Scenario: A form refusal returns once and a valid reply records a verdict

  • WHEN the mode of alternatives.reply_fixable is on, the reply is refused with the form code no_tool, and the job record holds no earlier refusal with that code
  • THEN the rule gives the band review, output_check sends the reason back once, and a valid second reply records a verdict

Requirement: No return for a repeated reason

The alternatives job MUST NOT send a refusal back when its reason code equals the code in the item's job record.

Scenario: The same reason code twice

  • WHEN the reply is refused with a code that the item's job record already holds
  • THEN the rule gives the band continue, the job makes no second model call and sets the next try 3 days later

Requirement: 3-day wait for a not-fixable refusal

The alternatives job SHALL keep the 3-day wait for a refusal whose reason is not a schema or form error.

Scenario: A timeout reason waits 3 days

  • WHEN the run stops on UsageLimitExceeded, or the reply is cut by the output limit
  • THEN the code is not fixable, the rule gives the band continue, the job makes no second model call and sets the next try 3 days later

Requirement: Return inside the attempt budget

The alternatives job MUST keep the one return inside the 10 searches and 30 fact reads of the attempt.

Scenario: The return stops at the budget

  • WHEN the job makes the one return after a fixable refusal and the model calls search_web past the 10th search
  • THEN the tool answers the call as text with no search, and the attempt reports at most 10 searches and 30 fact reads

Requirement: Rule-only point with its table in the cuts file

The alternatives.reply_fixable point SHALL resolve with a rule and MUST read its fixable code table from its cuts file, not from a constant.

Scenario: The settings load accepts the point in shadow

  • WHEN roadmap.decisions sets alternatives.reply_fixable to shadow
  • THEN the settings load, and the cuts file of the point holds the fixable code table

Requirement: Shadow mode records the band only

The alternatives.reply_fixable decision point SHALL run in mode shadow and record its band with no change to the job behavior.

Scenario: Shadow records a band and keeps the 3-day wait

  • WHEN the mode of alternatives.reply_fixable is shadow and the reply is a fixable refusal
  • THEN the result line holds the band review and the job makes no second model call and sets the next try 3 days later

Existing Tool Considered

jd/tenacity (https://github.com/jd/tenacity), Apache-2.0, last activity 2026-11-01, maintained: the repository already uses this tool (src/devops_cli/ai/retries/__init__.py:15, src/devops_cli/http/retry.py:32). It covers a conditional retry and an attempt cap in general, but the one return itself needs no new retry code: investigate already sends the first refused reply back once through output_check and ModelRetry (src/devops_cli/roadmap/refine/refine_investigation.py:493, src/devops_cli/roadmap/alternatives.py:1148). It lacks the classification of a reason code as a schema or form error, the memory of a repeated reason, the write of the reason code into the #4845 result line, the alternatives success-rate count, the shadow mode and its gate, the 3-day wait and the enforcement of the 10 searches / 30 fact reads budget. That code stays in alternatives.py, at the written cost of about 0.5M tokens and 3 hours that the body gives.

Key questions

  • Which retry mechanism makes the one return after a refused reply?: The one return reuses the existing output_check path of investigate: _retry_once sends the message back with ModelRetry for the first refused reply only, so the model gets one more turn in the same run. No new retry loop and no tenacity call is added for it. (best practice) [sources: src/devops_cli/roadmap/refine/refine_investigation.py:493, src/devops_cli/roadmap/refine/refine_investigation.py:626, src/devops_cli/roadmap/alternatives.py:1148, src/devops_cli/roadmap/alternatives.py:1162, openspec/changes/archive/2026-11-01-2946-the-alternatives-check-must-search-before/design.md:9]
    • Chosen: The existing output_check and ModelRetry path. The alternatives job already passes output_check and counts the return, and the reason goes back into the same run, so the same UsageLimits and the same tool counters bound it.
    • Rejected: A tenacity retry around the run. It would start a second run with a new UsageLimits and a new tool counter, and it cannot put the reason into the same conversation as ModelRetry does.
    • Rejected: A hand-kept retry loop in alternatives.py. It repeats the one-return guard that _retry_once already gives and that the returns count already records.
  • Does the one return run with a new search and fact-read budget?: No. _retry_once is an output validator of the same agent.run_sync, so the return runs under the same UsageLimits and the same AlternativesTools counters. The 10 searches and 30 fact reads of the attempt still bound it, and no second budget is opened. [sources: src/devops_cli/roadmap/refine/refine_investigation.py:593, src/devops_cli/roadmap/refine/refine_investigation.py:628, src/devops_cli/roadmap/alternatives.py:1155, src/devops_cli/config/constants.py:3495, src/devops_cli/config/constants.py:3496]
  • Where does the job write the reason code, and where does it keep the memory of a repeated reason?: The feat(roadmap): log one result line for each roadmap job attempt #4845 result line's reason field holds the code of a refused reply; today alternatives.py passes error_class there, which is RefusedReply. The memory that a reason repeated is a new job-record key alternatives.failed_reason, written beside alternatives.failed_error and cleared when a check is written. alternatives.failed_error keeps the class RefusedReply, as docs/ROADMAP_WORKFLOW.md and the result-line test state; a log line is not a durable store. (best practice) [sources: src/devops_cli/roadmap/alternatives.py:1377, src/devops_cli/roadmap/alternatives.py:1392, src/devops_cli/roadmap/stores/store.py:210, src/devops_cli/roadmap/job_result.py:8, docs/ROADMAP_WORKFLOW.md:138, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:78, src/devops_cli/config/constants.py:3516]
    • Chosen: The result line plus a new alternatives.failed_reason record key. The line is the per-attempt record that the gate counts, and the job record is the durable copy that the next run reads, while failed_error keeps its documented class.
    • Rejected: Put the code in alternatives.failed_error. The key is documented as the class of the error, holds RefusedReply, and the existing result-line test pins that value.
    • Rejected: Read the code back from the Loki line. A log line is not the store of a decision; ADR 0021 keeps the GitHub job record as the source of truth.
  • How does the job decide that a refusal is fixable, and with what resolver?: A refusal is fixable when its reason is the reply's form or schema and its code is not already in the item's job record. The form reasons are the keys of _refusal (alternatives_reason_skip_only, _job_verdict, _no_search, _no_tool, _no_facts, _url); the schema reason is the run stop with schema_broken. A timeout, an output-limit cut, invalid tool-call JSON, a provider error and an inventory read error are not fixable. A rule gives the band, and its code table is data in the point's cuts file; no model takes part. (best practice) [sources: src/devops_cli/roadmap/alternatives.py:770, src/devops_cli/roadmap/refine/refine_investigation.py:549, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:60, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:70, src/devops_cli/roadmap/decision_table.py:22]
    • Chosen: A rule whose code table is data in the point's cuts file. The reason is deterministic at the refusal, so a rule answers it; ADR 0020 puts a proven rule before a model, and a point in shadow needs a cuts file, which this file gives.
    • Rejected: A model resolver on the point. No labelled refusal outcome exists to fit a cut, and ADR 0020 adds a model only where it is measured to add to the rule.
    • Rejected: The code table as a constant in alternatives.py. ADR 0020 refuses a parameter that is a guess in a constant; the parameters of a rule are data, and a shadow point must name its cuts file.
  • What does the job do in shadow mode?: In mode shadow the point runs its rule, records its band, and the job behaves as it does today: no second model call, the next try 3 days later. The one return acts only when the mode is on. (best practice) [sources: CONTEXT.md:138, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:64, docs/CONFIGURATION.md:308]
    • Chosen: Record the band and keep today's wait. ADR 0020 says shadow records the answer and the workflow acts as with off.
    • Rejected: Apply the return from the first release. It skips the measured record that ADR 0020 requires before a person turns the point on.
  • How does the gate count 5 refusals in 7 days and the fixable share of 2/3?: From the feat(roadmap): log one result line for each roadmap job attempt #4845 result lines: each refused attempt writes result=refused, its reason code and its fixable band, so one Loki count_over_time over 7 days gives the refusal count and the share of lines whose band is review. No new counter is added; the lines are the per-attempt record that the job grade already reads. (best practice) [sources: src/devops_cli/roadmap/job_result.py:1, CONTEXT.md:142, docs/roadmap/job-success.md:22, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:84]
    • Chosen: Count from the result lines in Loki. The line already exists for each attempt, and the gate is a one-time read of the record that ADR 0020 asks for.
    • Rejected: Add a Prometheus counter for refusals. It adds a series for a one-time gate, and the result line already holds the reason and the band.
  • Is the promotion from shadow to on part of this change?: No. A person turns the point on after reading the record and the fit report, so this change ships the point in shadow. The gate of 5 refusals in 7 days with a fixable share of 2/3 is the evidence for that later decision, and a later change makes it. (a person decides) [sources: docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:84, docs/CONFIGURATION.md:308]
  • Does this change still wait on feat(roadmap): log one result line for each roadmap job attempt #4845?: No. The feat(roadmap): log one result line for each roadmap job attempt #4845 result line is merged: src/devops_cli/roadmap/job_result.py and the alternatives writer that logs it are in the tree, and the change folder is archived. feat(roadmap): add the soft-cap and fix-check chain to decision points #4847 (the soft-cap chain of decision points) is still Status New, so the dependency on it stands. [sources: openspec/changes/archive/2026-11-12-4845-log-one-result-line-for-each/proposal.md:9, src/devops_cli/roadmap/job_result.py:1, src/devops_cli/roadmap/alternatives.py:1385, openspec/changes/archive/2026-11-13-4851-extend-stage-gate-returns/proposal.md:44]

Open questions

  • Is the promotion from shadow to on part of this change? (a person decides)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4847

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. It improves observability of the alternatives success rate and adds one conditional retry, but no live item is blocked by its absence.
    • Value: Medium. Users gain a visible success rate and one faster retry for fixable refusals, which reduces idle wait time.
    • Effort: Low. The body states about 0.5M tokens and 3 hours of work, scoped to one file and two tests.
    • Related: fix(roadmap): a failed alternatives check skips its item and does not fail the round #2949, which asks for a different change. Both handle alternatives check failures, but #2949 isolates a failed item from the round and retries after days, while the candidate logs the reason code and allows one immediate return for fixable refusals.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found no tool that logs the alternatives refusal reason code, classifies a refusal as fixable or counts the success rate; that part stays in alternatives.py. The general retry library tenacity covers only the retry mechanism the issue asks for: a predicate chooses which failures get another try, and an attempt cap gives exactly one return.

    The repository already uses this tool.

    Tool: jd/tenacity (https://github.com/jd/tenacity)

    • License: Apache-2.0
    • Last activity: 2026-11-01
    • Maintained: yes

    Covers:

    • Conditional retry: a predicate or exception type selects the failures that get another try, so only the fixable reasons return
    • An attempt cap, so one extra try after a refused reply is expressible
    • A wait/backoff policy between the two tries

    Lacks:

    • No classification of a refusal reason code as a schema/form error, and no memory that a reason repeated
    • Does not write the reason code into the feat(roadmap): log one result line for each roadmap job attempt #4845 result line or count the alternatives success rate
    • No shadow mode or gate at 5 refusals in 7 days with a 2/3 fixable share
    • No 3-day wait for a not-fixable reply, and no enforcement of the 10 searches / 30 fact reads budget

    Tools considered:

    Searches run:

    • instructor pydantic max_retries validation error reask structured output, results: 5
    • python library retry on validation error only, skip retry on repeated reason, results: 5
    • stamina python retry library on predicate exception, results: 5
    • tenacity retry_if_exception predicate stop_after_attempt python, results: 5
    • tenacity documentation retry_if_exception_type stop_after_attempt, results: 5
    • pydantic-ai retry validation error structured output, results: 5
    • tenacity, results: 5
    • python retry library, results: 5
    • jd/tenacity github retrying library README retry_if_exception, results: 5
    • tenacity python retry stop_after_attempt retry_if_exception_type example, results: 5

    Sources:

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

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

    @devops-cli-service
    Contributor

    Owner question: Is the promotion from shadow to on part of this change? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. added
    status/in-progress
    and removed
    status/new
    on Nov 16, 2026
  8. added
    status/in-review
    and removed
    status/in-progress
    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
    Contributor

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