Skip to content

Simplify hackbot agent structure into self-contained agents/<name>/folders#6145

Merged
suhaibmujahid merged 21 commits into
mozilla:masterfrom
suhaibmujahid:worktree-simplify-hackbot-agents
Jun 11, 2026
Merged

Simplify hackbot agent structure into self-contained agents/<name>/folders#6145
suhaibmujahid merged 21 commits into
mozilla:masterfrom
suhaibmujahid:worktree-simplify-hackbot-agents

Conversation

@suhaibmujahid

Copy link
Copy Markdown
Member

Co-locate each agent's logic, entrypoint, and deployment in one folder; move shared building blocks (Reporter, actions_server_for, Bugzilla MCP) into hackbot-runtime; derive Job env from the input schema (model_to_env) instead of per-agent build_env. Migrate bug-fix as the reference.

@suhaibmujahid suhaibmujahid force-pushed the worktree-simplify-hackbot-agents branch from c60db3e to a174cde Compare June 10, 2026 05:31
Remove bugbug/tools/duplicate_bugs and the root pyproject bits it was the sole
user of: the bug-fix optional extra (agent-tools[bugzilla]) and the
duplicate_bugs/prompts wheel artifact. bugbug no longer depends on agent-tools.
The agent installed generic top-level packages (agent, broker), which would
collide when multiple agents are installed together (e.g. uv sync --all-packages
in the dev workspace). Ship each agent under a shared PEP 420 namespace instead:
bug-fix becomes hackbot_agents.bug_fix (broker -> hackbot_agents.bug_fix.broker).
hackbot_agents/ has no __init__.py, so future agents merge into the namespace
rather than clobbering. Entrypoints, packages, run_local, and the README are
updated; internal imports are relative so they're unchanged.
A run killed mid-fetch (e.g. container stop) leaves shallow.lock or
index.lock behind, causing the next run to fail with 'Another git
process seems to be running'. Since ensure_source_repo is the sole,
sequential git driver, any lock present at startup is stale and safe
to remove.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures hackbot into self-contained agents/<name>/ folders and introduces a new shared agent-tools library to centralize framework-neutral tool declarations (and claude-agent-sdk adapters), while shifting shared runtime utilities into hackbot-runtime. It also updates hackbot-api to derive Cloud Run Job env overrides generically from the agent input schema (model_to_env) instead of per-agent build_env.

Changes:

  • Add libs/agent-tools (tool registry + claude-agent-sdk adapter + Bugzilla read tools + Firefox tools) and wire it into hackbot-runtime and the bug-fix agent.
  • Introduce model_to_env and update hackbot-api run creation to fall back to it when no agent-specific env builder exists.
  • Migrate the bug-fix agent to the new agents/<name>/hackbot_agents/<name>/... structure and simplify Docker build flows to install packaged workspace members.

Reviewed changes

Copilot reviewed 53 out of 65 changed files in this pull request and generated no comments.

