Repository navigation
Description
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_totalhas the labelsrow,tool,toolsetandoutcome(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,646ok, 175refused(shell165,run_command10) and 2retrylines, and 2,560 "Tool call:" lines in another form. So 6.9% ofshellcalls 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
devopsusage error of an agent is counted ascli_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 fromRetryPromptPartgives 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_totalwithrow(the job of the result line),tool,toolset,outcome(ok,empty,error,refused) and the new labelerror_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(adevopsusage 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 nametool_error_top(the tool with the most errors in the attempt, ornone). 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 exampleshell refusedbeforeplan_defect, type-check errors beforetypes). - 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
shellcalls writestool_errors=3 tool_error_top=shellon its result line. promtool test rulespasses forRoadmapToolErrorsRise: 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,outcomeanderror_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"anderror_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_commandcall exits with status 2 - THEN The counter increases for
error_class="exit_nonzero"and the log line holdsexit 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
devopsusage 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
shellcalls - THEN Its result line holds
tool_calls=4,tool_errors=3andtool_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 gradeson 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 rulesruns 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
refineand for the rowimplement, 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_totalwitherror_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_errorandcli_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
repolabel?: No. This item adds onlyerror_class. The issue states one new label, and the alert and report queries userowandtool. (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
repotoo. The issue does not ask for it, and it adds a second label and more series.
- Chosen: Add only
- How does the implement runner count an exit that is not 0?: Write the exit status on the
Tool call:log line and countoutcome="error"witherror_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"anderror_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 readRetryPromptPart, 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
RoadmapToolErrorsRisewith 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 withpromtool 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
devopsusage error?: Count it ascli_usagewhen a tool call returns adevopsusage 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.
Activity
dan-petty commentedon Nov 12, 2026
Both work on devops_cli_roadmap_tool_calls_total; #3240 created the base counter for the stage planner, the candidate adds an error_class label and extends it to all agentic workflows.dan-petty commentedon Nov 12, 2026
The command gate plan (tracker #5199) changes the scope of this item.
New scope:
error_class=refusedcomes fromdevops_cli_roadmap_command_gate_total, not from the shell allowlist.gate_refusals,gate_jev_callsandgate_top_rule.block,default,jev,sticky,fallback,cache).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 thesecondsfield. Build this item after #5206, because both changetelemetry/instruments.pyand the generated docs.Acceptance to add:
blockin a fake runner adds 1 todevops_cli_roadmap_tool_calls_total{outcome="refused",error_class="refused"}and to the gate counter.gate_refusals=3andgate_top_rule=<id>on its result line.Command gate:lines for each source.dan-petty commentedon Nov 12, 2026
Scope change for #5219 (the self-improvement section of the project review):
repolabel todevops_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}.self_improvement. A fix item names its signal with adevops-signalline of sourcetool_error(row,tool, optionalerror_class).#5219 does not wait for this item. This item adds its own rows to the section in its own pull request.
dan-petty commentedon Nov 13, 2026
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)
run_commandcalls have the outcomeok. An exit that is not 0 goes only to the run trace. For example,uv run devops ci constructs(an unknown command, exit 2) logsprogram uv, ok.exit_nonzeroclass 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)callerserror 11 of about 76 (14%),read_specerror 23 of about 891,list_fileserror 15 of about 913,read_fileerror 8.search_codeempty about 430 of 5,751 (7.5%).status=errorhave an emptystatusMessage, and the Service log holds no error text. So nobody can tell the cause.read_spechas 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
run_commandcall.error_class(missing_name,missing_path,bad_input,environment).search_codeanswer records two booleans on the span: the text has regex characters, and the next call is anothersearch_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 dottedcallersname, and the note "The text is literal" for an emptysearch_codeanswer. Due when one tool and class has 20 or more errors in 7 days, or when emptysearch_codeanswers with regex characters are 25% or more of the empty answers.devops-cli-service commentedon Nov 17, 2026
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.devops-cli-service commentedon Nov 17, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
devops-cli-service commentedon Nov 19, 2026
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:
Sources:
devops-cli-service commentedon Nov 19, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.