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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/agents/frontend-triage/ @mozilla/hackbot-frontend
/agents/gecko-triage/ @mozilla/hackbot-media
/agents/perf-triage/ @mozilla/hackbot-performance
/agents/hackbot-capable/ @mozilla/hackbot-performance
/agents/autowebcompat-repro/ @mozilla/hackbot-webcompat
/agents/autowebcompat-diagnosis/ @mozilla/hackbot-webcompat
/agents/autowebcompat-intervention/ @mozilla/hackbot-webcompat
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/hackbot-prod-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ on:
- agents/dataset-eval
- agents/frontend-triage
- agents/gecko-triage
- agents/hackbot-capable
- agents/perf-triage
- agents/test-plan-generator
- agents/test-repair
Expand Down
2 changes: 2 additions & 0 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ tasks:
uv run --locked --with pytest==9.1.0 --with pytest-cov==7.1.0 --with pytest-asyncio==1.4.0 pytest --cov=hackbot_agents --cov-append tests/ &&
cd ../gecko-triage &&
uv run --locked --with pytest==9.1.0 --with pytest-cov==7.1.0 --with pytest-asyncio==1.4.0 pytest --cov=hackbot_agents --cov-append tests/ &&
cd ../hackbot-capable &&
uv run --locked --with pytest==9.1.0 --with pytest-cov==7.1.0 --with pytest-asyncio==1.4.0 pytest --cov=hackbot_agents --cov-append tests/ &&
cd ../perf-triage &&
uv run --locked --with pytest==9.1.0 --with pytest-cov==7.1.0 --with pytest-asyncio==1.4.0 pytest --cov=hackbot_agents --cov-append tests/ &&
cd ../test-repair &&
Expand Down
51 changes: 51 additions & 0 deletions agents/hackbot-capable/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM python:3.14 AS builder

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

ENV UV_PROJECT_ENVIRONMENT=/opt/venv
ENV UV_PYTHON_DOWNLOADS=never

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-hackbot-capable

RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,target=/app,rw \
uv sync --locked --no-dev --no-editable --package hackbot-agent-hackbot-capable

FROM python:3.14 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

# 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/hackbot-capable/hackbot.toml /app/hackbot.toml

# No /workspace: this agent never checks out Firefox.
RUN useradd --create-home --shell /bin/bash agent

USER agent

CMD ["python", "-m", "hackbot_agents.hackbot_capable"]

FROM base AS broker

RUN useradd --create-home --shell /bin/bash broker

USER broker

EXPOSE 8765

CMD ["python", "-m", "hackbot_agents.hackbot_capable.broker"]
61 changes: 61 additions & 0 deletions agents/hackbot-capable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# hackbot-capable

Decides whether a Bugzilla bug is simple enough for the [`bug-fix`](../bug-fix/)
agent to solve on its own, and if so adds `[hackbot-capable]` to the bug's
whiteboard.

## How it works

The run pulls the bug and its comments through the Bugzilla
[broker](hackbot_agents/hackbot_capable/broker.py), then asks Claude for a
verdict. Claude can read related bugs and attachment lists through the broker and
look up the code on Searchfox; it has no checkout and cannot edit or run anything.
What counts as capable is in
[`prompts/system.md`](hackbot_agents/hackbot_capable/prompts/system.md): the bug
says clearly what to do, the code to change was found and the change is small,
and the fix can be checked in the `bug-fix` agent's Linux container.

- **Capable**: the run records two actions on the bug: a whiteboard change that
appends `[hackbot-capable]`, and a comment rendered from
[`templates/comment.md`](hackbot_agents/hackbot_capable/templates/comment.md)
with the model's reasoning in its **Reasoning** section. The apply step sends
them as a single Bugzilla update.
- **Not capable**: nothing is recorded.
- **Skipped** without asking the model: a resolved bug, or one that already has
the tag.

The actions are auto-applied: a run that judged the bug capable sets
`findings.auto_apply`, which hackbot-api requires before applying anything
unattended. `summary.json`'s `findings` carries `capable`, `reasoning`,
`auto_apply` and `skip_reason`.

