Repository navigation
Fetch agents' internal repositories at build time - #7706
Open
suhaibmujahid wants to merge 3 commits into
Open
suhaibmujahid wants to merge 3 commits into
suhaibmujahid wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The token request uses an invalid REST action that prevents private dependency access, and token files remain exposed in the Docker build context to package build scripts.
2 open issues
What changed in this PR
This PR adds build-time private repository fetching for Hackbot agents, laying groundwork for #7610. No agent adopts the feature yet.
Changes:
- Adds a shared script to fetch repositories at pinned commits using a BuildKit secret.
- Adds per-agent token retrieval from Cloud Build’s GitHub connection and token cleanup after builds.
- Documents the workflow and tests fetching, token handling, and failure isolation.
| File | Description |
|---|---|
| tools/hackbot-deploy/tests/test_fetch_repos.py | Tests pinned fetches and token-safe error handling. |
| tools/hackbot-deploy/tests/test_build_tokens.py | Tests token retrieval, file permissions, and per-agent failures. |
| tools/hackbot-deploy/scripts/fetch_repos.py | Fetches configured repositories using a supplied token. |
| tools/hackbot-deploy/README.md | Documents private repository build integration. |
| tools/hackbot-deploy/hackbot_deploy/cli.py | Adds the plan-driven build-tokens command. |
| tools/hackbot-deploy/hackbot_deploy/build_tokens.py | Retrieves read tokens and writes per-agent secret files. |
| agents/cloudbuild.yaml | Adds token retrieval, BuildKit secret passing, and cleanup. |
Review effort: Balanced
The shared scripts/fetch_repos.py fetches each repository in an agent's [build] table at its pinned commit, for a Dockerfile build stage to copy from, using one BuildKit secret, github_token. In Cloud Build, a new Tokens step runs hackbot-deploy build-tokens, which asks the build's GitHub connection for a short-lived read token for each planned agent with a [build] table, so no GitHub credential of ours is ever in the build. The Build step passes it as the secret and removes it afterwards. A failed token costs only that agent; no agent uses this yet.
build-deps undersold it: the stage fetches whole repositories, into /repos/<name>.
The Tokens step wrote them under /workspace, the build context, which every agent's Dockerfile bind-mounts to install dependencies, so any package build script in any agent built afterwards could read them. They now go to a github-tokens volume that only the Tokens and Build steps mount.
suhaibmujahid
force-pushed
the
perf-plugin/build-tokens
branch
from
December 3, 2026 00:25
3e09d20 to
7508fce
Compare
suhaibmujahid
enabled stacked auto-merge (squash)
December 3, 2026 00:40
This branch has not been deployed
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.

Part of #7610
The shared scripts/fetch_repos.py fetches each repository in an agent's
[build] table at its pinned commit, for a Dockerfile build stage to copy
from, using one BuildKit secret, github_token. In Cloud Build, a new
Tokens step runs hackbot-deploy build-tokens, which asks the build's
GitHub connection for a short-lived read token for each planned agent
with a [build] table, so no GitHub credential of ours is ever in the
build. The Build step passes it as the secret and removes it afterwards.
A failed token costs only that agent; no agent uses this yet.
Stack created with GitHub Stacks CLI • Give Feedback 💬