Skip to content

feat(roadmap): the tool log of an implement step names why an edit_file call was retried #2866

Description

@dan-petty

What happened

The implement Job devops-cli-runner-20261031-125802-ebfe for #2735 stopped at group 1 with:

UnexpectedModelBehavior: Tool 'edit_file' exceeded max retries count of 5.
Refused commands: 0. Other retries: 6.

The Job log, the stop comment and the discarded diff show the word retry for each failed call (Tool call: edit_file, retry.) and nothing else. The tool refuses an edit when old_text is missing from the file, when it appears more than once, when the file changed, or when the hash is stale. Each case returns a message to the model, and the message is the only evidence of the cause. The job does not keep it.

In this run the target is unambiguous (LESSOPEN and LESSCLOSE occur once in CONST_CODE_LOADING_ENV_PATTERNS), so the cause is not clear from the outside. The same word retry showed in the earlier stop on #2656.

What should happen

  • The tool log line of a retried call carries the reason that the tool returned, cut to a short length and masked of secrets, with the path of the call: for example Tool call: edit_file, retry (src/x.py: old_text not found).
  • The stop comment keeps the reasons of the last retries of the tool that ended the step, in the same bounded form.
  • The reason comes from the retry message of the harness tool (ModelRetry), not from a text match on the model's reply.

Evidence

Acceptance criteria

  • A test with a scripted model whose edit_file call misses its old_text shows the reason in the tool log line.
  • A secret in the retry message does not reach the log.
  • The stop comment of a step that ended on retries names the last reason.
  • The reason is cut to a constant length.
  • uv run devops ci passes.

Proposed design

Problem statement

The implement step tool log records only the word "retry" for a failed tool call. It does not record the reason the tool returned. When a step stops because a tool exceeded its retry limit, the stop comment and the discarded diff show no cause. A person cannot diagnose why a tool call failed from the outside.

Acceptance criteria

Requirement: Tool log shows retry reason

The tool log line of a retried call SHALL contain the reason from the ModelRetry message.

Scenario: edit_file old_text not found

  • WHEN a scripted model calls edit_file with an old_text that is not in the target file
  • THEN the tool log line contains the text from the ModelRetry message, truncated and masked

Requirement: Secret masking in log

A secret in the retry message SHALL NOT appear in the tool log line.

Scenario: secret in retry message

  • WHEN the ModelRetry message contains a string that matches the project secret pattern
  • THEN the tool log line does not contain that string

Requirement: Stop comment names last reason

The stop comment of a step that ended on retries SHALL name the last retry reason of the tool that ended the step.

Scenario: step ends on retries

  • WHEN a step tool exceeds its retry limit and the step stops
  • THEN the stop comment contains the reason of the last retry of that tool, truncated and masked

Requirement: Reason truncation

The reason in the tool log SHALL be cut to a constant maximum length.

Scenario: long reason truncated

  • WHEN the ModelRetry message is longer than the constant length
  • THEN the tool log line contains the reason cut to that constant length

Requirement: CI passes

uv run devops ci SHALL pass on the branch.

Scenario: CI passes

  • WHEN uv run devops ci is run on the branch
  • THEN all checks pass

Existing Tool Considered

No check has run. No open, maintained tool or library covers this need. It is an internal logging enhancement to the implement step tool log. The project builds this code itself. The cost is the tokens to add reason capture in the wrap_tool_execute hook, the truncation and masking logic, the stop-comment update, and the tests, plus the elapsed time to keep and fix it until it matches the behavior of a purpose-built logger.

Key questions

  • Which hook intercepts the ModelRetry so the reason can be read?: wrap_tool_execute. pydantic-ai does not call on_tool_execute_error for a ModelRetry. The archived design of fix(roadmap): an implement step that stops on UnexpectedModelBehavior hides the cause and logs no tool call #2758 confirms that wrap_tool_execute sees a ModelRetry as a ToolRetryError whose cause is the ModelRetry. [sources: openspec/changes/archive/2026-10-30-2758-implement-stop-cause/design.md:21, openspec/changes/archive/2026-10-30-2758-implement-stop-cause/proposal.md:32]
  • What constant length cuts the reason in the tool log line?: 120 characters. The example in the body ("src/x.py: old_text not found") is 28 characters. A ModelRetry message can be longer. 120 characters keeps the log line readable while preserving the cause. It is a named constant so a person can change it. (best practice) [sources: docs/ERRORS.md:82]
    • Rejected: 64 characters. Too short. A reason that names a file path and a condition exceeds 64 characters and would lose the condition.
    • Rejected: 120 characters. Chosen. Fits a file path plus a short condition. Keeps the log line under 200 characters total with the tool name and prefix.
    • Rejected: 256 characters. Too long for a log line. A ModelRetry message that is 256 characters is a paragraph, not a reason.
  • How does the log mask secrets in the reason?: Replace each substring that matches the project secret pattern with a fixed token such as [REDACTED]. The project already defines secret patterns for environment variables in ARCHITECTURE.md. The same patterns apply to the reason text before it is written to the log. (best practice) [sources: ARCHITECTURE.md:181]
    • Rejected: Regex replace with [REDACTED]. Chosen. Simple, deterministic, and uses the patterns the project already defines. No new dependency.
    • Rejected: Drop the entire reason if it contains a secret. Rejected. Loses the cause. A person cannot diagnose the failure.
    • Rejected: Hash the secret portion. Rejected. A hash is not readable and does not help a person identify the secret.
  • Where does the step store the last retry reason for the stop comment?: In the step state object that the stop-comment generator already reads. The wrap_tool_execute hook writes the reason into that object on each retry. The stop-comment generator reads the last value when it builds the comment. This keeps the data in the same scope as the step. (best practice) [sources: openspec/changes/archive/2026-10-30-2758-implement-stop-cause/design.md:7]
    • Rejected: Step state object. Chosen. The stop-comment generator already reads the step state. Adding one field is the smallest change.
    • Rejected: A separate log file per step. Rejected. Adds a file to manage and read. The step state is already in memory.
    • Rejected: A database row. Rejected. Overkill for a string that lives only for the duration of the step.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Oct 31, 2026
  2. dan-petty commented on Oct 31, 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. Diagnostic improvement for failed runs; does not block delivery or cause data loss.
    • Value: Medium. Helps operators diagnose retry failures without reading gateway logs, but does not prevent the failure itself.
    • Effort: Medium. Requires wiring the ModelRetry reason into the log recorder, masking secrets, truncating, and updating the stop comment plus tests.
    • Related: fix(roadmap): an implement step that stops on UnexpectedModelBehavior hides the cause and logs no tool call #2758, which asks for a different change. Both improve visibility of a failed implement step, but #2758 added the tool call log line and the stop-reason text, while the candidate adds the specific retry reason from ModelRetry into each log line.
  3. added
    priority/p2-medium
    on Oct 31, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 31, 2026
  5. devops-cli-service commented on Oct 31, 2026

    @devops-cli-service
    Contributor

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

  6. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Oct 31, 2026
  7. removed
    status/in-review
    on Oct 31, 2026
  8. added a commit that references this issue on Oct 31, 2026
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