Support triggering the bug-fix agent for follow-ups when mentioning @hackbot#6353
Open
suhaibmujahid wants to merge 11 commits into
Open
Support triggering the bug-fix agent for follow-ups when mentioning @hackbot#6353suhaibmujahid wants to merge 11 commits into
@hackbot#6353suhaibmujahid wants to merge 11 commits into
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.
marco-c
reviewed
Jul 20, 2026
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.
Comment on lines
+72
to
+85
| # Dedupe retried deliveries: if we've already seen every triggering | ||
| # transaction, this is a retry of work already handled. | ||
| fresh = [phid for phid in triggering if phid not in _seen_transactions] | ||
| if not fresh: | ||
| return {"status": "ignored", "reason": "duplicate delivery"} | ||
| for phid in fresh: | ||
| _seen_transactions[phid] = True | ||
|
|
||
| detected = await detect_mention_and_revision( | ||
| phab_client, | ||
| settings.webhook, | ||
| object_phid, | ||
| triggering, | ||
| ) |
Comment on lines
+91
to
+98
| run_id = await api_client.trigger_run( | ||
| "bug-fix", | ||
| { | ||
| "bug_id": bug_id, | ||
| "revision_id": revision_id, | ||
| "comment": comment, | ||
| }, | ||
| ) |
Comment on lines
+152
to
156
| if revision_id and comment: | ||
| user_prompt = render_prompt( | ||
| "follow-up.md", revision_id=revision_id, bug_id=bug, comment=comment | ||
| ) | ||
| else: |
Comment on lines
+45
to
+50
| # Phabricator Conduit connection config, embedded as a nested model and | ||
| # populated in this single settings parse from PHABRICATOR_URL / | ||
| # PHABRICATOR_API_KEY / PHABRICATOR_TIMEOUT_SECONDS (see env_nested_delimiter | ||
| # below). Injected directly as PhabricatorClient(settings.phabricator). | ||
| # Required, so a missing/invalid api_key fails at startup. | ||
| phabricator: PhabricatorSettings |
Comment on lines
33
to
37
| bugzilla_api_url: str | ||
| bugzilla_api_key: str | ||
| phabricator_url: str | ||
| phabricator_api_key: str | ||
| host: str = "0.0.0.0" |
Comment on lines
+95
to
+104
| phabricator_settings = PhabricatorSettings( | ||
| url=inputs.phabricator_url, api_key=inputs.phabricator_api_key | ||
| ) | ||
| return Starlette( | ||
| routes=[ | ||
| Mount("/mcp", app=mcp_handler), | ||
| _phabricator_route(phabricator_settings), | ||
| ], | ||
| lifespan=lifespan, | ||
| ) |
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.
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.