Skip to content

fix(roadmap): Name the cause of a stopped verification run - #6333

Merged
dan-petty merged 5 commits into
mainfrom
fix/3717-the-agent-verification-pass-stops-with
Nov 19, 2026
Merged

dan-petty merged 5 commits into
mainfrom
fix/3717-the-agent-verification-pass-stops-with

Conversation

@devops-cli-service

@devops-cli-service devops-cli-service Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

devops roadmap eval verify stopped a case with Tool <text> exceeded max retries count of 2. That message names no tool and no limit, and the case failed with no reason, so a person could not act on the stop.

This change types the stop of an agent run from its messages. stop_cause gives one reason of the closed set StopReason: a refused text reply, a call to a tool that the run does not offer, a call to an offered tool with arguments that break its schema, arguments that are no JSON text, a cut reply, used output retries, a used budget, a starved window or a failed model call. pydantic-ai gives one message for an unknown tool and for an offered tool with bad arguments, so the names of the offered tools tell them apart. The stop message of the verification pass names the cause. The eval report records cases[].reason and names the reason of each failed case.

Closes #3717

Change: openspec/changes/archive/2026-11-19-3717-the-agent-verification-pass-stops-with/

@devops-cli-service devops-cli-service Bot added scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must labels Nov 18, 2026
@devops-cli-service
devops-cli-service Bot force-pushed the fix/3717-the-agent-verification-pass-stops-with branch 3 times, most recently from d52c35b to 20e42cd Compare November 18, 2026 23:02
@devops-cli-service

Copy link
Copy Markdown
Contributor Author

The steps of the job:

Step Status Attempts Tokens in/out Last failing command
group 1 done 1 12617925/44758 pytest on base: tests/roadmap/refine/test_roadmap_refine_investigation.py
group 2 done 1 14798565/47616 pytest on base: tests/roadmap/stage/test_roadmap_stage_toolbox.py
group 3 done 1 6274708/17120 pytest on base: tests/roadmap/stage/test_roadmap_stage_verify_eval.py

@dan-petty

Copy link
Copy Markdown
Owner

Advisory pre-merge review (automated; a person decides).

Recommendation: hold. The change names the wrong cause for a stop that the issue reports, and the change exists to name the correct cause.

Reviewed head: 96a6ab2854e3683257e4ee6f418c3dce781b33a6.

Findings

Severity Where Problem Evidence Fix
major src/devops_cli/roadmap/agent_run.py:313-320 (stop_cause), src/devops_cli/lang/en/messages.py:4431-4433 (stage_verify_stop_refused_tool) stop_cause gives REFUSED_TOOL_CALL to every stop with the text "Tool X exceeded max retries count of N". pydantic-ai gives the same text when the model calls an offered tool with arguments that fail validation. The review message then says that the run does not offer a tool that it does offer. For joined (invalid JSON) arguments, the error text says "invalid arguments", but trace.stop_reason, cases[].reason and the per-case line say refused_tool_call. The 2026-11-13 comment on #3717 reports exactly this stop. A probe on the PR head: an agent offers read_file(path: str), and the model calls read_file({"wrong": 1}). Output: Tool 'read_file' exceeded max retries count of 2 and then StopCause(reason=REFUSED_TOOL_CALL, detail='read_file', limit=2). A second probe with joined arguments {"path": "a"}{"path": "b"} gives the same reason. _stopped_outcome computes invalid_arguments (refine_investigation.py:567), but stop_cause does not use it. #3717 comment of 2026-11-13: A tool call of the run held invalid arguments ...: Tool <text> exceeded max retries count of 2. Use REFUSED_TOOL_CALL only when the tool name is not in the offered tool names (or the retry prompt starts with "Unknown tool name"). Give a validation failure of an offered tool, and an invalid-arguments stop, their own reason and message text. Add a test for each case to test_a_stopped_verification_run_names_its_cause.
minor src/devops_cli/roadmap/stage/stage_toolbox.py:224, :230 No test asserts the new stop_reason values model_error and window_starved, or their stop_detail. The eval report shows these reasons for a failed case. A grep of tests finds no stop_reason or stop_detail assertion for these values. Coverage shows that the lines run, but no assertion checks them. Add trace.stop_reason and trace.stop_detail assertions to an existing window-starved test and an existing AIClientError test.
nit src/devops_cli/roadmap/stage/stage_toolbox.py:85-86, src/devops_cli/roadmap/agent_run.py:220 The stop reasons are one closed set, but the PR keeps 4 values in StopReason and 2 values as bare strings. RunTrace.stop_reason and CaseOutcome.reason are typed str, so the type checker does not check a reason. _STOP_WINDOW_STARVED: Final = "window_starved", _STOP_MODEL_ERROR: Final = "model_error". CONTRIBUTING.md line 16 (closed set of cases in one match or table). Add WINDOW_STARVED and MODEL_ERROR to StopReason, and type the fields as StopReason or StopReason | None.
nit src/devops_cli/roadmap/refine/refine_investigation.py:214, :591 InvestigationStopped.texts is a copy of cause.texts. No code reads it. grep -rn '\.texts\b' src tests/roadmap finds only the assignment at line 591 and reads of cause.texts. Remove the field and read cause.texts.
nit src/devops_cli/roadmap/stage/stage_toolbox.py:298-299 The branch for cause is None in _review_stopped cannot run. The only constructor of InvestigationStopped sets cause. Coverage shows line 299 as missing. grep -rn "InvestigationStopped(" src finds only refine_investigation.py:584, which passes cause=cause. Make cause required, or remove the branch.
nit tests/roadmap/stage/test_roadmap_stage_toolbox.py:317 test_a_text_reply_that_holds_the_findings_gives_them passes on the base too. It guards existing pydantic-ai behavior. It does not prove a change of this PR. On a worktree at origin/main with the head test files: 3 new tests failed, this test passed. No code change. Say in the PR body that this is a guard test.
nit PR body The body tells only why. It does not tell what the change does. It also says Closes #3717, but nobody ran the live acceptance criterion (devops roadmap eval verify --case), and the major finding above affects the stop that was seen last. CONTRIBUTING.md:176 ("what the change does, and why"). tasks.md Criteria: "Pending person ... a person runs the command after the merge." Add one sentence on what the change does. After the fix, run the live command on case 2166, or say that the criterion stays open for a person.

