Add hackbot-api service#5970
Open
suhaibmujahid wants to merge 24 commits into
Open
Conversation
68a5381 to
5b883c8
Compare
ea18276 to
da2dc0b
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new “hackbot” stack to the repo: a FastAPI-based orchestration service (hackbot-api) that triggers Cloud Run Jobs for agents, plus a small shared runtime library (hackbot-runtime) used by agent containers to upload artifacts/summary data back to GCS. It also refactors the existing bug-fix agent execution model so Bugzilla credentials live in a broker sidecar instead of the agent container.
Changes:
- Add
services/hackbot-api(FastAPI + Cloud Run Jobs trigger, Cloud SQL persistence, GCS signed-policy generation, Alembic migrations). - Add
libs/hackbot-runtimefor agent-side summary + artifact uploads via signed POST policy. - Add
agents/bug-fix(agent + broker multi-container build) and update bug-fix tool wiring to use an HTTP MCP broker for Bugzilla.
Reviewed changes
Copilot reviewed 38 out of 42 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Updates workspace membership and locks additional dependencies for new hackbot components. |
| pyproject.toml | Adds new uv workspace members for hackbot service/agent/runtime. |
| docker-compose.yml | Adds Compose include for the bug-fix agent/broker setup. |
| services/hackbot-api/pyproject.toml | Declares hackbot-api package dependencies and pytest config. |
| services/hackbot-api/Dockerfile | Builds the hackbot-api container using uv workspace sync. |
| services/hackbot-api/app/init.py | Defines hackbot-api version constant. |
| services/hackbot-api/app/main.py | FastAPI app setup, Sentry init, lifespan DB init/close, health endpoint. |
| services/hackbot-api/app/config.py | Pydantic settings for GCP/DB/auth/runtime configuration. |
| services/hackbot-api/app/auth.py | API key header auth dependency for routes. |
| services/hackbot-api/app/schemas.py | Pydantic API schemas for runs, artifacts, agents, and inputs. |
| services/hackbot-api/app/agents.py | Agent registry + per-agent env var mapping (bug-fix). |
| services/hackbot-api/app/jobs.py | Cloud Run Jobs trigger + execution status polling (async wrappers). |
| services/hackbot-api/app/gcs.py | GCS signed POST policy generation and run artifact/summary reading. |
| services/hackbot-api/app/routers/init.py | Exposes runs router. |
| services/hackbot-api/app/routers/runs.py | Endpoints for listing agents, creating runs, fetching run status + reconciliation. |
| services/hackbot-api/app/database/init.py | Marks DB package. |
| services/hackbot-api/app/database/models.py | SQLAlchemy model for runs table. |
| services/hackbot-api/app/database/connection.py | Cloud SQL Connector + async SQLAlchemy engine/session setup. |
| services/hackbot-api/alembic.ini | Alembic configuration for the new service. |
| services/hackbot-api/alembic/env.py | Alembic environment running migrations via Cloud SQL Connector. |
| services/hackbot-api/alembic/script.py.mako | Alembic revision template. |
| services/hackbot-api/alembic/versions/b5b896e1ce12_initial_schema.py | Initial migration creating runs table and indexes. |
| libs/hackbot-runtime/pyproject.toml | Declares the hackbot-runtime library package and dependencies. |
| libs/hackbot-runtime/hackbot_runtime/init.py | Exposes runtime public API surface. |
| libs/hackbot-runtime/hackbot_runtime/context.py | Loads agent runtime context from env and constructs uploader. |
| libs/hackbot-runtime/hackbot_runtime/result.py | Defines AgentResult summary contract. |
| libs/hackbot-runtime/hackbot_runtime/runtime.py | Provides run/run_async wrappers to write summary.json and handle failures. |
| libs/hackbot-runtime/hackbot_runtime/uploader.py | Implements signed-policy POST uploads to GCS for artifacts/summary. |
| agents/bug-fix/pyproject.toml | Declares the bug-fix agent package and its workspace sources. |
| agents/bug-fix/Dockerfile | Multi-target build producing agent and broker images. |
| agents/bug-fix/compose.yml | Local compose wiring for agent + broker containers. |
| agents/bug-fix/broker/init.py | Marks broker package. |
| agents/bug-fix/broker/main.py | Bugzilla MCP broker (HTTP) holding Bugzilla credentials. |
| agents/bug-fix/agent_runner/init.py | Marks agent_runner package. |
| agents/bug-fix/agent_runner/main.py | Agent entrypoint: ensure Firefox checkout, run tool, upload logs, emit summary. |
| scripts/run_bug_fix.py | Updates local runner to use in-process Bugzilla MCP server wiring. |
| bugbug/tools/bug_fix/agent.py | Refactors bug-fix tool to accept an MCP server config instead of raw Bugzilla token/url and removes selector logic. |
| bugbug/tools/bug_fix/bugzilla_mcp.py | Removes dry-run “simulated writes” tracking from Bugzilla MCP context. |
| bugbug/tools/bug_fix/config.py | Expands allowed Firefox MCP tools list (js shell + bootstrap). |
| bugbug/tools/bug_fix/firefox_mcp.py | Exposes new bootstrap_firefox MCP tool and includes it in the server tool list. |
| bugbug/tools/bug_fix/firefox_tools/init.py | Exports new bootstrap helper. |
| bugbug/tools/bug_fix/firefox_tools/bootstrap_firefox.py | Adds async helper for ./mach bootstrap toolchain setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
`_validate_result` returned an unraised `RuntimeError` that then flowed into `_finish` → `_summary_payload_from_exception`. With no active exception, `traceback.format_exc()` returns "NoneType: None", which produced a useless summary and obscured the real reason for failure. Build an AgentResult(status="error", exit_code=1) directly so the summary path is deterministic, and drop the now-dead RuntimeError branch in `run()` / `run_async()`.
`upload_file` previously called `path.read_bytes()`, pulling the entire artifact into memory. The signed POST policy permits uploads up to several GB; agents that write large build logs or patches would burn unnecessary RSS. Factor the POST out of `upload_bytes`/`upload_file` into a shared `_post` that accepts either bytes or a file handle so the file path streams via the multipart encoder.
The docstring promises every return dict carries `stdout` and `stderr`. The early-return when the directory is missing and the exception handler both omitted them, forcing callers to special-case those shapes. Include empty strings on both paths.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.