fix(agent): shallow clone repositories for cloud tasks - #4051
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Prompt To Fix All With AI### Issue 1
packages/agent/src/adapters/local-tools/tools/clone-repo.ts:114
**Shallow clone breaks branch switching**
When `clone_repo` is called again for a different branch of the same repository, the existing-clone path runs `checkout(branch)` without fetching it, but the initial `--single-branch` clone has no ref for that branch, causing the checkout to fail and leaving the agent on the previously cloned branch.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(agent): allow repository setup in au..." | Re-trigger Greptile |
| }, | ||
| { | ||
| environment, | ||
| channelMode, |
There was a problem hiding this comment.
High: GitHub token becomes readable by the agent
Enabling channelMode exposes clone_repo, which clones using a URL containing the GitHub token. Git saves that URL as remote.origin.url in .git/config, so a malicious task can call clone_repo and then read the current token from the cloned repository. Authenticate through a temporary credential helper or HTTP authorization header instead, and ensure the stored origin URL never contains credentials.
PR overviewThis pull request changes the agent’s cloud-task repository cloning behavior to use shallow Git clones, including cloning through the Claude agent’s One high-impact issue remains open: when channel mode is enabled, a task can clone a repository and then read the GitHub token persisted in the clone’s Git configuration. This exposes a live credential to potentially malicious agent workloads and should be fixed by using non-persistent authentication before merging. Open issues (1)
Fixed/addressed: 0 · PR risk: 8/10 |
Problem
Repository-less cloud tasks need to discover and clone the right repository at runtime. A normal clone can download years of history and tags for large repositories, and Auto mode paused for approval before the new repository tools could run.
Changes