-
Notifications
You must be signed in to change notification settings - Fork 346
Add regression-range hackbot agent (mozregression --prompt bisection) #6354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
msujaws
wants to merge
1
commit into
mozilla:master
Choose a base branch
from
msujaws:regression-range-6259
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| FROM python:3.12 AS builder | ||
|
|
||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
|
|
||
| ENV UV_PROJECT_ENVIRONMENT=/opt/venv | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install external deps without building workspace members. | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
| --mount=type=bind,source=uv.lock,target=uv.lock \ | ||
| --mount=type=bind,source=VERSION,target=VERSION \ | ||
| uv sync --frozen --no-dev --no-install-workspace --package hackbot-agent-regression-range | ||
|
|
||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| --mount=type=bind,target=/app,rw \ | ||
| uv sync --locked --no-dev --no-editable --package hackbot-agent-regression-range | ||
|
|
||
| # mozregression is installed from the fork carrying PR #2197 (the --prompt mode | ||
| # is not yet in a release), so it lives outside the workspace lockfile. Pin to a | ||
| # specific commit once the PR settles; the branch tracks the PR for now. | ||
| ARG MOZREGRESSION_REF="git+https://github.com/msujaws/mozregression.git@prompt-devtools-mcp-verdict" | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| uv pip install --python /opt/venv "mozregression @ ${MOZREGRESSION_REF}" | ||
|
|
||
| FROM python:3.12 AS base | ||
|
|
||
| COPY --from=builder /opt/venv /opt/venv | ||
| WORKDIR /app | ||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV PATH="/opt/venv/bin:$PATH" | ||
|
|
||
| FROM base AS agent | ||
|
|
||
| # mozregression's --prompt mode (mozilla/mozregression#2197) shells out to the | ||
| # Claude CLI, which launches the Firefox DevTools MCP via npx to classify each | ||
| # build. So the agent image needs Node.js/npm/npx, the DevTools MCP, the Claude | ||
| # CLI, and the shared libraries a downloaded Firefox needs to run headless. The | ||
| # Firefox builds themselves are fetched by mozregression at bisect time. | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| # Node.js/npm/npx: run the Claude CLI and the Firefox DevTools MCP. | ||
| nodejs npm \ | ||
| ca-certificates \ | ||
| # Firefox runtime deps (for the builds mozregression downloads). | ||
| libgtk-3-0 libdbus-glib-1-2 libx11-xcb1 libxtst6 libxt6 libpci3 \ | ||
| libnss3 libnspr4 libasound2t64 libpango-1.0-0 libcairo2 \ | ||
| fonts-liberation \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # The Claude CLI (invoked by mozregression --prompt) and the Firefox DevTools | ||
| # MCP it drives. mozregression launches the MCP with `npx --prefer-offline | ||
| # @mozilla/firefox-devtools-mcp`, so a global install keeps the run offline and | ||
| # fast (npx resolves the globally-installed package before hitting the network). | ||
| RUN npm install -g @anthropic-ai/claude-code @mozilla/firefox-devtools-mcp | ||
|
|
||
| # hackbot.toml lives at the agent root (not inside the package), so copy it into | ||
| # the working dir; the runtime discovers it there (cwd) at startup. | ||
| COPY agents/regression-range/hackbot.toml /app/hackbot.toml | ||
|
|
||
| RUN useradd --create-home --shell /bin/bash agent \ | ||
| && mkdir -p /workspace \ | ||
| && chown agent:agent /workspace | ||
|
|
||
| USER agent | ||
|
|
||
| CMD ["python", "-m", "hackbot_agents.regression_range"] | ||
|
|
||
| FROM base AS broker | ||
|
|
||
| RUN useradd --create-home --shell /bin/bash broker | ||
|
|
||
| USER broker | ||
|
|
||
| EXPOSE 8765 | ||
|
|
||
| CMD ["python", "-m", "hackbot_agents.regression_range.broker"] | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| services: | ||
| regression-range-broker: | ||
| build: | ||
| context: ../.. | ||
| dockerfile: agents/regression-range/Dockerfile | ||
| target: broker | ||
| environment: | ||
| BUGZILLA_API_URL: ${BUGZILLA_API_URL} | ||
| BUGZILLA_API_KEY: ${BUGZILLA_API_KEY} | ||
| expose: | ||
| - "8765" | ||
|
|
||
| regression-range-agent: | ||
| build: | ||
| context: ../.. | ||
| dockerfile: agents/regression-range/Dockerfile | ||
| target: agent | ||
| environment: | ||
| - RUN_ID | ||
| - BUG_ID=${BUG_ID:?error} | ||
| - GOOD=${GOOD:-} | ||
| - BAD=${BAD:-} | ||
| - BUGZILLA_MCP_URL=http://regression-range-broker:8765/mcp | ||
| - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:?error} | ||
| # No uploader locally: summary/logs/attachments are written under | ||
| # /artifacts/<run_id>, bind-mounted to the host's ~/hackbot/artifacts so | ||
| # compose and direct runs land in the same user-scoped location. | ||
| - ARTIFACTS_DIR=/artifacts | ||
| volumes: | ||
| - ${HOME}/hackbot/artifacts:/artifacts | ||
| depends_on: | ||
| regression-range-broker: | ||
| condition: service_started |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # This agent declares no [source] and no [firefox] table: it never needs a | ||
| # Firefox source checkout or a local build. mozregression downloads the builds | ||
| # it bisects, and its --prompt mode launches them through the Firefox DevTools | ||
| # MCP. All the agent needs from the platform is Anthropic credentials (provided | ||
| # automatically) and the brokered Bugzilla MCP (wired via env). |
Empty file.
58 changes: 58 additions & 0 deletions
58
agents/regression-range/hackbot_agents/regression_range/__main__.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| from hackbot_runtime import HackbotContext, run_async | ||
| from pydantic import field_validator | ||
| from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
|
||
| from .agent import RegressionRangeResult, run_regression_range | ||
|
|
||
|
|
||
| class AgentInputs(BaseSettings): | ||
| bug_id: int | ||
| bugzilla_mcp_url: str | ||
| # Optional bisection bounds (date, version number, or changeset). When | ||
| # omitted, the agent infers them from the bug. | ||
| good: str | None = None | ||
| bad: str | None = None | ||
| model: str | None = None | ||
| # Model the nested mozregression --prompt agent uses; defaults to `model`. | ||
| mozregression_model: str | None = None | ||
| max_turns: int | None = None | ||
| effort: str | None = None | ||
|
|
||
| model_config = SettingsConfigDict(extra="ignore") | ||
|
|
||
| @field_validator( | ||
| "good", "bad", "model", "mozregression_model", "effort", mode="before" | ||
| ) | ||
| @classmethod | ||
| def _empty_to_none(cls, v: object) -> object: | ||
| # compose passes optional inputs as empty strings when unset; treat those | ||
| # as absent so the agent infers bounds / uses defaults. | ||
| if isinstance(v, str) and not v.strip(): | ||
| return None | ||
| return v | ||
|
|
||
|
|
||
| async def main(ctx: HackbotContext) -> RegressionRangeResult: | ||
| inputs = AgentInputs() | ||
|
|
||
| return await run_regression_range( | ||
| bugzilla_mcp_server={ | ||
| "type": "http", | ||
| "url": inputs.bugzilla_mcp_url, | ||
| }, | ||
| bug=inputs.bug_id, | ||
| anthropic_api_key=ctx.anthropic.api_key, | ||
| good=inputs.good, | ||
| bad=inputs.bad, | ||
| model=inputs.model, | ||
| mozregression_model=inputs.mozregression_model, | ||
| max_turns=inputs.max_turns, | ||
| effort=inputs.effort, | ||
| log=ctx.log_path, | ||
| verbose=True, | ||
| actions_recorder=ctx.actions, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_async(main) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead use
[tool.uv.sources]inpyproject.tomlso it gets installed with other deps without a custom step in Dockerfile?