Support triggering the bug-fix agent for follow-ups when mentioning @hackbot#6353
Conversation
Both consumers run in hackbot-api's event loop (the webhook route and the apply handler awaited by the action applier), so the Conduit client is now async (httpx.AsyncClient). The apply handler's helpers become async, with _repository_phid cached via async-lru instead of functools.lru_cache.
Update Phabricator mention handling to collect every triggering @hackbot comment in a delivery instead of only the first match. The webhook now returns all qualifying comments in transaction order, skips bot/self and non-triggering transactions as before, and combines multiple comments into a numbered payload so the agent can address each request. Follow-up prompt wording was updated to reflect multi-comment runs and mixed review requests, and webhook tests were expanded for multi-inline mentions, per-transaction version handling, and comment-join formatting.
Pass `bug_id` when rendering the bug-fix follow-up prompt and update the prompt text to include the linked bug number alongside the Phabricator revision. This gives follow-up runs clearer issue context when responding to mention-triggered comments.
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end support for Phabricator follow-up runs triggered by @hackbot mentions: hackbot-api receives signed Phabricator webhooks, resolves the revision+bug via Conduit, and triggers a bug-fix run that checks out the revision’s base+diff via a broker sidecar and can optionally respond on the revision.
Changes:
- Add a Phabricator webhook receiver to
hackbot-api(HMAC-authenticated) that triggersbug-fixfollow-up runs when an@hackbotmention is detected. - Introduce a shared
phabricator-clientlibrary (httpx-based) and wire it into both the webhook receiver and the apply-side Phabricator handlers. - Extend
hackbot-runtime+bug-fixagent to support revision-based follow-ups (checkout revision, follow-up prompt, and a new “add comment” action/handler).
Reviewed changes
Copilot reviewed 41 out of 42 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Adds workspace member phabricator-client and dependency updates for new webhook/revision features. |
| services/hackbot-api/tests/test_webhooks.py | Adds tests for signature verification, mention detection, revision resolution, dedupe, and webhook route behavior. |
| services/hackbot-api/tests/conftest.py | Seeds required env vars so settings validation doesn’t fail during tests. |
| services/hackbot-api/pyproject.toml | Adds runtime deps needed for webhook receiver + Conduit calls (cachetools, httpx, phabricator-client). |
| services/hackbot-api/app/schemas.py | Extends BugFixInputs with optional revision_id and comment for follow-up runs. |
| services/hackbot-api/app/routers/webhooks.py | Implements /webhooks/phabricator endpoint to detect mentions and trigger a bug-fix follow-up run. |
| services/hackbot-api/app/routers/init.py | Exposes the new webhooks router. |
| services/hackbot-api/app/phabricator_webhook.py | Adds webhook payload parsing, mention detection, and Conduit resolution helpers. |
| services/hackbot-api/app/main.py | Includes the new webhooks router in the FastAPI app. |
| services/hackbot-api/app/config.py | Adds nested phabricator + webhook settings and env nesting configuration. |
| services/hackbot-api/app/client.py | Adds async client used by the webhook receiver to trigger hackbot runs via public API. |
| services/hackbot-api/app/auth.py | Adds Phabricator HMAC signature verification + dependency guard. |
| libs/phabricator-client/tests/test_client.py | Adds unit tests for Conduit request behavior and helper methods. |
| libs/phabricator-client/pyproject.toml | Defines the new phabricator-client library package. |
| libs/phabricator-client/phabricator_client/models.py | Adds typed Phabricator models (e.g., latest diff metadata). |
| libs/phabricator-client/phabricator_client/config.py | Adds validated settings model + env-driven loader for standalone use. |
| libs/phabricator-client/phabricator_client/client.py | Implements the async httpx-based Conduit client and helper APIs. |
| libs/phabricator-client/phabricator_client/init.py | Exports the public API of phabricator-client. |
| libs/hackbot-runtime/tests/test_revision.py | Tests revision checkout via broker patch endpoint and git apply behavior. |
| libs/hackbot-runtime/tests/test_phabricator_handler.py | Updates apply-side handler tests for async client and adds comment handler coverage. |
| libs/hackbot-runtime/tests/test_phabricator_actions.py | Adds tests for recording phabricator.add_comment. |
| libs/hackbot-runtime/tests/test_context.py | Updates tests to the new async prepare_repo() / repo_path contract. |
| libs/hackbot-runtime/pyproject.toml | Adds deps for Phabricator support (httpx, async-lru, phabricator-client). |
| libs/hackbot-runtime/hackbot_runtime/revision.py | Adds logic to check out a Phabricator revision (base commit + diff) via broker. |
| libs/hackbot-runtime/hackbot_runtime/context.py | Replaces source_repo lazy property with prepare_repo() + repo_path and one-time preparation enforcement. |
| libs/hackbot-runtime/hackbot_runtime/actions/phabricator.py | Adds phabricator_add_comment action recording with a standard footer. |
| libs/hackbot-runtime/hackbot_runtime/actions/handlers/registry.py | Registers the new phabricator.add_comment apply handler. |
| libs/hackbot-runtime/hackbot_runtime/actions/handlers/phabricator_handler.py | Migrates Conduit calls to shared phabricator-client and adds apply-side comment posting. |
| libs/hackbot-runtime/hackbot_runtime/init.py | Exports checkout_revision from the runtime package. |
| agents/frontend-triage/hackbot_agents/frontend_triage/main.py | Updates to call prepare_repo() and pass ctx.repo_path instead of ctx.source_repo. |
| agents/build-repair/hackbot_agents/build_repair/main.py | Uses prepare_repo(ref=…, depth=…) rather than env mutation and passes ctx.repo_path. |
| agents/bug-fix/tests/test_inputs.py | Adds validation tests for revision follow-ups requiring broker URL. |
| agents/bug-fix/tests/test_broker.py | Adds tests for broker patch route (base commit expansion + diff retrieval). |
| agents/bug-fix/pyproject.toml | Adds phabricator-client + pytest config for the agent package. |
| agents/bug-fix/hackbot_agents/bug_fix/prompts/triage-and-fix.md | Moves the triage prompt text into a template file. |
| agents/bug-fix/hackbot_agents/bug_fix/prompts/system.md | Updates system prompt to reflect “Hackbot” identity and new action tool. |
| agents/bug-fix/hackbot_agents/bug_fix/prompts/follow-up.md | Adds follow-up prompt template for responding to @hackbot mention comments on a revision. |
| agents/bug-fix/hackbot_agents/bug_fix/config.py | Enables the new Phabricator add-comment action type. |
| agents/bug-fix/hackbot_agents/bug_fix/broker.py | Extends broker to serve Phabricator patch route in addition to Bugzilla MCP. |
| agents/bug-fix/hackbot_agents/bug_fix/agent.py | Adds prompt templating and follow-up mode (revision_id + comment). |
| agents/bug-fix/hackbot_agents/bug_fix/main.py | Checks out revision via broker when REVISION_ID is set; otherwise prepares repo. |
| agents/bug-fix/compose.yml | Wires Phabricator broker URL + follow-up env vars into local compose. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
marco-c
left a comment
There was a problem hiding this comment.
LGTM overall. I didn't review all the code, but the design looks good.
As discussed today, let's think if we also want to trigger hackbot automatically on all comments on hackbot-owned revisions.
Note
This PR car be reviewed commit by commit
This PR will add support to trigger the bug-fix agent for follow-ups when mentioning
@hackbotin a comment on a Phabricator revision.