fix(gh-action): pass workflow_run conclusion to auto tools - #2843
fix(gh-action): pass workflow_run conclusion to auto tools#2843lb1192176991-lab wants to merge 1 commit into
Conversation
The workflow_run handler read workflow_run.event and workflow_run.pull_requests but never workflow_run.conclusion, so the post-CI review behaved identically whether the triggering workflow succeeded, failed, or was cancelled. Extract the extra_instructions append loop from _inject_artifact_context into a shared _append_tool_context helper and add _inject_ci_conclusion, which tells the model how the triggering workflow run concluded via extra_instructions. Call it from the workflow_run branch. Fixes The-PR-Agent#2841
PR Summary by QodoPropagate workflow run conclusions to PR auto tools
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. CI context leaks across tests
|
|
Thanks for this, and for getting there first. I am taking #2848, and adding you as a co-author on it, because its The reason it is not this one is measured rather than stylistic. Lifting the target-tool loop out of Qodo's test-pollution finding here is also still live. Under default config all three PRs inject byte-identical text, so this came down to regression surface rather than quality. |
The CI-status injection was checking against a fixed tuple of three tool names, so a repo that narrows ARTIFACTS.TARGET_TOOLS to fewer tools still got the CI context injected into all three anyway. Reads the configured target tools now, falling back to the same three tools when nothing is set, with a guard so a string, a malformed value, or nothing at all can't raise. Based on the approach from The-PR-Agent#2843, applied here per review feedback.
What
The
workflow_runhandler now readsworkflow_run.conclusionfrom the payload and tells the auto tools (PR Description, PR Review, PR Code Suggestions) how the triggering workflow finished, by appending a labelled CI status block to theirextra_instructions.The append loop previously embedded in
_inject_artifact_context()was extracted into a shared_append_tool_context(text)helper, and a new_inject_ci_conclusion(conclusion)uses it. The new call sits next to the existing artifact injection in theworkflow_runbranch.Why
The whole point of running after CI is to review with the pipeline's findings in hand. The handler read
workflow_run.eventandworkflow_run.pull_requestsbut neverworkflow_run.conclusion, so a post-CI review behaved identically whether the triggering workflow succeeded, failed, or was cancelled — and the model was never told which. If the conclusion is notsuccess, the injected context instructs the tools to say so rather than implying the change is clean.This is purely additive: no control flow changes, no prompt files touched, and it reuses the
ARTIFACTS.TARGET_TOOLSsettings key (no new configuration).Testing
PYTHONPATH=. pytest -q tests/unittest/test_github_action_runner_core.py— 19 passed.test_workflow_run_injects_ci_conclusion: a run withconclusion: "failure"results in the conclusion text appearing inget_settings().pr_reviewer.extra_instructions.test_workflow_run_without_conclusion_injects_nothing: a payload without aconclusionkey appends no CI context._write_workflow_run_eventto accept aconclusionparameter (Noneomits the key).