Show a summary per file
File Description
uv.lock Adds agent-tools workspace package and updates dependencies/sources for hackbot packages.
services/hackbot-api/tests/test_agents.py Adds tests for model_to_env and default registry behavior.
services/hackbot-api/pyproject.toml Adds hatch build config so the service can be packaged/installed cleanly.
services/hackbot-api/Dockerfile Updates build to install into /opt/venv via uv with bind mounts and no-editable installs.
services/hackbot-api/app/routers/runs.py Uses model_to_env when AgentSpec.build_env is not provided.
services/hackbot-api/app/agents.py Implements model_to_env and removes bug-fix’s hand-written env mapping.
pyproject.toml Removes bug-fix extra from bugbug and adds libs/agent-tools to uv workspace members/sources.
libs/hackbot-runtime/tests/test_source.py Adds tests for new ensure_source_repo helper.
libs/hackbot-runtime/tests/test_registry.py Removes tests for the old action registry (moved/replaced by agent-tools).
libs/hackbot-runtime/tests/test_claude.py Adds tests for new shared Reporter utilities.
libs/hackbot-runtime/tests/test_claude_sdk.py Updates claude-sdk adapter tests to use actions_server_for and adds coverage for fallback recorder behavior.
libs/hackbot-runtime/tests/test_bugzilla_actions.py Updates tests to use ToolError and new tool declaration approach.
libs/hackbot-runtime/pyproject.toml Adds dependency on agent-tools and wires optional claude-sdk extra through to it.
libs/hackbot-runtime/hackbot_runtime/source.py Adds ensure_source_repo shallow clone/update helper.
libs/hackbot-runtime/hackbot_runtime/context.py Updates import path for ActionsRecorder after module reshuffle.
libs/hackbot-runtime/hackbot_runtime/claude.py Adds shared Reporter implementation for claude-agent-sdk message streaming.
libs/hackbot-runtime/hackbot_runtime/actions/registry.py Removes runtime-specific action registry (superseded by agent-tools tool registry).
libs/hackbot-runtime/hackbot_runtime/actions/naming.py Removes action naming helpers (now in agent_tools.registry).
libs/hackbot-runtime/hackbot_runtime/actions/claude_sdk.py Replaces bespoke SDK server builder with wrapper around agent-tools adapter; introduces actions_server_for.
libs/hackbot-runtime/hackbot_runtime/actions/bugzilla.py Converts actions to @tool declarations and exports TOOLS via tools_in.
libs/hackbot-runtime/hackbot_runtime/actions/init.py Simplifies exports to recorder + domain modules; removes old registry exports.
libs/hackbot-runtime/hackbot_runtime/init.py Updates top-level exports; adds ensure_source_repo.
libs/agent-tools/tests/test_registry.py Adds tests for the new @tool decorator and schema inference/caching.
libs/agent-tools/tests/test_firefox.py Adds coverage that Firefox tools are exposed via SDK server adapter.
libs/agent-tools/tests/test_bugzilla.py Adds coverage for Bugzilla read tools and structured error payloads.
libs/agent-tools/pyproject.toml Defines the new agent-tools package with optional extras.
libs/agent-tools/agent_tools/registry.py Implements framework-neutral tool registry (ToolDefinition, @tool, schema derivation, ToolError).
libs/agent-tools/agent_tools/firefox/tools/js_shell_evaluator.py Adds SpiderMonkey shell evaluator implementation.
libs/agent-tools/agent_tools/firefox/tools/evaluate_testcase.py Adds Firefox/grizzly testcase evaluation implementation.
libs/agent-tools/agent_tools/firefox/tools/build_firefox.py Adds ./mach build helper implementation.
libs/agent-tools/agent_tools/firefox/tools/bootstrap_firefox.py Adds ./mach bootstrap helper implementation.
libs/agent-tools/agent_tools/firefox/tools/init.py Re-exports Firefox tool implementations.
libs/agent-tools/agent_tools/firefox/init.py Defines FirefoxContext and framework-neutral @tool wrappers; exports TOOLS.
libs/agent-tools/agent_tools/claude_sdk.py Adds claude-agent-sdk adapter to build in-process MCP servers from ToolDefinitions.
libs/agent-tools/agent_tools/bugzilla.py Adds Bugzilla read-only tools backed by bugsy; exports TOOLS.
libs/agent-tools/agent_tools/init.py Defines minimal public surface without importing optional-dependency submodules.
infra/dockerfile.spawn_pipeline Simplifies uv sync invocation to avoid mounting per-member pyprojects.
infra/dockerfile.base Simplifies uv sync invocation to avoid mounting per-member pyprojects.
http_service/Dockerfile.bg_worker Simplifies uv sync invocation to avoid mounting per-member pyprojects.
http_service/Dockerfile Simplifies uv sync invocation to avoid mounting per-member pyprojects.
bugbug/tools/duplicate_bugs/prompts/dupdetector_local.md Removes old duplicate-bugs prompt asset (tool removed/migrated as part of restructure).
bugbug/tools/duplicate_bugs/prompts/dupdetector_local_to_local.md Removes old duplicate-bugs prompt asset (tool removed/migrated as part of restructure).
bugbug/tools/duplicate_bugs/prompts/dupdetector_bugs.md Removes old duplicate-bugs prompt asset (tool removed/migrated as part of restructure).
bugbug/tools/duplicate_bugs/config.py Removes old duplicate-bugs config module.
bugbug/tools/duplicate_bugs/agent.py Removes old duplicate-bugs agent implementation.
bugbug/tools/duplicate_bugs/init.py Removes duplicate-bugs tool package export.
bugbug/tools/bug_fix/firefox_mcp.py Removes old in-process Firefox MCP server (replaced by agent-tools).
bugbug/tools/bug_fix/bugzilla_mcp.py Removes old in-process Bugzilla MCP server (replaced by agent-tools).
bugbug/tools/bug_fix/agent.py Removes old bug-fix tool implementation (migrated into agents/bug-fix/hackbot_agents/bug_fix).
agents/README.md Documents the new agents/<name>/ structure and shared building blocks.
agents/bug-fix/run_local.py Updates local runner to use agent-tools Bugzilla server and new hackbot_agents.bug_fix entrypoint.
agents/bug-fix/pyproject.toml Updates agent dist dependencies to hackbot-runtime + agent-tools and adds hatch packaging config.
agents/bug-fix/hackbot_agents/bug_fix/rules/unsupported-config.md Adds a new triage ruleset.
agents/bug-fix/hackbot_agents/bug_fix/rules/README.md Adds rules directory documentation.
agents/bug-fix/hackbot_agents/bug_fix/prompts/system.md Adds new bug-fix system prompt under the co-located agent package.
agents/bug-fix/hackbot_agents/bug_fix/hackbot.py Adds Cloud Run job entrypoint wiring inputs, checkout, logging publication, and run execution.
agents/bug-fix/hackbot_agents/bug_fix/config.py Updates config to use agent_tools.registry symbols; removes YAML config loader.
agents/bug-fix/hackbot_agents/bug_fix/broker/main.py Updates broker to build Bugzilla MCP server via agent-tools adapter.
agents/bug-fix/hackbot_agents/bug_fix/main.py Adds python -m hackbot_agents.bug_fix entrypoint.
agents/bug-fix/hackbot_agents/bug_fix/init.py Migrates bug-fix agent logic into the co-located agent package and uses shared reporter/actions server builder.
agents/bug-fix/Dockerfile Updates agent image to run python -m hackbot_agents.bug_fix and install into /opt/venv.
agents/bug-fix/agent_runner/main.py Removes old agent runner entrypoint (replaced by hackbot_agents.bug_fix).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

