Skip to content

feat(roadmap): count tool call errors by class for each workflow #5179

Open

Description

@dan-petty

Part of #5164 (child 13).

Problem or Motivation

The owner wrote on 2026-11-12, word for word:

monitoring tool call errors could give an early indicator of what is causing job failures

Facts on 2026-11-12 (7 days):

  • devops_cli_roadmap_tool_calls_total has the labels row, tool, toolset and outcome (ok, empty, error). Only the stage planner (stage) and the verifier (stage_verify) emit it: 49 errors of about 30,800 calls, and 77 of about 8,250. It has no error class. Refine, alternatives, fix-plan, review and the implement runner do not emit it.
  • The implement runner writes one log line for each tool call (Tool call: run_command, program other:<hash>, refused.). Loki has 4,646 ok, 175 refused (shell 165, run_command 10) and 2 retry lines, and 2,560 "Tool call:" lines in another form. So 6.9% of shell calls were refused. Only log parsing finds this.
  • The implement attempt on refactor(ai): rank the benchmark with numpy and pytrec-eval #1928 stopped with the class types. No measure shows the type-check tool calls before the stop.
  • A devops usage error of an agent is counted as cli_usage_error (feat(telemetry): record each CLI usage error by name and kind #4973). The owner wants these assessed through the self-improvement loop (feat(telemetry): rank CLI usage errors and propose fixes #4840).
  • build(deps): move pydantic-ai to 2.68 and its retry parts #5098: from pydantic-ai 2.60, the framework does not build RetryPromptPart (the pin is 2.59.0). After that move, a count of schema retries from RetryPromptPart gives 0 with no error.

Proposed Solution & Architectural Design

  • One counter for every agentic workflow. Every workflow that gives tools to a model emits devops_cli_roadmap_tool_calls_total with row (the job of the result line), tool, toolset, outcome (ok, empty, error, refused) and the new label error_class: none, refused (shell allowlist or path rule), exit_nonzero, timeout, output_cap, invalid_args (schema or argument validation, counted in the tool wrapper, not from message parts), model_error, cli_usage (a devops usage error, feat(telemetry): record each CLI usage error by name and kind #4973). The implement runner emits the counter from its tool dispatch. It keeps its log line, and the line is no longer the measure.
  • On the result line (through the attempt context of feat(roadmap): result lines state first-pass, model calls and cost #5168): tool_calls, tool_errors, and the name tool_error_top (the tool with the most errors in the attempt, or none). So one line joins the tool errors of an attempt with its result and its failure class.
  • Report (devops roadmap eval grades, feat(roadmap): eval grades prints the grade of each workflow #5165): for each workflow, the tool error rate for each tool and version next to the grade. For a workflow under 80, the top 3 failing tools with their error classes, and the failure classes of the attempts that had them (for example shell refused before plan_defect, type-check errors before types).
  • Alert (Prometheus rule with a promtool test and a runbook row): RoadmapToolErrorsRise, the 24-hour error ratio of a tool in a row is 2 times or more its 7-day ratio of the day before, with 50 or more calls. The release compare of feat(roadmap): find a success or efficiency change after a release #5175 adds the tool error rate as a measure.
  • Tempo spans of pydantic-ai runs stay a drill-down tool: they are sampled, and the privacy defaults keep tool content off.

Target Subsystem

SDLC, Git & PR Governance (src/devops_cli/roadmap/, the implement runner) and AI & Agentic Review Pipeline (src/devops_cli/review/).

Existing Tool Considered

The counter exists, and this item extends its rows and adds one label. Tempo (TraceQL metrics) can count span errors, but the spans are sampled and hold no error class. pydantic-ai gives no counter of tool errors. Cost: about 300,000 tokens, 7 hours elapsed.

Acceptance Criteria

  • A refused shell call in a fake runner adds 1 to outcome="refused", error_class="refused" for its tool and row.
  • An argument validation error in a planner tool adds 1 to error_class="invalid_args".
  • An attempt with 3 refused shell calls writes tool_errors=3 tool_error_top=shell on its result line.
  • promtool test rules passes for RoadmapToolErrorsRise: it fires on a 3 times rise with 60 calls, and stays quiet with 40 calls.
  • The report shows the top failing tools of a workflow under 80 on a fixture.

Dependencies

#5165 (the report), #5168 (the attempt context).

Alternatives check of 2026-11-19: none.
Tool: none found.
Reason: Searches found open LLM observability platforms (Langfuse, Phoenix, OpenLLMetry, Logfire), but they record tool calls as trace spans; none extends a per-workflow Prometheus counter with an error_class label, result-line fields or the grade report.

Lacks:

  • No error_class label on a per-workflow Prometheus counter
  • No attempt result-line fields tool_calls, tool_errors, tool_error_top
  • No tool error rate per tool and version in the grade report
  • No ratio alert rule with a 50-call floor

Proposed design

Problem statement

The owner wants an early indicator of what causes job failures. The roadmap jobs have no common measure of tool call errors by class. Only the stage planner and verifier emit devops_cli_roadmap_tool_calls_total, and the counter has no error_class. The implement runner writes log lines, so only log parsing finds refusals. This change extends the counter, the attempt result line, the grade report and the alert, so each workflow shows tool errors by class.

Acceptance criteria

Requirement: Tool call counter labels

The devops_cli_roadmap_tool_calls_total counter SHALL carry the labels row, tool, toolset, outcome and error_class.

Scenario: Counter label set

  • WHEN A test builds the counter and reads its label names
  • THEN The label names are row, tool, toolset, outcome and error_class.

Requirement: Closed error class set

The counter SHALL use only the error classes none, refused, exit_nonzero, timeout, output_cap, invalid_args, model_error and cli_usage.

Scenario: Error class values

  • WHEN A test reads the error class values that the counter accepts
  • THEN The values are the eight closed classes and no other value.

Requirement: Refused shell class

A refused shell call in the implement runner SHALL add one to devops_cli_roadmap_tool_calls_total with outcome="refused" and error_class="refused".

Scenario: Refused shell call

  • WHEN A fake runner refuses a shell call
  • THEN The counter increases by one for the tool and row with outcome="refused" and error_class="refused".

Requirement: Invalid argument class

A tool argument validation error SHALL add one to devops_cli_roadmap_tool_calls_total with outcome="error" and error_class="invalid_args".

Scenario: Argument validation error

  • WHEN A fake planner tool receives invalid arguments
  • THEN The counter increases for error_class="invalid_args".

Requirement: Nonzero exit class

The implement runner SHALL count an exit status that is not 0 as outcome="error" and error_class="exit_nonzero", and SHALL keep the exit status on its Tool call: log line.

Scenario: Nonzero exit

  • WHEN A fake run_command call exits with status 2
  • THEN The counter increases for error_class="exit_nonzero" and the log line holds exit 2.

Requirement: Usage error class

A devops usage error in a tool call SHALL add one to devops_cli_roadmap_tool_calls_total with outcome="error" and error_class="cli_usage".

Scenario: Usage error

  • WHEN A fake tool call returns a devops usage error
  • THEN The counter increases for error_class="cli_usage".

Requirement: Attempt tool error fields

The result line of an attempt SHALL hold tool_calls, tool_errors and tool_error_top, where tool_error_top is the tool with the most errors or none.

Scenario: Top failing tool

  • WHEN An attempt makes 4 tool calls, including 3 refused shell calls
  • THEN Its result line holds tool_calls=4, tool_errors=3 and tool_error_top=shell.

Requirement: Grade report tool errors

The devops roadmap eval grades report SHALL show for each workflow the tool error rate for each tool and version next to the grade, and for a workflow under 80 the top 3 failing tools with their error classes.

Scenario: Workflow under 80

  • WHEN A test runs devops roadmap eval grades on a fixture workflow with a grade under 80 and three failing tools
  • THEN The output shows the tool error rate for each tool and version, the top 3 failing tools with their error classes, and the failure classes of the attempts that had them.

Requirement: Tool error alert

A Prometheus rule RoadmapToolErrorsRise SHALL fire when the 24-hour error ratio of a tool in a row is at least 2 times its 7-day ratio of the day before and the tool in the row has at least 50 calls.

Scenario: Rule fires and stays quiet

  • WHEN promtool test rules runs on the rule fixture with a 3 times rise and 60 calls, then with 40 calls
  • THEN The command exits 0, the rule fires for the 60-call case and stays quiet for the 40-call case.

Requirement: Workflow emission

Each roadmap workflow that gives tools to a model SHALL emit devops_cli_roadmap_tool_calls_total from its tool dispatch.

Scenario: Refine and implement tool calls

  • WHEN A fake refine workflow and a fake implement runner each call a tool
  • THEN The counter increases for the row refine and for the row implement, with their tool and toolset.

Existing Tool Considered

The alternatives check of 2026-11-19 found no open, maintained tool that covers the need (verdict none); the block in the issue body lists what the considered observability platforms lack. The plan extends the existing devops_cli_roadmap_tool_calls_total counter and the roadmap code. The written cost to build, keep and fix the code is about 300,000 tokens and 7 hours elapsed.

Key questions

  • Should this item extend the existing tool call counter or add a new counter?: Extend devops_cli_roadmap_tool_calls_total with error_class. A second counter would split the same series and break existing dashboards. (best practice) [sources: src/devops_cli/telemetry/instruments.py, docs/TELEMETRY.md]
    • Chosen: Extend the existing counter. It keeps one series for each row, tool and toolset and adds the missing class.
    • Rejected: Add a second tool error counter. It duplicates the existing series and makes each query read two metrics.
  • Which closed error classes SHALL the counter use?: Use none, refused, exit_nonzero, timeout, output_cap, invalid_args, model_error and cli_usage. (best practice) [sources: src/devops_cli/telemetry/instruments.py, docs/TELEMETRY.md]
    • Chosen: Closed class set. A closed set keeps the label cardinality low and makes the alert and report queries stable.
    • Rejected: Free text reason. It makes the label cardinality unbounded and breaks the alert rule.
  • Should the counter add the repo label?: No. This item adds only error_class. The issue states one new label, and the alert and report queries use row and tool. (best practice) [sources: src/devops_cli/telemetry/instruments.py, docs/TELEMETRY.md]
    • Chosen: Add only error_class. It follows the issue and keeps the label set small.
    • Rejected: Add repo too. The issue does not ask for it, and it adds a second label and more series.
  • How does the implement runner count an exit that is not 0?: Write the exit status on the Tool call: log line and count outcome="error" with error_class="exit_nonzero". (best practice) [sources: src/devops_cli/roadmap/agent_run.py, tests/roadmap/implement/test_roadmap_implement_tool_log.py]
    • Chosen: Put the exit status on the log line and counter. The log line and the counter then agree, and a log-only parse is no longer the measure.
    • Rejected: Read the exit status only from the run trace. The trace is sampled and does not hold each call, so the counter would miss errors.
  • How does a refused shell call reach the tool error counter?: Count the refusal in the shell refusal path of the implement runner tool dispatch, with outcome="refused" and error_class="refused". (best practice) [sources: src/devops_cli/roadmap/agent_run.py, tests/roadmap/implement/test_roadmap_implement_shell_refusal.py]
    • Chosen: Count in the tool dispatch. The dispatch already decides the refusal and knows the tool and row.
    • Rejected: Parse the refusal from the log line. Log parsing is the current workaround and misses calls in other workflows.
  • How does the counter classify invalid arguments without RetryPromptPart?: Count the validation error in the tool wrapper at argument validation. Do not read RetryPromptPart, because pydantic-ai 2.60 stops building it. (best practice) [sources: src/devops_cli/roadmap/agent_run.py, src/devops_cli/roadmap/refine/refine_investigation.py, tests/roadmap/refine/test_roadmap_refine_investigation.py]
    • Chosen: Count in the tool wrapper. It survives the pydantic-ai change and counts the call that failed.
    • Rejected: Count from RetryPromptPart. The part is absent after pydantic-ai 2.60, so the count gives 0 with no error.
  • Where does the grade report get the tool error rate and the top failing tools?: From the attempt result line through the attempt context of feat(roadmap): result lines state first-pass, model calls and cost #5168 and the report of feat(roadmap): eval grades prints the grade of each workflow #5165. (best practice) [sources: docs/roadmap/job-success.md, CONTEXT.md]
    • Chosen: Use the result line. The result line joins the tool errors with the attempt result and failure class.
    • Rejected: Parse the Loki log lines. Log parsing is the current workaround and misses calls in other workflows.
  • What alert rule and proof SHALL this item add?: Use RoadmapToolErrorsRise with a 24-hour ratio at least 2 times the 7-day ratio of the day before and a 50-call floor for the tool in the row, and prove it with promtool test rules. (best practice) [sources: docs/TELEMETRY.md]
    • Chosen: Ratio rule with a call floor. It compares a tool with its own recent baseline and ignores low-volume noise.
    • Rejected: Absolute error count. A busy tool always crosses a fixed count and a quiet tool never does.
  • Should every agentic workflow emit the counter in this item?: Yes. Each workflow that gives tools to a model emits the counter from its tool dispatch. The implement runner is the first new emitter. (best practice) [sources: docs/TELEMETRY.md, src/devops_cli/roadmap/agent_run.py]
    • Chosen: Emit from each workflow tool dispatch. The issue asks for one counter for every agentic workflow.
    • Rejected: Keep the counter to stage only. It leaves refine, alternatives, fix-plan, review and implement with no measure.
  • How does the counter classify a devops usage error?: Count it as cli_usage when a tool call returns a devops usage error, using the existing usage-error signal from feat(telemetry): record each CLI usage error by name and kind #4973. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py, tests/telemetry/test_usage_errors.py]
    • Chosen: Use the usage-error signal. It classifies the error at its source and keeps the label set closed.
    • Rejected: Parse the tool text. Text parsing is fragile and misses the error class.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#5165, #5168

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    The command gate plan (tracker #5199) changes the scope of this item.

    New scope:

    • error_class=refused comes from devops_cli_roadmap_command_gate_total, not from the shell allowlist.
    • The result line gets gate_refusals, gate_jev_calls and gate_top_rule.
    • The grade report shows the refusals by source (block, default, jev, sticky, fallback, cache).
    • Period counts come from the Command gate: Loki lines.

    What moves: #5201 adds the gate counter, the refusal source and rule, and the Command gate: line. #5206 adds the Jev calls and the seconds field. Build this item after #5206, because both change telemetry/instruments.py and the generated docs.

    Acceptance to add:

    1. A refusal with source block in a fake runner adds 1 to devops_cli_roadmap_tool_calls_total{outcome="refused",error_class="refused"} and to the gate counter.
    2. An attempt with 3 gate refusals writes gate_refusals=3 and gate_top_rule=<id> on its result line.
    3. Real transcripts, before the merge: the counts on the result lines of a replay of 3 recorded Jobs are equal to the count of their Command gate: lines for each source.
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Scope change for #5219 (the self-improvement section of the project review):

    • Add the repo label to devops_cli_roadmap_tool_calls_total. The feat(roadmap): read project review facts through a catalog #4692 catalog schema refuses a Service metric query with no {repo}.
    • Add Table N-5 (tool call errors by row, tool and error class) to section self_improvement. A fix item names its signal with a devops-signal line of source tool_error (row, tool, optional error_class).

    #5219 does not wait for this item. This item adds its own rows to the section in its own pull request.

  6. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    New evidence of 2026-11-13 (review of failing jobs), and three scope points for the error classes.

    Implement runner (Loki, 17 runs, 2026-11-10 to 2026-11-13)

    • All 2,280 run_command calls have the outcome ok. An exit that is not 0 goes only to the run trace. For example, uv run devops ci constructs (an unknown command, exit 2) logs program uv, ok.
    • So the exit_nonzero class of this item has no source in the log line today. The log line needs the exit status (exit 2).

    Stage toolbox (Prometheus, increase(devops_cli_roadmap_tool_calls_total[3d]), about 311 stage runs and 110 stage_verify runs)

    • callers error 11 of about 76 (14%), read_spec error 23 of about 891, list_files error 15 of about 913, read_file error 8. search_code empty about 430 of 5,751 (7.5%).
    • Tempo tool spans with status=error have an empty statusMessage, and the Service log holds no error text. So nobody can tell the cause. read_spec has several error paths: a missing spec, "OpenSpec is not installed", and "The text ... is no capability name" (src/devops_cli/roadmap/stage/stage_tools.py, near lines 300-310).

    Scope points

    1. The run log line and the counter carry the exit status class of each run_command call.
    2. Each toolbox error sets its masked, cut text as the span status message, and its closed reason as error_class (missing_name, missing_path, bad_input, environment).
    3. Each empty search_code answer records two booleans on the span: the text has regex characters, and the next call is another search_code.

    With this data, the answer changes wait for proof: near names for a missing name or path, the hint "Give the bare name, such as run" for a dotted callers name, and the note "The text is literal" for an empty search_code answer. Due when one tool and class has 20 or more errors in 7 days, or when empty search_code answers with regex characters are 25% or more of the empty answers.

  7. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 8ccd95a while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/telemetry/instruments.py, src/devops_cli/docs/generator.py, src/devops_cli/roadmap/agent_run.py.

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

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  9. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • pydantic-ai tool call error metrics OpenTelemetry Prometheus, results: 5
    • OpenLLMetry tool call metrics error count, results: 5
    • open source LLM agent observability tool call error rate metrics, results: 5
    • Langfuse tool call errors dashboard, results: 5
    • Arize Phoenix agent tool call error tracking, results: 5
    • OpenTelemetry GenAI semantic conventions tool call error metric, results: 5
    • Langfuse, results: 5
    • traceloop openllmetry, results: 5
    • Langfuse pydantic-ai integration, results: 5
    • Phoenix OpenTelemetry tool spans, results: 5

    Sources:

  10. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  11. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

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/agentstatus/readytype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions