Skip to content

Integrate bug fix/triage tool into BugBug#5959

Merged
suhaibmujahid merged 10 commits intomozilla:masterfrom
suhaibmujahid:larrey-in-bugbug
Apr 27, 2026
Merged

Integrate bug fix/triage tool into BugBug#5959
suhaibmujahid merged 10 commits intomozilla:masterfrom
suhaibmujahid:larrey-in-bugbug

Conversation

@suhaibmujahid
Copy link
Copy Markdown
Member

For now, it runs via CLI; I'll follow up by creating a cloud-based service.

uv run --with bugsy,grizzly-framework,prefpicker scripts/run_bug_fix.py --bug_id 1234567

Co-Authored-By: Christian Holler (:decoder) <choller@mozilla.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates the Larrey bug-triage/fix workflow into BugBug as a locally runnable CLI tool, and adds a new “duplicate_bugs” agent with associated prompts/config to support duplicate detection workflows.

Changes:

  • Add a CLI entry script to run the bug-fix triage agent locally (dry-run, verbose) with Pydantic CLI/env settings.
  • Introduce Bugzilla + Firefox in-process MCP servers and Firefox evaluation/build helpers to support triage investigation.
  • Add a new duplicate-bugs tool (agent + prompts + config) and ensure prompt/rule artifacts are packaged in wheels.

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
scripts/run_bug_fix.py Local CLI wrapper for running BugFixTool with settings parsed from CLI/env.
pyproject.toml Adds runtime deps and includes prompt/rule artifacts in wheel builds.
bugbug/tools/duplicate_bugs/prompts/dupdetector_local_to_local.md Prompt for local crash-directory deduping.
bugbug/tools/duplicate_bugs/prompts/dupdetector_local.md Prompt for matching a local crash dir to Bugzilla bugs.
bugbug/tools/duplicate_bugs/prompts/dupdetector_bugs.md Prompt for finding duplicates among Bugzilla blockers.
bugbug/tools/duplicate_bugs/config.py Shared config + verdict parsing helpers for duplicate-bugs flows.
bugbug/tools/duplicate_bugs/agent.py Implements the duplicate-bugs agent modes and CLI-style runner logic.
bugbug/tools/duplicate_bugs/init.py Exports DuplicateBugsTool.
bugbug/tools/bug_fix/rules/unsupported-config.md Adds a triage ruleset about unsupported pref/config cases.
bugbug/tools/bug_fix/rules/README.md Documents how triage rulesets are discovered/used.
bugbug/tools/bug_fix/prompts/system.md System prompt for Larrey triage agent, including tool usage constraints.
bugbug/tools/bug_fix/firefox_tools/js_shell_evaluator.py Runs JS shell testcases and captures crash output.
bugbug/tools/bug_fix/firefox_tools/evaluate_testcase.py Runs browser testcases via grizzly and captures crash output.
bugbug/tools/bug_fix/firefox_tools/build_firefox.py Builds Firefox with ASAN fuzzing mozconfig.
bugbug/tools/bug_fix/firefox_tools/init.py Exposes Firefox tool implementations.
bugbug/tools/bug_fix/firefox_mcp.py MCP server exposing Firefox build + evaluation tools.
bugbug/tools/bug_fix/config.py Bug-fix tool config constants (tool allowlists, config keys).
bugbug/tools/bug_fix/bugzilla_mcp.py MCP server wrapping Bugzilla REST access (read/write w/ dry-run + confirm).
bugbug/tools/bug_fix/agent.py Main Larrey triage agent orchestration (Bugzilla + Firefox MCP, rules, streaming).
.gitignore Ignores .env for local runs.
Comments suppressed due to low confidence (1)