broker/{__init__,__main__}.py -> broker.py. The empty __init__.py added nothing,
and python -m hackbot_agents.bug_fix.broker resolves to the module just as it did
to the package's __main__, so the Dockerfile CMD is unchanged.
Without a [build-system], uv installs these editable via setuptools'
default import-hook editable mode, which writes a .pth that runs a
custom MetaPathFinder. Editors' static analysis (Pylance) won't execute
.pth code, so it can't locate the packages and flags every import as
unresolved. Matching the rest of the workspace (hatchling) makes the
editable install path-based, which resolves natively in any editor.
@suhaibmujahid suhaibmujahid force-pushed the worktree-simplify-hackbot-agents branch from 90a247d to d86661e Compare June 11, 2026 04:35
@suhaibmujahid suhaibmujahid marked this pull request as ready for review June 11, 2026 04:35
@suhaibmujahid suhaibmujahid requested a review from marco-c June 11, 2026 04:35
Comment thread libs/agent-tools/tests/test_firefox.py
Comment thread libs/agent-tools/agent_tools/registry.py
Comment thread agents/README.md Outdated
Comment thread agents/README.md Outdated
Comment thread agents/README.md Outdated
Comment thread agents/bug-fix/hackbot_agents/bug_fix/__main__.py Outdated
marco-c
marco-c previously approved these changes Jun 11, 2026
Replace the bug-fix agent's exit_code/bool result handling with a
HackbotAgentResult model (num_turns + optional total_cost_usd) that the
runtime serializes into summary.json findings. run_bug_fix now raises
AgentError on failure instead of flagging it, and handles a single bug.

Also drop the script-style banner comments in bug_fix/agent.py and fix a
stale ENABLED_ACTION_TYPES import in its config.
@suhaibmujahid suhaibmujahid enabled auto-merge (rebase) June 11, 2026 19:33
@suhaibmujahid suhaibmujahid disabled auto-merge June 11, 2026 19:33
@suhaibmujahid suhaibmujahid merged commit 2cd67c2 into mozilla:master Jun 11, 2026
6 checks passed
@suhaibmujahid suhaibmujahid deleted the worktree-simplify-hackbot-agents branch June 11, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants