> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-docsde-1785859450-e55f5fa.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect GitHub repositories to Managed Deep Agents

> Clone GitHub repositories, install the GitHub CLI, and inject credentials into a Managed Deep Agents sandbox.

The GitHub connector prepares repositories, the GitHub CLI (`gh`), and credentials inside a [managed sandbox](/langsmith/managed-deep-agents-deploy#configure-a-sandbox), so an agent can inspect a repository or open a pull request against it. It requires `managed-deepagents>=0.4.0`.

<Note>
  Managed Deep Agents is in **private [beta](/langsmith/release-stages)**, available on [LangSmith Cloud](/langsmith/cloud) in the US region only. [Join the waitlist](https://www.langchain.com/langsmith-managed-deep-agents-waitlist) to request access.
</Note>

This connector is separate from the [GitHub channel](/langsmith/managed-deep-agents-channels/github), which receives App webhooks, and Connect-with-GitHub under [identity](/langsmith/managed-deep-agents-identity).

## Add the connector

Create `connectors/github.py` or `connectors/github.ts`. Export the connector as `connector` in Python or as the module default in TypeScript.

<CodeGroup>
  ```python connectors/github.py theme={null}
  from managed_deepagents.connectors import github

  connector = github.connector(
      repositories=[
          {
              "repo": "acme/api",
              "path": "workspace/api",
              "ref": "main",
              "depth": 1,
              "on_reuse": "fetch",
          }
      ],
  )
  ```

  ```ts connectors/github.ts theme={null}
  import { github } from "managed-deepagents";

  export default github.connector({
    repositories: [
      {
        repo: "acme/api",
        path: "workspace/api",
        ref: "main",
        depth: 1,
        onReuse: "fetch",
      },
    ],
  });
  ```
</CodeGroup>

The connector clones each repository when the sandbox is created. When a thread reuses an existing sandbox, `on_reuse` / `onReuse` controls the checkout (see [Configure options](#configure-options)).

## Configure options

| Option (Python / TypeScript)               | Default | Purpose                                               |
| ------------------------------------------ | ------- | ----------------------------------------------------- |
| `repositories`                             | `[]`    | Repository checkouts and their sandbox paths.         |
| `install_cli` / `installCLI`               | `true`  | Install the GitHub CLI in the sandbox.                |
| `inject_credentials` / `injectCredentials` | `true`  | Expose resolved GitHub credentials to `git` and `gh`. |

Each entry in `repositories` accepts these fields:

| Field (Python / TypeScript)    | Default | Purpose                                                                          |
| ------------------------------ | ------- | -------------------------------------------------------------------------------- |
| `repo`                         | —       | Static repository to checkout, as `owner/repo`.                                  |
| `path`                         | —       | Relative sandbox path where the repository appears. Must be relative and unique. |
| `ref`                          | —       | Git ref (branch, tag, or SHA) to checkout.                                       |
| `depth`                        | —       | Shallow clone depth. Must be an integer of `1` or greater.                       |
| `sparse_paths` / `sparsePaths` | —       | Sparse checkout paths, relative to the repository root.                          |
| `submodules`                   | `false` | Initialize submodules.                                                           |
| `write`                        | —       | Use write credentials instead of read credentials for this checkout.             |
| `on_reuse` / `onReuse`         | `fetch` | Reuse behavior for an existing checkout: `keep`, `reset`, or `fetch`.            |

Set `write` to `true` only on checkouts the agent must push to, since it grants write credentials for the repository. Leave it unset for read-only work.

For private repositories, configure GitHub credentials through [identity](/langsmith/managed-deep-agents-identity#custom-downstream-credentials). The runtime resolves the credential, injects it into the sandbox as `GH_TOKEN`, and configures Git credentials for the run. The token is never stored in thread state.

## Test and deploy

Test the project locally with [`mda dev`](/langsmith/managed-deep-agents-cli#develop-locally), then deploy it with [`mda deploy`](/langsmith/managed-deep-agents-deploy). Open deployment traces in LangSmith to inspect model calls, tool calls, errors, and latency.

The connector runs only when the project declares a managed sandbox; without one, it does not run. After startup, confirm the checkout by asking the agent to list the files at the configured path, and confirm credentials by asking it to run `gh auth status` in the sandbox. For deploy symptoms and fixes, see [Troubleshooting](/langsmith/managed-deep-agents-cli#troubleshooting).

## Next steps

<CardGroup cols={2}>
  <Card title="Connectors" icon="plug" href="/langsmith/managed-deep-agents-connectors">
    Compare connector types.
  </Card>

  <Card title="GitHub channel" icon="brand-github" href="/langsmith/managed-deep-agents-channels/github">
    Receive GitHub App webhooks.
  </Card>

  <Card title="Identity" icon="fingerprint" href="/langsmith/managed-deep-agents-identity">
    Scope callers and resolve credentials.
  </Card>

  <Card title="Configure a sandbox" icon="box" href="/langsmith/managed-deep-agents-deploy#configure-a-sandbox">
    Configure sandbox scope and lifecycle.
  </Card>
</CardGroup>

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/managed-deep-agents-connectors/github.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
