fix: stop run_diagnostic_code from crashing every investigation dispatch#988
Conversation
The dispatcher calls every tool whose is_available() returns True, then passes whatever extract_params() pulls from the alert sources. This tool had neither callback, so it always got selected and always got called with no arguments — causing a TypeError on every single investigation run. Added is_available=lambda _: False so the dispatcher skips it. The tool still works fine when called directly with a code argument; it just shouldn't be auto-selected when the agent has no code to give it. Also updated the existing test that was asserting the wrong behaviour (is_available returning True) and added a second assertion to make the intent explicit. Fixes Tracer-Cloud#956
Greptile SummaryThis PR fixes a crash where Confidence Score: 5/5Safe to merge — one-line fix with updated tests, follows the established pattern for this class of bug. The change is minimal and consistent with prior fixes (#732, #703, #704). The dispatcher logic in No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Dispatcher as Investigation Dispatcher
participant Tool as run_diagnostic_code
Note over Dispatcher,Tool: Before fix — every dispatch
Dispatcher->>Tool: is_available(sources) → True (default)
Dispatcher->>Tool: extract_params(sources) → {}
Dispatcher->>Tool: run(**{})
Tool-->>Dispatcher: TypeError: missing required arg 'code'
Note over Dispatcher,Tool: After fix — every dispatch
Dispatcher->>Tool: is_available(sources) → False
Dispatcher-->>Dispatcher: skip — Action not available
Note over Dispatcher,Tool: Direct / explicit call (unaffected)
Dispatcher->>Tool: run(code="print(1)")
Tool-->>Dispatcher: {success: True, stdout: "1\n", ...}
Reviews (1): Last reviewed commit: "fix: stop run_diagnostic_code from crash..." | Re-trigger Greptile |
VaibhavUpreti
left a comment
There was a problem hiding this comment.
Awesome @AarushSharmaa , thanks a lot for fixing this!
|
Welcome to the OpenSRE community :) |
|
Thanks for the quick merge! Been reading through the codebase to understand how everything fits together and really enjoying it. Looking forward to picking up more issues as I go deeper. And honestly, cheers to what you all are building here, this kind of infrastructure is going to matter a lot as agents start taking over more of the ecosystem. |
Fixes #956
Describe the changes you have made in this PR -
run_diagnostic_codewas registered with@toolbut withoutis_availableorextract_params. The dispatcher's defaults are: always select the tool (is_availablereturnsTrue) and call it with empty kwargs (extract_paramsreturns{}). Sincerun_diagnostic_coderequires acodeargument, this caused aTypeErroron every investigation - even ones completely unrelated to code execution.The fix is one line:
is_available=lambda _: Falsein the@tooldecorator. This matches the pattern used in #732, #703, and #704 which fixed the same class of bug for other tools. The tool still works perfectly when called directly with acodeargument - it just won't be auto-selected by the dispatcher anymore.Also updated the existing test that was asserting the wrong behaviour (
is_availablereturningTrue) and made the intent explicit with a second assertion.Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
I traced the crash by reading
execute_actions.py(the dispatcher) and saw it callsaction.extract_params(sources)thenaction.run(**kwargs). For tools without a customextract_params,kwargsis always{}.run_diagnostic_coderequirescodeas a positional argument, so the call always raisesTypeError.I looked at how prior fixes (#732, #703, #704) handled the same problem: they all used
is_available=lambda _: Falseto tell the dispatcher "skip me, I can't be auto-called". That's the right fix here too, because there's no way to pull a meaningfulcodestring out of an alert's source dict.The one-line change to the decorator is the entire fix. I also flipped the test that was asserting the wrong thing and added a second assertion that documents why this matters.
Checklist before requesting a review
Note: Please check Allow edits from maintainers if you would like us to assist in the PR.