gh CLI.
Repository resources share their lifecycle with the owning Session. If you need to change the URL or mount_path, create a new Session — mounted repositories cannot be swapped on a running Session.
Workflow
Prepare a GitHub token
Generate a GitHub Personal Access Token (a fine-grained PAT is recommended) that grants the repository scopes required for the task — read, write, Pull Request creation, etc. The token is a required field on every GitHub repository resource.
Mount the repository when creating the Session
Add a
type: "github_repository" entry to resources in the create-Session request, including the URL and PAT.Agent works on the code
Once the Session boots, the Agent can read code at the mount path and modify files via
Bash, Read, Write, Edit, etc.Repository clones live on the container’s ephemeral disk. After 24 hours of inactivity the platform may reclaim the disk; the Session can still resume conversation, but uncommitted changes on disk are lost. See Container reference — File persistence.
Repository resource fields
A GitHub repository resource uses the following fields. Pass them in when you create the Session:| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "github_repository" |
url | string | Yes | Repository URL, e.g. https://github.com/your-org/your-repo |
mount_path | string | No | Path to clone into inside the container. Defaults to a path derived from the repository name |
authorization_token | string | Yes | GitHub Personal Access Token used to clone and push the repository |
authorization_token is supplied only on the create request or token-rotation request. It is not returned when you fetch Session details or Session resources. Use a least-privilege PAT for each Session and revoke it when finished.Mount a GitHub repository at Session creation
Call Create Session with the repository insideresources[]:
resources array contains the normalized mount description. The token is not returned:
Mount multiple repositories
A single request can attach several repositories under differentmount_path values, for example to bring frontend and backend code into the same Session:
Token permission model
GitHub offers two PAT flavours: fine-grained PATs (recommended) and classic PATs. Whichever you choose, follow the principle of least privilege and grant only the scopes the task needs.Recommended permissions
The table below maps common Agent actions to fine-grained PAT repository permissions. For a classic PAT, the equivalent is therepo scope.
| Agent action | Fine-grained PAT permission (Repository permissions) |
|---|---|
| Clone / read a private repo | Contents: Read |
| Create a branch and push | Contents: Read & Write |
| Open / comment on Pull Requests | Pull requests: Read & Write |
| Read Issues | Issues: Read |
| Create / comment on Issues | Issues: Read & Write |
| Read repository metadata (always required) | Metadata: Read |
Security guidance
- Keep the Session creation request body and any response containing
resourcesout of logs, screenshots, and version control — they include the plaintext PAT. - Revoke the PAT in GitHub settings as soon as the task ends; fine-grained PATs also support short
Expirationvalues. - The PAT is required even for public repositories; for those, prefer a read-only, short-lived token to minimize the exposure surface.
- Use distinct PATs across environments (development vs production) so audit trails remain meaningful.
Pull Request workflow
Inside a mounted repository directory, the Agent can rungit and gh commands directly. The runtime image ships both git and the gh CLI, and the platform automatically wires the repository resource’s authorization_token into the container as GH_TOKEN — there is no need to install gh or export the token yourself. To drive the full “edit -> push -> open PR” flow:
- Enable the
agent_toolset_20260401toolset on the Agent and include at leastBash,Read,Write, andEdit. See Tools. - State the task, repository path, and target branch clearly in the user message.
sess_019e5ce0bf9074b69c3481e93771a522 with a repository mounted at /app/your-repo:
The platform auto-configures
GH_TOKEN inside the container from the repository resource’s authorization_token, so gh pr create works out of the box. PR creation fails if that PAT lacks Pull requests: Read & Write; provision the PAT with the scopes listed in Recommended permissions up front.Best practices for Agent configuration
- Enable
Bash,Read,Write,Edit,Glob, andGrepin the Agent’stoolsto cover code search and modification. - State the mount path explicitly in the Agent’s
systemprompt, e.g. “Your working directory is/app/your-repo. Run allgitandghcommands inside this folder.” - For long tasks, ask the Agent to run
git statusat the end of each turn so nothing is left uncommitted. - To carry artefacts across Sessions, have the Agent upload key outputs (patches, reports) via the Files API; otherwise unuploaded intermediate files are lost when the container disk is reclaimed after 24 hours of inactivity.
FAQ
Q: The repository is huge — how do I speed up cloning? A: Repository resources currently use a full clone; there is no shallow-clone switch on the resource object. For very large monorepos, narrow the task scope or upload the relevant subdirectories/files via the Files API as supplemental context. Q: What if the PAT expires or is revoked? A: Subsequent git /gh calls return 401. Create a new Session with a fresh PAT. If you have local changes that have not been pushed, ask the Agent to emit a git diff patch first and upload it via the Files API for safekeeping.
Q: Are private forks or organization-internal repositories supported?
A: Yes — as long as the PAT has Contents: Read on the target repository. If the organization enforces SSO, you must authorize the PAT (Authorize button) before it can clone.
Q: Are git submodules supported?
A: Repository resources do not expose a separate submodule field. If you need submodules, have the Agent run git submodule update --init --recursive inside the repository, and make sure the PAT has read access to every submodule repository.
Q: Can I swap repositories on a running Session?
A: No. Once a Session is created with a particular repository mount, that mount cannot be replaced via update calls. Create a new Session if you need a different repository or mount_path.
Q: Will the Agent automatically push changes back to GitHub?
A: No. Unless the Agent runs git push in its turn, edits remain on the container’s ephemeral disk. Spell out “push the branch” or “open a PR” in the user message.
Q: Is GitHub Enterprise Server (GHES) supported?
A: GitHub repository resources expose only url, mount_path, and authorization_token; there is no separate GHES configuration field. For GitHub Enterprise Server, confirm the GHES endpoint is reachable from the platform and that the token works with gh/git for that host.
Next steps
- Sessions — Attach resources at creation — overview of resource mounts
- API — Create a session — full request body for Session creation
- Skills — reuse code review and PR workflows
- Container reference — directory layout and disk behaviour