Skip to content

fix(agent): shallow clone repositories for cloud tasks - #4051

Open
tatoalo wants to merge 3 commits into
mainfrom
agent/shallow-cloud-repo-clones
Open

fix(agent): shallow clone repositories for cloud tasks#4051
tatoalo wants to merge 3 commits into
mainfrom
agent/shallow-cloud-repo-clones

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

  • expose local repository listing and cloning tools to repo-less Claude and Codex cloud sessions
  • clone with a single branch, depth 1, and no tags through the existing clone saga
  • tell the agent to use the repository tools and deepen history only when needed
  • allow the trusted local repository setup tools to run without a permission prompt in Auto mode

@trunk-io

trunk-io Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

@tatoalo tatoalo self-assigned this Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 6380d23.

@tatoalo
tatoalo marked this pull request as ready for review July 31, 2026 15:30
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
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

Comment thread packages/agent/src/adapters/local-tools/tools/clone-repo.ts
},
{
environment,
channelMode,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@veria-ai

veria-ai Bot commented Jul 31, 2026

Copy link
Copy Markdown

PR overview

This pull request changes the agent’s cloud-task repository cloning behavior to use shallow Git clones, including cloning through the Claude agent’s clone_repo capability.

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

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.

1 participant