## Triggers

bugbot's `hackbot_capable` rule starts a run for each bug newly filed by a
Mozilla employee in the Testing components the performance team owns
(Performance, mozperftest, Raptor, Talos, AWSY, Condprofile). The agent itself is
not tied to those components or to who filed the bug.

## Input

- `BUG_ID`: the Bugzilla bug.
- `MODEL`, `MAX_TURNS`, `EFFORT` (optional): Claude settings.

## Running locally

With `ANTHROPIC_API_KEY`, `BUGZILLA_API_URL` and `BUGZILLA_API_KEY` in the repo
root's `.env`:

```sh
BUG_ID=1234567 docker compose up hackbot-capable-agent --build
```

A local run records the actions but doesn't apply them. Artifacts are written to
`~/hackbot/artifacts/<run_id>`.

## Tests

```sh
cd agents/hackbot-capable
uv run --extra dev pytest tests/
```
1 change: 1 addition & 0 deletions agents/hackbot-capable/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
33 changes: 33 additions & 0 deletions agents/hackbot-capable/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
hackbot-capable-broker:
build:
context: ../..
dockerfile: agents/hackbot-capable/Dockerfile
target: broker
environment:
BUGZILLA_API_URL: ${BUGZILLA_API_URL}
BUGZILLA_API_KEY: ${BUGZILLA_API_KEY}
expose:
- "8765"

hackbot-capable-agent:
build:
context: ../..
dockerfile: agents/hackbot-capable/Dockerfile
target: agent
environment:
- RUN_ID
- BUG_ID=${BUG_ID:?error}
- MODEL
- MAX_TURNS
- EFFORT
- BROKER_URL=http://hackbot-capable-broker:8765
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:?error}
# No uploader locally: summary/logs are written under /artifacts/<run_id>,
# bind-mounted to the host's ~/hackbot/artifacts.
- ARTIFACTS_DIR=/artifacts
volumes:
- ${HOME}/hackbot/artifacts:/artifacts
depends_on:
hackbot-capable-broker:
condition: service_started
15 changes: 15 additions & 0 deletions agents/hackbot-capable/hackbot.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Nothing to prepare: no [source] checkout, no [firefox] build. The bug is read
# through the Bugzilla broker and the code through Searchfox.

# Infrastructure this agent runs on, applied by Terraform. Changing anything here
# changes the agent's shape and goes through an infra PR; the image ships on
# its own.
[deploy]
runtime = "cloud_run_job"
cpu = "1"
memory = "2Gi"
timeout_seconds = 1800

[deploy.broker]
cpu = "1"
memory = "512Mi"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from hackbot_runtime import HackbotContext, run_async
from pydantic_settings import BaseSettings, SettingsConfigDict

from .agent import HackbotCapableResult, run_hackbot_capable

DEFAULT_MODEL = "claude-opus-5-5"
# Enough to read the bug and look up the code it names; a bug that needs more
# digging than this is not a simple one.
DEFAULT_MAX_TURNS = 30


class AgentInputs(BaseSettings):
bug_id: int
broker_url: str
model: str = DEFAULT_MODEL
max_turns: int = DEFAULT_MAX_TURNS
effort: str | None = None

model_config = SettingsConfigDict(extra="ignore")

@property
def bugzilla_mcp_url(self) -> str:
return f"{self.broker_url.rstrip('/')}/mcp"


async def main(ctx: HackbotContext) -> HackbotCapableResult:
inputs = AgentInputs()
return await run_hackbot_capable(
bugzilla_mcp_server={"type": "http", "url": inputs.bugzilla_mcp_url},
bug=inputs.bug_id,
actions_recorder=ctx.actions,
model=inputs.model,
max_turns=inputs.max_turns,
effort=inputs.effort,
log=ctx.log_path,
verbose=True,
)


if __name__ == "__main__":
run_async(main)
Loading