Skip to content

fix(roadmap): raise or configure implement tool retry budget #3271

Closed

Description

@dan-petty

Problem Description

The implement runner stops with UnexpectedModelBehavior when a tool reaches five retries.
In src/devops_cli/config/constants.py, CONST_ROADMAP_IMPLEMENT_TOOL_RETRIES hardcodes this limit to 5.
Pydantic AI counts retries across the full execution of the task group.
Long steps with many tool calls hit this limit easily.
Minor command refusals or shell syntax errors accumulate until the fifth retry aborts the step.
This aborted task group 2 during the implementation of issue #2572.

Reproduction Steps

  1. Configure an item with multiple tasks in a group.
  2. Run devops roadmap implement --item <number>.
  3. Cause the agent to encounter five tool retries (such as shell refusals) across 50 requests.
  4. Observe the step abort with UnexpectedModelBehavior: Tool 'shell' exceeded max retries count of 5.

Expected vs Actual Behavior

Expected the tool retry limit to be configurable and sized for long multi-turn sessions.
Actual behavior hardcodes the limit to 5 across the entire task group.

Target Subsystem

src/devops_cli/roadmap/implement_step.py, src/devops_cli/config/constants.py

Existing Tool Considered

None. This is internal implement job configuration.
The cost to fix is tuning CONST_ROADMAP_IMPLEMENT_TOOL_RETRIES or adding settings.roadmap.implement.tool_retries.

Evaluation 2026-11-04

The stated cause is wrong. Pydantic AI does not count retries across the full execution. pydantic_ai/tool_manager.py:331-342 removes a tool that succeeded from the retry count, so the count is of failures in a row. A higher limit only moves the stop. In the window 2026-11-03T15:05Z to 2026-11-04T15:05Z, 11 stops have the class refused_tool. They hold 201 refused commands, at most 37 in one run (#2116, 2026-11-04T05:58Z), and 45,964,971 input tokens. One stop has no table, so the token sum is a low count.

The title no longer fits. Proposed title: fix(roadmap): a shell refusal of the implement step counts no tool retry.

Design that replaces the text above.

  1. A policy refusal returns a normal tool result that names the replacement, and it counts no retry. A real failure of a tool still counts. _execute in src/devops_cli/roadmap/implement_shell_refusal.py can return text in place of raise ModelRetry.
  2. The agent shell allows a read pipe through a table of allowed right-hand programs, such as head, grep and wc. Removing | from CONST_ROADMAP_IMPLEMENT_DENIED_OPERATORS (constants.py:3247-3259) would also allow | sh, because the harness reads the first word only. A leading cd <checkout> && is harmless. Verification lines stay a list of words with no shell (openspec/specs/roadmap-implement-step/spec.md:70).
  3. Extend the known-program table of logged_program, or log a digest as the trace does. Never write a free first word: src/devops_cli/roadmap/implement_tool_log.py:119-127 says that it can hold a secret. A change to that rule goes to the owner. The word other is 91 of the 201 refused commands.
  4. A limit on total refusals in a step stops a loop. The plan names the number, the failure class and the stop text.
  5. This issue replaces criterion 3 of feat(roadmap): the implement agent can use the project's development tools #3041, "The refusal limit counts only calls that the catalog has no entry for". The two rules differ, so reword it against SHELL_PROGRAMS. Edit feat(roadmap): the implement agent can use the project's development tools #3041 in the same pass, to remove the criterion and to name this issue under a ### Dependencies heading above its refine block.

Decision on roadmap.implement.tool_retries. Drop the setting and the default of 50. When a refusal counts no retry, the count holds only real failures in a row, and the constant of 5 stays right for them. The requirements on the setting in the refine block go.

Spec. The plan needs MODIFIED deltas for openspec/specs/roadmap-implement-step/spec.md:106, :150, :180, :304-308 and :335.

Size. Item 1 is small. Items 2 and 3 are larger, so split them into a second issue if the plan does not fit one pull request. #3053 also names shell refusals. It is broader and stays open.

Refused commands in the text of a plan task add to this count. A task that tells the agent to run !, a pipe or helm costs retries on the plan's own text.

Proposed design

Problem statement

placeholder

Acceptance criteria

Existing Tool Considered

placeholder

Key questions

None.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 2, 2026
  2. dan-petty commented on Nov 2, 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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It causes complete loss of work on long multi-tool steps, but shorter steps or fewer tool calls can work around it.
    • Value: Medium. It prevents aborts and work loss in legitimate long implement sessions that exceed five retries.
    • Effort: Low. The fix is changing one constant or adding one config key in two files.
    • Related: perf(roadmap): raise the soft caps and request timeouts of the jobs #3206, which asks for a different change. Both adjust limits in config/constants.py for the implement step, but #3206 raises total call and token caps while the candidate targets the per-tool retry count.
  3. added
    priority/p2-medium
    on Nov 2, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 3, 2026
  5. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    The stage job returned the item to New. The premise of the issue does not hold at the staging commit, so the job planned no change and opened no pull request.

    Evidence:

    placeholder

  7. added
    status/new
    and removed
    status/ready
    on Nov 3, 2026
  8. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    The stage comment of 2026-11-03T00:28Z gave the evidence placeholder. That text is false, because it is no finding on the premise. The real problem with the premise is in the section Evaluation 2026-11-04 of the body: the retry count is of failures in a row. Do not set Ready by hand, because the stage job would then plan from the refine block, which sets a default of 50. The body edit starts a new refine round, and refine then writes the block again.

  9. added
    priority/p1-high
    and removed
    priority/p2-medium
    on Nov 4, 2026
  10. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    The owner asked for this priority change on 2026-11-04. The blocker rule sets P1 here: this item blocks #2116, #2462 and #2469, which are P2. It is also the largest stop class in the window, with 11 of 39 stops.

  11. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 67d3f47 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • The proposal has no problem statement, no acceptance criterion with its requirement, scenario, WHEN and THEN, or no answer to the existing-tool question. State the problem, the requirements with their scenarios, and the open tool that covers the need or the cost of building it.
  12. removed
    status/new
    on Nov 4, 2026
  13. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-04 22:29 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/p1-highscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions