Skip to content

fix(roadmap): keep the diff of a step when a model call fails - #2781

Merged
dan-petty merged 10 commits into
mainfrom
fix/2731-keep-diff-on-model-failure
Oct 30, 2026
Merged

dan-petty merged 10 commits into
mainfrom
fix/2731-keep-diff-on-model-failure

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A step of devops roadmap implement now keeps the diff of its work when a model call fails.

Before this change, a failed model call raised a client error. The step reset the checkout, and the stop comment of the item held no diff. The case was worst in the extra turn for the ticks: every check had passed, and a person could not see the work.

Now _run_agent ends the turn as stopped for a ModelAPIError that is not a refused key. The outcome holds the masked, size-limited diff, the requests and the tokens (the failed request included), and the last text of the model. The ledger holds the spend of the failed turn. A ModelHTTPError with the status 401 or 403 still raises AICredentialsError and stops the whole run.

The reason of a failed model call holds the class of the error, the HTTP status when it has one, and the name of the model. It holds neither the message nor the body of the reply. mask_secrets does not find the value of a key such as x-api-key in the repr of a dict body, and the comment goes to GitHub. If git cannot give the diff, the step still ends as stopped, with the git error added to the reason.

Closes #2731

@dan-petty

Copy link
Copy Markdown
Owner Author

Test results

  • Full uv run devops ci: all checks pass. The test check took 3m 38s (218 s).
  • Fail-to-pass run (uv run devops ci fail-to-pass --base origin/main): 13 tests failed on base and pass on the branch (126 tests in tests/test_roadmap_implement_step.py and tests/test_roadmap_implement_job.py).

Review findings, both fixed test first

  • Major: the reason of a failed model call held the full str() of the error. mask_secrets does not mask x-api-key or api_key values in the repr of a dict body. Fixed: the reason now holds the class, the HTTP status and the model name only. A new test uses a dict body with both keys and checks that the secret is absent. The design and the spec now say this.
  • Minor: a git failure when the step read the discarded diff replaced the model error. Fixed: _read_discarded_diff returns an empty diff and adds the git error to the reason. A new test covers it.

Findings not fixed: none.

@dan-petty
dan-petty marked this pull request as ready for review October 30, 2026 14:29
…-model-failure

# Conflicts:
#	openspec/specs/roadmap-implement-step/spec.md
#	src/devops_cli/roadmap/implement_step.py
@dan-petty
dan-petty merged commit c6a837d into main Oct 30, 2026
19 checks passed
@dan-petty
dan-petty deleted the fix/2731-keep-diff-on-model-failure branch October 30, 2026 16:08
dan-petty pushed a commit that referenced this pull request Oct 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.22.5](v0.22.4...v0.22.5)
(2026-10-30)


### Bug Fixes

* **roadmap:** keep the diff of a step when a model call fails
([#2781](#2781))
([c6a837d](c6a837d)),
closes [#2731](#2731)
* **roadmap:** name the repo and cause in refine warnings
([#2784](#2784))
([85b3a67](85b3a67)),
closes [#2562](#2562)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): keep the diff when a model call fails in an implement step

1 participant