ci/ai: make the /investigate agent reliably deliver its findings#172151
Merged
Conversation
The /investigate agent sometimes finished a successful investigation without its analysis ever reaching the issue: instead of writing artifacts/findings.md (which a later workflow step posts), it tried to post the comment itself via gh issue comment — denied by the sandbox — and saved its report under /tmp. The post step then found no file and fell back to "Investigation did not produce findings," forcing a human to copy the analysis out of the workflow run by hand. Two complementary changes: - Reframe the agent prompt so the report file is its sole deliverable and remove every cue that the output becomes a posted comment — the likely source of the temptation to post directly. The feedback footer, the most explicit such cue, moves from the agent's template into the workflow's post step. - Add a recovery step that, when artifacts/findings.md is absent, extracts the agent's final summary from the action's execution-output JSON and writes it to the file. This is defense-in-depth: it also covers the agent failing to write the file for unrelated reasons (out of turns, crash mid-write). A missing file now reflects a genuinely empty investigation rather than a misrouted one. Epic: none Release note: None
rail
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The /investigate agent sometimes finished a successful investigation without its analysis ever reaching the issue: instead of writing artifacts/findings.md (which a later workflow step posts), it tried to post the comment itself via gh issue comment — denied by the sandbox — and saved its report under /tmp. The post step then found no file and fell back to "Investigation did not produce findings," forcing a human to copy the analysis out of the workflow run by hand.
Two complementary changes:
Reframe the agent prompt so the report file is its sole deliverable and remove every cue that the output becomes a posted comment — the likely source of the temptation to post directly. The feedback footer, the most explicit such cue, moves from the agent's template into the workflow's post step.
Add a recovery step that, when artifacts/findings.md is absent, extracts the agent's final summary from the action's execution-output JSON and writes it to the file. This is defense-in-depth: it also covers the agent failing to write the file for unrelated reasons (out of turns, crash mid-write). A missing file now reflects a genuinely empty investigation rather than a misrouted one.
Epic: none
Release note: None