pyproject.toml:23

  • The bugsy dependency is unconstrained while most dependencies are version-pinned or at least have a lower bound. To avoid unexpected breakage from upstream releases, add a version range (minimum tested version, optionally an upper bound).
    "beautifulsoup4==4.14.3",
    "boto3==1.42.78",
    "claude-agent-sdk>=0.1.30",
    "httpx==0.28.1",

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bugbug/tools/bug_fix/firefox_tools/evaluate_testcase.py
Comment thread bugbug/tools/bug_fix/config.py
Comment thread bugbug/tools/duplicate_bugs/agent.py
Comment thread bugbug/tools/duplicate_bugs/agent.py
Comment thread bugbug/tools/duplicate_bugs/agent.py
Comment thread bugbug/tools/bug_fix/firefox_tools/evaluate_testcase.py
Comment thread bugbug/tools/bug_fix/firefox_tools/evaluate_testcase.py
Comment thread bugbug/tools/duplicate_bugs/agent.py
@suhaibmujahid suhaibmujahid requested a review from marco-c April 22, 2026 20:03
@suhaibmujahid suhaibmujahid marked this pull request as ready for review April 22, 2026 20:03
Comment thread bugbug/tools/bug_fix/firefox_tools/build_firefox.py Outdated
Comment thread bugbug/tools/bug_fix/firefox_tools/build_firefox.py Outdated
Comment thread bugbug/tools/bug_fix/firefox_tools/evaluate_testcase.py Outdated
Comment thread bugbug/tools/bug_fix/firefox_tools/evaluate_testcase.py Outdated
suhaibmujahid and others added 2 commits April 22, 2026 16:44
Co-authored-by: Marco Castelluccio <mcastelluccio@mozilla.com>
@marco-c marco-c changed the title Integrate Larrey into BugBug Integrate bug fix/triage tool into BugBug Apr 22, 2026
@suhaibmujahid suhaibmujahid requested a review from marco-c April 23, 2026 16:43
Comment thread scripts/run_bug_fix.py
Comment on lines +42 to +43
if result.simulated_writes:
print(f"simulated writes: {len(result.simulated_writes)}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the "simulated writes"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a print out of the changes when running in dry-run.

Comment thread scripts/run_bug_fix.py Outdated
@@ -0,0 +1,47 @@
"""Run the bug_fix triage tool locally."""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Run the bug_fix triage tool locally."""
"""Run the bug_fix tool locally."""

not just triage :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ff61e16

@@ -0,0 +1,745 @@
"""In-process MCP server wrapping bugsy for Bugzilla REST access.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's file an issue to merge this into the default MCP

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #5964

Comment thread bugbug/tools/bug_fix/config.py Outdated
_CONFIG_KEYS = {"base_url", "source_repo", "rules_dir", "model", "max_turns", "effort"}

# Valid values for the SDK's `effort` knob (adaptive thinking control).
EFFORT_CHOICES = ("low", "medium", "high", "max")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's also xhigh now, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used anywhere, so I dropped it in ed57dbe.

import yaml

# Tools that can modify the source repo — blocked under dry-run.
SOURCE_WRITE_TOOLS = {"Write", "Edit", "MultiEdit", "NotebookEdit"}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "NotebookEdit"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It modifies Jupyter notebook cells, it could be needed if it is using Jupyter Notebook for the STRP.

Comment thread bugbug/tools/bug_fix/firefox_mcp.py Outdated

@tool(
"evaluate_testcase",
"Run a testcase in an ASAN-instrumented Firefox under xvfb and "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on the mozconfig, we should not always use ASAN

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 071cc9c

Comment thread bugbug/tools/bug_fix/firefox_mcp.py Outdated
Comment on lines +122 to +123
"Build Firefox with the ASAN+UBSAN fuzzing mozconfig. Slow (tens of "
"minutes on a cold build, faster incremental). Returns JSON: "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, given it's slow, we won't always use ASAN and UBSAN

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 071cc9c

Only label something as `unsupported-config` if that assessment would be true for all
currently supported channels.

Currently supported versions are: ESR115, ESR140, 149, 150 and 151.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be outdated very quickly :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole file is hardcode, and we should consider replacing it with a dynamic way to provide the same information.

Comment on lines +50 to +51
Unless you add the `unsupported-config` keyword, append a `[prefs-checked]` tag to the
whiteboard so we don't have to repeat this process again.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we'll want to do this for every bug

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped in e5007df

Comment thread bugbug/tools/bug_fix/prompts/system.md Outdated

Process each bug exactly once. Do not loop back.

**Task mode:** If the user message gives you a specific task directive (e.g. "set keyword X on bugs that match Y"), that directive replaces the default rules-driven triage workflow above. The rules directory remains available but is not mandatory — follow the task.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't need this for now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Droped in 7d77c90.


# Source repository

Your working directory is the source repository for the product these bugs are filed against. You have Read, Grep, Glob, and Bash to inspect it. Use this to answer questions like "does this function still exist", "where is this string defined", "what does this test actually check".
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow-up, we should also add the other tools that we already have like searchfox

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed #5965

Comment thread bugbug/tools/bug_fix/prompts/system.md Outdated

These tools are not gated by --dry-run: reproducing a crash is assessment, not modification.

Only produce a fix when explicitly asked for, and follow these rules:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to remove this and always have the agent attempt a fix if possible

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d7e1825

Comment thread bugbug/tools/bug_fix/prompts/system.md Outdated

Only produce a fix when explicitly asked for, and follow these rules:

- Before trying to reproduce or fix anything, ensure you are at origin/main with no local source changes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we create a fresh clone for each run, this line might not be necessary

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d7e1825

Comment on lines +45 to +47
- Reproduce the issue first, then plan your fix and test that the issue no longer reproduces. If you cannot
reproduce the bug, do not post a fix patch. Comment instead that the bug wasn't reproducible automatically
and needs manual attention.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases it would be feasible to attempt a fix even when the bug can't be reproduced (though we can add this option later I guess)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it for now to reduce false positives, and we can iterate later if it turns out to be too restrictive.

- **What** you are about to change and **why** (cite the specific rule)
- **Your confidence**: high / medium / low

Only call `update_bug` to change fields when confidence is **high** and a specific triage rule directs it. If confidence is medium or low, `add_comment` instead to ask for clarification or note your findings — do not silently skip.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we have few triage rules, the confidence might never be "high" right now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us keep it and see how it works.

marco-c
marco-c previously approved these changes Apr 23, 2026
@suhaibmujahid suhaibmujahid merged commit e4aec7a into mozilla:master Apr 27, 2026
6 checks passed
@suhaibmujahid suhaibmujahid deleted the larrey-in-bugbug branch April 27, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants