Skip to content

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

Closed

Description

@dan-petty

Problem

devops roadmap eval verify stops on a case with StructuredOutputValidationError: The verification run stopped before it gave its findings: Tool <text> exceeded max retries count of 2. The pass reads the repository as an agent since #3039, and the run ends before the model gives its findings. The case counts as failed, so it gives no recall and no false-alarm count.

I saw it on 2026-11-06 with the model qwen3.8:27b of the verification task, at the commit that merged #3710. Three runs gave the same error: the good case of #3410 twice, and good-2739-the-subprocess-environment-guard-accepts-gh once. Each run took about 5 minutes before it stopped. The same model gave findings on the same cases with the single-call pass before #3039.

Expected

A run of the verification pass on a case gives its findings, or it names the cause of the stop. The cause is a text reply in place of the output tool, a refused tool call, or a run that has no budget left. The pass retries or ends the run with a reason that a person can act on.

Acceptance criteria

  • A run with a model that answers in text in place of the output tool gives the findings of the model or a stop whose message names the cause. A test with a scripted model shows the case.
  • devops roadmap eval verify --case <case> with the local verification model gives findings on the good case of fix(roadmap): the stage gate proves a negative search verify #3410 and on good-2739-the-subprocess-environment-guard-accepts-gh, or the report names why it cannot.

Existing tool considered

The harness is pydantic-ai, which raises the error after the output retries. Its option output_retries and its text output mode may cover the case. The change must read the pydantic-ai documents before it adds code.

Related

#3039 added the agent pass. #3688 holds a related fault of the same eval: two golden cases have no real base commit.

Proposed design

Problem statement

devops roadmap eval verify stops on a case with StructuredOutputValidationError: The verification run stopped before it gave its findings: Tool <text> exceeded max retries count of 2. The agent pass reads the repository since #3039, and the model qwen3.8:27b ends the run with an unknown tool call or a text reply instead of the output tool. run_error_message hides the quoted tool name as <text>, so the report names no cause. The case counts as failed, so it gives no recall and no false-alarm count. The pass must return the findings or stop with a cause that a person can act on.

Acceptance criteria

Requirement: Text reply accepted

The verification run SHALL accept a plain-text reply that holds the findings in place of the output tool call.

Scenario: Text reply holds the findings

  • WHEN A scripted model replies with text that holds the findings JSON and calls no output tool.
  • THEN The run returns those findings and records no stop.

Requirement: Text reply without findings

The verification run MUST stop with a reason that names the text reply when the text holds no findings.

Scenario: Text reply holds no findings

  • WHEN A scripted model replies with text that holds no findings and calls no output tool.
  • THEN The run stops with the reason text_reply and a message that names the text reply.

Requirement: Exhausted output retries

The verification run MUST map an exhausted output retry to a stop that names the retry limit.

Scenario: Output retries are exhausted

  • WHEN A scripted model gives an invalid findings call three times and the output retry limit is two.
  • THEN The stop names the retry limit 2 and the reason output_retries_exhausted.

Requirement: Refused tool call

The verification run MUST stop with a reason that names a refused tool call.

Scenario: Tool call refused

  • WHEN A scripted model calls a tool that the run does not offer.
  • THEN The run stops with the reason refused_tool_call and the name of the tool.

Requirement: Exhausted budget

The verification run MUST stop with a reason that names the exhausted budget.

Scenario: Budget exhausted

  • WHEN A scripted run reaches the tool-call or token limit.
  • THEN The run stops with the reason budget_exhausted and the name of the limit.

Requirement: Case report holds the stop reason

The eval verify report SHALL record the stop reason of each failed case.

Scenario: Failed case report

  • WHEN A case run stops with a typed reason.
  • THEN The JSON report holds that reason for the case, and the text report names it.

Existing Tool Considered

No alternatives check has run (alternatives is null). pydantic-ai, the open, maintained harness already in use, covers the need: its output mode accepts a union of Verification and str, so a text reply becomes the output, and its retries={\"output\": n} sets the output retry limit. It lacks a default that accepts text for a structured output type, so the change sets the union output type and validates the text with the existing _repair_and_validate_payload parser. It adds no library and no second parser.

Key questions

  • How does the verification pass get the findings when the model replies in text?: Set the agent's output type to the union of Verification and str, as pydantic-ai's union output mode describes, and validate the text with the existing _repair_and_validate_payload parser; a text reply that does not validate stops with text_reply. (best practice) [sources: src/devops_cli/ai/client/structured.py:103]
    • Chosen: Union output type with text. pydantic-ai accepts a text reply for the str member, so the run keeps the findings that the model gave.
    • Rejected: Higher output_retries. A higher limit repeats the 5-minute run and does not make the model call the output tool.
    • Rejected: Catch UnexpectedModelBehavior only. It reports the stop but loses the findings that the text holds. Keep it as the fallback.
  • Which parser reads the text reply?: The existing _repair_and_validate_payload in src/devops_cli/ai/client/structured.py, which repairs and validates a reply against the schema and is already tested; the change adds no second parser. (best practice) [sources: src/devops_cli/ai/client/structured.py:103, tests/ai/client/test_ai_client_structured.py:74]
    • Chosen: Reuse the existing parser. The single-call pass gave findings on the same cases, so its parser reads the same text, and it is already covered by a test.
    • Rejected: Add a new parser. A second parser duplicates the schema and its tests.
  • Which stop reasons must the pass name?: Four typed reasons: text_reply, refused_tool_call, budget_exhausted and output_retries_exhausted; investigate fills the reason and the tool or limit name from the captured messages, not from the masked message text. (best practice) [sources: src/devops_cli/roadmap/refine/refine_investigation.py:138, src/devops_cli/roadmap/refine/refine_investigation.py:452, src/devops_cli/roadmap/agent_run.py:113]
    • Chosen: Typed stop reason for each cause. The Expected lists the causes, and a typed reason lets the report and a test act on it.
    • Rejected: Pass the pydantic-ai message through. The raw message names Tool <text> and no cause that a person can act on.
  • Where does the pass read the name of the tool that a refused call names?: From the tool calls of the last model response, not from the error message: run_error_message replaces each quoted part, including a tool name, with <text>. [sources: src/devops_cli/roadmap/agent_run.py:113, src/devops_cli/roadmap/refine/refine_investigation.py:385]
  • Does the change increase the output retry limit?: No. Keep CONST_ROADMAP_REFINE_INVESTIGATION_RETRIES (2) for tools and output; the union output removes the retry loop for a text reply, and each retry costs about five minutes. (best practice) [sources: src/devops_cli/config/constants.py:3092, src/devops_cli/roadmap/refine/refine_investigation.py:433]
    • Chosen: Keep the limit. The union output type removes the retry loop for a text reply.
    • Rejected: Increase the limit. Each retry costs about 5 minutes and does not fix a model that never calls the tool.
  • Does the eval verify report hold the stop reason?: The JSON report already writes each failed case's error string (cases[].error), and the text report prints only the failed count. Add a typed reason to CaseOutcome, serialize it as cases[].reason, and print it next to the failed count. (best practice) [sources: src/devops_cli/roadmap/stage/stage_verify_eval.py:76, src/devops_cli/roadmap/stage/stage_verify_eval.py:249, src/devops_cli/roadmap/stage/stage_verify_eval.py:339, src/devops_cli/roadmap/stage/stage_verify_eval.py:370]
    • Chosen: Add a typed reason field. The report already has the free-text error; a typed field lets a test and the text report read the cause without parsing the message.
    • Rejected: Write the reason into error only. It mixes the typed cause with the masked message, so a test or a person must parse it.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-08: in-use.
The item already names this tool.
Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai), MIT, last activity 2026-11-08, maintained.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 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. The bug blocks the eval verify pass from producing findings on affected cases, but it does not stop development or expose a security risk.
    • Value: Medium. The eval verify pass is the quality gate for roadmap items, and a silent stop removes recall and false-alarm data.
    • Effort: Medium. The fix needs a text-output fallback or a named stop reason, a scripted-model test, and a read of the pydantic-ai docs.
    • Related: fix(roadmap): raise or configure implement tool retry budget #3271, which asks for a different change. Both deal with pydantic-ai tool retry limits in the roadmap agent, but #3271 fixes the implement step budget while the candidate fixes the eval verify pass text-tool stop.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

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

    Moved to new items: #3956.

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

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found pydantic-ai, the open, maintained harness the issue names as the one that raises the error; its configurable output retries and its output mode that accepts a text member cover the text reply and the exhausted-retry stop without a new library or parser. It lacks a default text fallback for a structured output type, so the pass still sets the union output type, validates the text with its existing parser and maps each stop to a typed reason.

    The item already names this tool.

    Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai)

    • License: MIT
    • Last activity: 2026-11-08
    • Maintained: yes

    Covers:

    • Raises the exhausted output retry that the pass can map to the typed reason output_retries_exhausted
    • Takes a configurable output retry limit, so the limit of 2 stays and is named in the stop
    • An output type that is a union with str accepts a plain-text reply in place of the output tool, so the findings are kept
    • Already the project's harness, so the change adds no library and no second parser

    Lacks:

    • No default that accepts text for a structured output type; the pass must set the union output type and validate the text with _repair_and_validate_payload
    • The error text masks the offending tool name as <text>, so the pass must read the tool name from the last model response
    • No typed stop reasons or eval report field; text_reply, refused_tool_call, budget_exhausted and output_retries_exhausted must be added by the pass and the report

    Tools considered:

    Searches run:

    • pydantic-ai output_retries text output instead of tool structured output, results: 5
    • pydantic-ai "exceeded max retries count" output tool text, results: 5
    • pydantic-ai agent retries output parameter documentation, results: 5
    • pydantic ai structured output retries docs, results: 5
    • pydantic-ai, results: 5
    • ai.pydantic.dev output retries structured output, results: 5
    • pydantic-ai UnexpectedModelBehavior retries tool, results: 5
    • pydantic-ai output docs, results: 5
    • pydantic-ai retries, results: 5
    • github pydantic-ai issue output retries text response instead of tool call, results: 5

    Sources:

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

  7. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    The same stop occurred again on 2026-11-13 with the model qwen3.8:27b of the verification task, at 0.128.0 (origin/main 2daf63a). The case 2166-the-unused-run-subprocess-re-import of uv run devops roadmap eval verify --case 2166 ended as failed:

    RoadmapStageError: A tool call of the run held invalid arguments, which are not one JSON text: Tool <text> exceeded max retries count of 2. ... The model made several tool calls in one reply and the gateway joined their arguments.

    The same case runs with --model deepseek-v4.1-flash-1017. So the configured local model still cannot run the agent pass of the eval.

  8. added
    owner/service
    and removed
    owner/service
    on Nov 16, 2026
  9. 64 remaining items

  10. removed
    status/in-review
    owner/agent
    on Nov 19, 2026
  11. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor
  12. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-19 11:42 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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions