Repository navigation
Add mr_testing_analyst agent - #880
martinky82 wants to merge 33 commits into
Conversation
Ports the mr_testing Claude Code skill into a Ymir agent so Testing Farm results, CVE verification, and untested/failed-test review can run as part of the automated pipeline instead of only interactively. Mirrors preliminary_testing_agent's Workflow/ReasoningAgent structure, which this agent is intended to eventually replace. - New privileged tools parse_mr_test_results and format_mr_testing_comment (ymir/tools/privileged/mr_testing.py), ported from the skill's parse_results.py/format_comments.py, since this workflow is tightly coupled to authenticated GitLab/Jira operations. - New update_merge_request_comment and remove_merge_request_labels privileged GitLab tools, closing gaps versus the skill: folding Testing Farm results into anewa's existing comment in place, and keeping the mr_testing_started -> mr_testing_completed -> mr_testing_analyzed label lifecycle clean for status tracking and rescheduling. - Wired into compose.yaml, Makefile (run-mr-testing-analyzer-agent-standalone), and agents_as_skills/mr-testing-analyzer for Claude Code use. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Scheduling is missing, i propose to file MR test analysis job when consolidation finishes and no more consolidation job is supposed to be filed. Wait for Gitlab CI results and if configuration parameter in ymir.yaml is present then also wait for separate runner results, those runners should apply label of your choosing. Then start the analysis and on finish of analysis, add label if you checked gitlab ci or the separate runner results.
|
Also there is pre-commit CI commit again. Check your local setup of the pre-commit hook. |
IMO, the analyzer should run only when the results are ready and as indication of that I propose using mr_testing_completed (or similar) label. Runners should be responsible for setting the label. I don;t see any reason to spawn the agent for it only to wait for results that may appear in minutes, hours or never. But, if we opt for 2 stage testing (using the minimal CI results as a gate for full blown testing) then the analyst should be fired off for processing the CI results and if pass/waive (that can be done by agent, fail only if the analysis shows potential failure caused by the code change), the full testing will commence and alayzer would run for second time processing the full results |
|
We are not spawning anything but we have to record which MR should be verified. We have basically 3 options to do this.
Option 3 would allow us to not care about persistent data records and recovery on shutdowns, so it would probably be the best, but it depends whether the queries in gitlab won’t have issues. Also you have to implement some kind of fetcher for this. As for the 2 phase testing. The analysis will allways wait for gitlab CI and separate runner tests and if there is failure caused by code change in either CI or runner, it has to end with such indication (some boolean in final_answer). We will use that later to respin appropriate jobs. The first identified failure should fail the verification so we can spin up fix immediately and not needlesly verify again MR that is already in a wrong state. |
|
/agentic_review |
Code Review by Qodo
Nice, no open findings for this group Nice, no open findings for this group Nice, no open findings for this group Resolved findings 1.
|
lbarcziova
left a comment
There was a problem hiding this comment.
thank for kicking this off. Do you plan to finish the scheduling as part of this PR, or as a follow-up? As for mechanism, I agree with Tomas' proposals, but namely I would either start with
- polling on Ymir submitted MRs (tradeoff is that we won't do testing on non-Ymir MRs)
- generic Gitlab MR fetcher (similarly as we have the Jira one) that polls Gitlab for MRs with that particular label you propose as a first phase
Could you please also have a look into qodo's comments (I checked the high severity one at least and those look relevant)?
I reckon the scheduling part should be a folow-up. I certainly opt for polling instead of running the agent only for ymir created MRs - the QE process change affects all testing no matter who or what submitted the MR. |
Renames mr_testing_analyzer -> mr_testing_analyst throughout (agent file, prompt dir, tests, compose/Makefile targets, agents_as_skills dir), and fixes the review findings from PR packit#880 that still apply: TomasKorbar: - Drop the redundant "## Tools" prompt section and the hand-written final_answer JSON schema block -- BeeAI already injects the tool list and formats expected_output=MrTestingAnalystResult for the agent, so both were pure duplication. - Biggest change: move every GitLab/Jira write out of the ReasoningAgent's reach. It now only parses results and returns structured content (mr_comments/jira_comments/resolve_discussion_id) in its final answer; a new deterministic act_on_result step performs every actual post/label/resolve. dry_run/poc/no_jira_comments are handled entirely in that step and no longer appear in the prompt at all. - Unroll the comment templates to mr_testing_templates.json (asked about inline on the PR), loaded the same way the originating Claude Code skill loads its templates.json. qodo-for-packit automated findings: - note_id vs discussion_id confusion broke update_merge_request_comment on the normal path -- add a real note_id field end to end instead of falling back to a discussion_id update_merge_request_comment can't accept. - parse_mr_test_results now returns the architecture-keyed dict shape format_mr_testing_comment actually requires, instead of a flat list of rows that had to be reshaped by hand (and never correctly was). - Fix the anewa-still-running case being treated as "has results" and marked analyzed prematurely. - _cve_status_is_pass no longer treats "failed (2 fail, 10 pass)" as a pass. - fetch_gitlab_mr_notes fallback now calls the tool with its actual project/mr_iid schema and decodes its JSON string result, instead of silently producing an empty comment list. - A rerun's own previously-folded analysis is no longer re-parsed as more anewa architecture rows -- a FOLDED_RESULTS_MARKER bounds table parsing, and a new fold_mr_comment_body tool builds the idempotent merge deterministically instead of leaving it to prompt instructions. - An MR with no linked issues now gets labeled mr_testing_analyzed too (outside gating mode), so a completed-label scheduler doesn't re-queue it forever. - A Jira fetch failure now aborts the run (analyzed: false, nothing posted/labeled) instead of silently continuing on an empty CVE/Test Coverage context. - Document the agent's GitLab/Jira/Testing-Farm dependency flow and the comment-spoofing risk inherent to matching on body-text markers as T15 in THREAT_MODEL.md, with the deterministic-posting split and exact-note-targeting listed as mitigations. Added/updated unit tests throughout; 108 tests pass in the two privileged-tools suites. The agent-level test file can't execute in this environment (pre-existing beeai-framework version mismatch, confirmed present on unmodified main too) but was hand-verified against the new act_on_result logic. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
I reckon the scheduling part should be a folow-up. I certainly opt for polling instead of running the agent only for ymir created MRs - the QE process change affects all testing no matter who or what submitted the MR. |
|
/agentic_review |
- check-mcp-install-in-container was failing: ymir-tools' wheel only packaged **/*.py, so mr_testing_templates.json never shipped in a real `pip install`, and mr_testing.py raises at import time when it can't find its templates file. Add **/*.json to the wheel include list. Verified by building the wheel and confirming the file is present and the module imports successfully from an installed copy. - pre-commit.ci's ruff hook was failing on lines pre-existing before this change, in files this change otherwise touches (ruff lints whole files, not diffs): a try/except/pass -> contextlib.suppress, one over-length line, two list-concatenation-vs-unpacking nits, and an unnecessary dict() call. Fixed all five; `pre-commit run` is now clean end to end. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 89a616a |
|
One thing this relates to is that ultimately I think most agentic flows that operate on a git repository should run in the context of that repo - that's how GitHub Agentic Workflows operates, as does Fullsend etc.
Which would bypass this type of thing - a workflow like this would be a thing that could be triggered by a slash command or be a scheduled job in the repo, and could run without any global state/queuing at all (other than the global state from the forge itself). |
…back Deterministic-side fixes for 8 qodo-for-packit findings: stop trusting a model-chosen GitLab discussion ID for resolving OSCI's results thread (Python now locates and validates it itself, gating-mode only), move anewa/NEWA/OSCI comment parsing out of the model's own tool calls so raw comment bodies and anewa's fold target never pass through model-generated tool arguments, fall back to unfiltered MR notes when the authorized-comments fetch silently drops the results bot's note, retain all per-plan Testing Farm URLs instead of just the first, derive overall_status for modern per-plan-only tables, add a real NEWA-only results comment template, keep a partial Jira/discussion-resolve failure from blocking MR labeling, and register the renamed skill in the installer. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
I need to check how this could be done in Gitlab. We discussed it with Laura but i ultimately thought that if we will add this as a CI job, then we won't be maintaining only the job but also our scraper which reacts to the external runner, but perhaps gitlab would allow us to trigger the job when the separate runner finished label is applied and thus would allow us to avoid scraping. |
|
I did some research and discussed the stuff with Stephen Gallagher yesterday and i want to provide additional reasoning behind the scheduling and current plan. For me the ideal state of this (as i see it right now) would be to have the review showing as additional CI job running after the tests. The job would communicate with our infra running the agents (because to me it seems that maintaining the infra directly in our cluster seems easier than debugging stuff in gitlab runners) and finish when the review is complete. If the review found issues with the MR, another pipeline with job fixing the MR would be run. That way we would show what is happening above the MR directly in the MR. Separate runners would be instructed to execute pipeline instead of adding label to MR, because reacting to labels or comments would need us filtering those, while triggering pipeline is straightforward and requires no processing. I think it presents no difference whether separate test runners are adding label or triggering pipeline, we just have to tell them what to do. Now why this can not happen right now is because we are not able to receive traffic from outside of VPN (that means gitlab) on the cluster where we are right now. That is why the querying and polling is a way how to do this in this moment and when we will migrate we will rework the scheduling again. |
TomasKorbar
left a comment
There was a problem hiding this comment.
I tried running the workflow as it is and got
============================================================
RESULT: ⚠️ SKIPPED
============================================================
No `Resolves: RHEL-XXXXX` line found in https://gitlab.com/redhat/rhel/rpms/expat/-/merge_requests/108's description.
============================================================
Current MRs filed by Ymir do not contain those lines in description, because ticket checking automation was then picking those values from MR description instead of commits and since it consumes only limited amount of characters, it split the Resolves: RHEL-XXXXX in half on multiple occasions and blocked the MR. The Resolves are in commits only.
- Find linked Jira issues from `Resolves:` footers in the MR's commit messages (new get_merge_request_commit_messages gateway tool), falling back to the description; abort without labeling if commits can't be fetched. - Drop the agents_as_skills/mr-testing-analyst skill and its installer entry. - Render gating/non-gating instructions and PARSED_RESULTS in the Jinja prompt instead of branching in the agent or appending to the prompt. - Add queue mode (mr_testing_queue) alongside the direct MR_URL mode. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Find linked Jira issues from `Resolves:` footers in the MR's commit messages (new get_merge_request_commit_messages gateway tool), falling back to the description; abort without labeling if commits can't be fetched. - Drop the agents_as_skills/mr-testing-analyst skill and its installer entry. - Render gating/non-gating instructions and PARSED_RESULTS in the Jinja prompt instead of branching in the agent or appending to the prompt. - Add queue mode (mr_testing_queue) alongside the direct MR_URL mode. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…st failures Look at earlier Test Failure Analysis threads on the same MR or, if none, at up to 4 recent mr_testing_analyzed MRs of the component, and include the findings (waivers, repeated failures) in the analysis via a new optional History block in the failure comment. search_gitlab_project_mrs gains optional label/exclude_drafts filters and an optional search string. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Find linked Jira issues from `Resolves:` footers in the MR's commit messages (new get_merge_request_commit_messages gateway tool), falling back to the description; abort without labeling if commits can't be fetched. - Drop the agents_as_skills/mr-testing-analyst skill and its installer entry. - Render gating/non-gating instructions and PARSED_RESULTS in the Jinja prompt instead of branching in the agent or appending to the prompt. - Add queue mode (mr_testing_queue) alongside the direct MR_URL mode. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
- Wrap long summary and Redis startup log lines to satisfy E501. - Remove dead url/encoded_project/headers assignments from SearchGitlabProjectMrsTool; the undefined _get_auth_headers call caused F821. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
In gating mode the agent fetched CI traces and Testing Farm logs through tools, so long log text was pasted into its context and results got omitted. Python now downloads each gating test job's results.xml and the logs of its failed or errored testcases into a per-run temp directory (fetch_test_logs step), and the agent reads those local copies with view/search_text. Downloads are restricted to artifacts.osci.redhat.com and capped at 50 logs per job. The temp directory is removed after the run. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The workflow passed the MR URL as the transaction's jira_issue, so the trace server indexed every span under the MR URL as if it were a Jira issue. Transactions now start without an issue key, and once the linked Jira keys are known the spans are tagged with them (comma-joined, which the trace server splits on). run_mr_testing_analyst takes the span_processor for this, as merge_request_agent does. observability.start_transaction no longer names transactions "... for None" when there is no issue key. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The UI percent-encodes the issue key, but the route matched the raw path, so keys containing "/" or ":" (such as MR URLs) never matched the stored values. Decode the path before the lookup. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The SDK default of 128 attributes evicts the oldest ones on LLM spans, which flatten every message and tool schema. Long ReasoningAgent runs dropped jira.issue and logged "Attributes dict is full" warnings. Set SpanLimits.max_span_attributes to 1024 on the tracer provider. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
StreamReader.read(n) returns only the first buffered chunk, so the fetch tool handed the model about 8 KB of a results file and CVE testcases past that point looked missing. Read chunks up to the cap. The full JUnit file is megabytes of system-out, so return one line per testcase with a short failure message instead, and keep raw text only for non-XML content. The testcase status rule moves to ymir/common/junit.py. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The fold into anewa's note carried the unenriched table plus a second per-architecture breakdown. Before folding, read each architecture's results file, count testcases per plan, and append counts to the plan cells (e.g. "✅ pass (4 pass)"). The summary is built without its own table in that case. Also read the downloaded results in full, since read(n) returned only the first chunk. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The MrTestingAnalystWorkflow root span records the whole workflow state at each step, which overflowed the 1024 limit on a real MR and made the SDK drop the oldest attributes, including jira.issue. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The workflow trace copies the state at every step, so the raw MR comments and the anewa note body were recorded in full on the root span. Exclude them from the state dump while keeping them in memory for the fetch, parse, and fold steps, and drop the note body from PARSED_RESULTS since the model does not need it. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
|
Agent tested successfully: https://gitlab.com/redhat/centos-stream/rpms/python3.12/-/merge_requests/124 the first run is done by my skill, the second by the agent |
beeai fails the step with EmptyChatModelResponseError and the trace has no reply to inspect. A LiteLLM callback now logs the finish reason, the thinking-part types and lengths, and usage for such replies. The text itself is never logged. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
|
Side note: models like Sonnet 5.5 often error out on empty response from the model. It seems, the culprit is the security guardrails those new models have against misuse (though I never had such problem with my skill). Analysis with Opus 4.6 works flawlessly so far, even on a MR where Sonnet 5.5 reliably errored out. |
Ports the mr_testing Claude Code skill into a Ymir agent so Testing Farm results, CVE verification, and untested/failed-test review can run as part of the automated pipeline instead of only interactively. Mirrors preliminary_testing_agent's Workflow/ReasoningAgent structure, which this agent is intended to eventually replace.
TODO:
packit/packit.dev.Fixes
Related to
Merge before/after
RELEASE NOTES BEGIN
Packit now supports automatic ordering of ☕ after all checks pass.
RELEASE NOTES END