What is good

  • Each task group of the plan is in the diff. All changed files are on a Changes: line of the plan. The archive is a pure rename, and tasks.md changes only its checkboxes.
  • The diff removes, skips or loosens no test. 3 of the 4 new tests fail on the base and pass on the head.
  • All CI checks at the head are success or skipped. devops docs generate --check reports no drift. No private data.

Checks that ran

  • Probe of stop_cause on the PR head with an offered tool and invalid arguments (result above). I ran it again for this report and got the same result.
  • devops ci test on the 3 changed test files: 175 passed. Dependent modules: 4241 passed, 1 skipped (the skip is an existing test).
  • Fail-to-pass on a base worktree at origin/main 6ff83d4: 3 failed, 1 passed (the text-reply test).
  • ruff check, ruff format --check, C901 and PLR1702 on the 8 changed Python files: pass. mypy --strict on the 5 changed source files: no error.
  • devops docs generate --check: all documentation files are up to date.
  • Read of the fix(roadmap): the agent verification pass stops with a text tool error #3717 comments through devops gh api.

@dan-petty
dan-petty marked this pull request as draft November 19, 2026 01:29
@dan-petty
dan-petty force-pushed the fix/3717-the-agent-verification-pass-stops-with branch from 96a6ab2 to 3ea6dfe Compare November 19, 2026 01:53
@dan-petty

dan-petty commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Fix of the advisory review of 2026-11-18 (head 3ea6dfe9d).

Findings

Finding Result
major: stop_cause gives refused_tool_call to an offered tool with invalid arguments Fixed. stop_cause now takes the names of the tools that the requests of the run offered (the record of the _offering hook). Only a name outside that set gives refused_tool_call. A call to an offered tool past the tools retry limit gives tool_retries_exhausted, with its own text stage_verify_stop_tool_retries, which does not say that the run does not offer the tool. Arguments that are no JSON text give invalid_arguments with the tool name. stop_cause is now the one classifier: it reads the output cut and the invalid arguments, and _stopped_outcome sets output_limit and invalid_arguments from its reason, so trace.stop_reason, cases[].reason and the error message name the same cause. The new cases are in test_a_stopped_investigation_names_its_cause and in the new test test_a_review_run_that_calls_an_offered_tool_with_invalid_arguments_names_no_refused_tool.
found during the fix: a reply that the output token limit cut gave output_retries_exhausted, but the error said "output token limit" Fixed with the reason output_limit. test_a_reply_cut_by_the_output_token_limit_stops_the_run_and_is_not_a_broken_schema asserts it.
minor: no assertion of model_error and window_starved Fixed. test_a_failed_model_call_raises_the_clients_own_error asserts model_error and AIClientError. test_a_review_run_whose_tools_the_window_ends_too_soon_fails_and_names_the_review_window asserts window_starved and 12000.
nit: reasons split between the enum and bare strings Fixed. WINDOW_STARVED and MODEL_ERROR are in StopReason. RunTrace.stop_reason and CaseOutcome.reason are StopReason | None. The JSON report writes null for a case with no stop.
nit: InvestigationStopped.texts that nothing reads Fixed. The field is gone; callers read cause.texts.
nit: the cause is None branch that cannot run Fixed. cause is a required field, and _review_stopped is gone. The one test that built InvestigationStopped (test_failure_record_the_reason_of_a_stopped_run_holds_its_message) now gives a cause.
nit: test_a_text_reply_that_holds_the_findings_gives_them passes on the base No code change. It is a guard test of the pydantic-ai text output (AutoOutputSchema). It shows the first acceptance criterion and does not prove a change of this pull request.
nit: the body tells only why Fixed. The body now tells what the change does. Closes #3717 stays: the project records the live proof as a comment on the issue after the merge.

The archive commit was made again after the fix, so the folder is now openspec/changes/archive/2026-11-19-3717-the-agent-verification-pass-stops-with/. The spec delta, tasks.md, proposal.md and design.md name the new reasons.

Test record

  • devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures: all pass.
  • devops ci test on the 4 changed test files: 355 passed.
  • devops ci test on the tests that cover agent_run.py, refine_investigation.py, stage_toolbox.py and stage_verify_eval.py: 1439 passed.
  • mypy on the 5 changed source files: no issues.

Fail-to-pass

devops ci fail-to-pass --base 4d4c49f94 (the head of the branch before this fix):

failed on base: tests.roadmap.stage.test_roadmap_stage_toolbox::test_a_review_run_that_calls_an_offered_tool_with_invalid_arguments_names_no_refused_tool (AssertionError: assert [(<StopReason... 'read_file')] == [('tool_retri... 'read_file')])
failed on base: tests.roadmap.refine.test_roadmap_refine_investigation::test_a_reply_cut_by_the_output_token_limit_stops_the_run_and_is_not_a_broken_schema (AssertionError: assert ('UnexpectedM...s_exhausted'>) == ('UnexpectedM...output_limit'))
failed on base: tests.roadmap.refine.test_roadmap_refine_investigation::test_a_stopped_investigation_names_its_cause (AssertionError: assert [(<StopReason...file', 2, ())] == [('text_reply...e', None, ())])
3 failed on base (3 failed and 313 passed in tests/roadmap/refine/test_roadmap_refine_investigation.py, tests/roadmap/stage/test_roadmap_stage_toolbox.py, tests/roadmap/test_roadmap_alternatives.py; 0 errored).

Live check after the merge

A person runs uv run devops roadmap eval verify --case <case> with the local verification model on the good case of #3410, on good-2739-the-subprocess-environment-guard-accepts-gh and on 2166-the-unused-run-subprocess-re-import, and records the result as a comment on #3717. Each case gives findings, or the report names its stop reason. For the stop of the 2026-11-13 comment, the expected reason is invalid_arguments with the tool name, and not refused_tool_call.

Checks of head 3ea6dfe9d

devops-cli-service Bot and others added 5 commits November 19, 2026 04:24
…ason (#3717)

pydantic-ai gives the same 'Tool <name> exceeded max retries' message for a call to an unknown tool and for an offered tool whose arguments fail validation. stop_cause now reads the tools that the run offered: only an unknown tool gives refused_tool_call, an offered tool gives tool_retries_exhausted. Arguments that are no JSON text give invalid_arguments, and a cut reply gives output_limit, so the report reason and the error message name the same cause. window_starved and model_error join StopReason, RunTrace and CaseOutcome type the reason, and InvestigationStopped requires its cause.
@dan-petty
dan-petty force-pushed the fix/3717-the-agent-verification-pass-stops-with branch from 3ea6dfe to 125fc9a Compare November 19, 2026 04:33
@dan-petty
dan-petty marked this pull request as ready for review November 19, 2026 04:53
@dan-petty
dan-petty merged commit bbf308d into main Nov 19, 2026
24 checks passed
@dan-petty
dan-petty deleted the fix/3717-the-agent-verification-pass-stops-with branch November 19, 2026 11:12
dan-petty-release Bot added a commit that referenced this pull request Nov 19, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.179.5](v0.179.4...v0.179.5)
(2026-11-19)


### Bug Fixes

* **ai:** bound the number of prewarm model label values
([#6391](#6391))
([e3fa4f1](e3fa4f1))
* **ci:** count a changed test that errors on base as proof
([#6379](#6379))
([6881b4c](6881b4c))
* **deps:** update Helm release argo-cd to v10.18.2
([#6398](#6398))
([2604ace](2604ace))
* **infra:** Fix the offline separator of a comma limit
([#6387](#6387))
([98493e4](98493e4))
* **roadmap:** Name the cause of a stopped verification run
([#6333](#6333))
([bbf308d](bbf308d))
* **roadmap:** Stage a long plan body and a null optional text
([#6351](#6351))
([053aabc](053aabc))
* **telemetry:** Keep the age metrics' reads across pods
([#6326](#6326))
([ad0ee60](ad0ee60))


### Code Refactoring

* **ai:** rank the benchmark with numpy and pytrec-eval
([#6388](#6388))
([051217e](051217e))

---
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

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): the agent verification pass stops with a text tool error

1 participant