Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions agents/regression-range/Dockerfile
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}"
Comment on lines +20 to +25

Copy link
Copy Markdown
Member

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] in pyproject.toml so it gets installed with other deps without a custom step in Dockerfile?


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"]
33 changes: 33 additions & 0 deletions agents/regression-range/compose.yml
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
5 changes: 5 additions & 0 deletions agents/regression-range/hackbot.toml
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.
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)
Loading