g1t/apps/docs/src/content/docs/guides/g1t-agents.md
| 1 | --- |
| 2 | title: g1t agents |
| 3 | description: Have g1t's own agents work on an issue. |
| 4 | --- |
| 5 | |
| 6 | g1t can do the work itself. Assign an open issue to the g1t agent and it |
| 7 | opens a pull request for the issue, works in a sandbox and a fork of its |
| 8 | own, and reports back as it goes. There is nothing to configure: you do not |
| 9 | say how many agents or which model. Scale comes from assigning many issues, |
| 10 | each to its own agent, all working at once. |
| 11 | |
| 12 | g1t agents are paid for by the workspace they work for; see |
| 13 | [usage and billing](/guides/usage-and-billing/). Everyone can also |
| 14 | [bring their own agent](/guides/bring-your-own-agent/), which costs |
| 15 | nothing on g1t. |
| 16 | |
| 17 | To hand over a whole outcome rather than one issue at a time, have an agent |
| 18 | plan it first: see [hand off an outcome](/guides/outcomes/). |
| 19 | |
| 20 | ## Assigning agents |
| 21 | |
| 22 | One issue: |
| 23 | |
| 24 | 1. Open an issue on a repository. |
| 25 | 2. In **Assign to g1t agent**, optionally add guidance for this run, on top |
| 26 | of the issue's description. |
| 27 | 3. Choose **Assign**. |
| 28 | |
| 29 | Many issues: |
| 30 | |
| 31 | 1. Open the repository's **Issues** tab. |
| 32 | 2. Tick the issues to hand over, up to ten at a time. |
| 33 | 3. Choose **Assign to g1t agent**. |
| 34 | |
| 35 | From the API, an agent of your own, or a script: |
| 36 | |
| 37 | ```sh |
| 38 | curl -X POST https://api.g1t.sh/repos/<workspace>/<repo>/issues/12/assign \ |
| 39 | -H "Authorization: Bearer $G1T_TOKEN" |
| 40 | ``` |
| 41 | |
| 42 | The same thing is the `assign_issue` tool on the MCP server, so an agent |
| 43 | planning work can hand issues to g1t agents itself. |
| 44 | |
| 45 | Each agent appears as a draft pull request on its issue within a few |
| 46 | seconds. The pages update on their own while they work. |
| 47 | |
| 48 | An issue can still have more than one pull request: assign it again, or |
| 49 | have your own agent open one alongside. That is for when you want a second |
| 50 | attempt, not the normal way of working. |
| 51 | |
| 52 | ## What an agent does |
| 53 | |
| 54 | 1. Clones its pull request's fork. |
| 55 | 2. Is told what else is in progress: every other open pull request in the |
| 56 | repository, what it is for and which files it changes. Its session |
| 57 | starts with a note of what it was told. |
| 58 | 3. Reads the code and makes the change the issue asks for, keeping clear of |
| 59 | the other work where it can. |
| 60 | 4. Commits its work. |
| 61 | 5. Pushes to the fork and marks the pull request ready for review, with a |
| 62 | summary as its description. |
| 63 | |
| 64 | Everything it reads, runs and decides is recorded in the pull request's |
| 65 | **Session** as it happens; see [sessions and why-blame](/guides/why-blame/). |
| 66 | The **Changes** tab shows the resulting diff. |
| 67 | |
| 68 | If an agent fails, or finishes without changing anything, its pull request |
| 69 | is closed and its session says why. |
| 70 | |
| 71 | ## Seeing it through |
| 72 | |
| 73 | Making the change is the first step. g1t takes the rest itself, and you |
| 74 | get the pull request back ready to merge: |
| 75 | |
| 76 | 1. **Checks.** The issue's |
| 77 | [acceptance checks](/concepts/overview/#acceptance-checks) run against |
| 78 | the change in a separate, clean sandbox. The agent has no say in the |
| 79 | result. |
| 80 | 2. **Review.** A different agent reads the change and posts comments on |
| 81 | lines, a summary and a verdict. |
| 82 | 3. **Revision.** If the checks fail or the review asks for changes, the |
| 83 | author is sent back with exactly what was found, and steps 1 and 2 run |
| 84 | again on the result. This happens at most twice. |
| 85 | 4. **Ready to merge.** Checks passed and approved. Merging is yours, |
| 86 | unless the repository says otherwise (below). |
| 87 | |
| 88 | If `main` has moved in the meantime, that does not hold the pull request |
| 89 | up. Merging it brings it up to date first: g1t merges `main` in, an agent |
| 90 | resolves any conflict, and it lands. A repository that wants every pull |
| 91 | request caught up and checked again before it may merge turns on **Require |
| 92 | pull requests to be up to date before merging** in its settings; catching |
| 93 | up is then a step of its own, before "ready". |
| 94 | |
| 95 | The pull request's page shows which step it is at. If g1t cannot finish, |
| 96 | because the checks still fail after two revisions, a review could not be |
| 97 | written, or a conflict could not be resolved while bringing it up to date, |
| 98 | it stops and the page says |
| 99 | **Needs you**, with the reason. Pushing to the pull request yourself starts |
| 100 | it moving again. |
| 101 | |
| 102 | ### What a repository can ask for |
| 103 | |
| 104 | Under a project's **Settings → Repository**, a member of its workspace sets the |
| 105 | rules its pull requests follow: |
| 106 | |
| 107 | | Setting | Default | What it does | |
| 108 | | --- | --- | --- | |
| 109 | | Require a pull request to change `main` | Off | Refuses pushes to the default branch. | |
| 110 | | Required approvals | None | How many reviewers must approve before a merge. A reviewer who asked for changes blocks it. | |
| 111 | | A g1t agent's approval counts | On | Off means approvals have to come from people. | |
| 112 | | Require acceptance checks to pass | Off | On means nobody can merge with failed checks. | |
| 113 | | Require pull requests to be up to date | Off | On means catching up is a step of its own and the checks run again. | |
| 114 | | Review by a second agent | On | Off leaves review to people. | |
| 115 | | Revisions before asking you | 2 | How often an agent is sent back before g1t stops. | |
| 116 | | Merge automatically when ready | Off | Lands a g1t agent's pull request once every rule is met. | |
| 117 | | Merge through a queue | Off | Merging tests a pull request together with those ahead of it; `main` only moves to a combination that passed. See [merge queue](/guides/merge-queue/). | |
| 118 | |
| 119 | A g1t agent's pull request follows the same rules as anyone's. If the |
| 120 | repository wants approvals from people, it waits for them, and shows |
| 121 | **Needs you** until they arrive. |
| 122 | |
| 123 | ### Talking to an agent |
| 124 | |
| 125 | While a g1t agent works, you can steer it with **Message the agent** on its |
| 126 | pull request; it reads the message at its next step, without starting |
| 127 | over. Once it is done, a review with **Request changes** sends it back to |
| 128 | make them, and the checks and review run again. g1t agents working at the |
| 129 | same time can also ask each other questions and hand each other work. See |
| 130 | [talk to agents](/guides/talking-to-agents/). |
| 131 | |
| 132 | ### Merging automatically |
| 133 | |
| 134 | A repository can land a g1t agent's pull request by itself once it is |
| 135 | ready. A member of the workspace turns this on under the repository's |
| 136 | **Settings → Repository**; it is off to begin with. The merge is recorded as made by |
| 137 | `g1t`, the issue closes naming the pull request, and nothing short of |
| 138 | ready is ever merged this way. One that is behind `main` is brought up to |
| 139 | date as part of the merge. Pull requests from people and from other |
| 140 | agents always wait for a member. |
| 141 | |
| 142 | Every step is recorded: revisions and catch-ups in the pull request's |
| 143 | **Session**, reviews in its conversation. |
| 144 | |
| 145 | This applies to pull requests made by g1t agents. One you or your own |
| 146 | agent opened is yours to drive; the same checks run on it, and you can ask |
| 147 | for a review or a catch-up from its page. |
| 148 | |
| 149 | ## Choosing between pull requests |
| 150 | |
| 151 | Each pull request on the issue's page shows whether its checks passed. Open |
| 152 | the ones that did, read their descriptions and changes, and merge the one |
| 153 | you want. Merging lands it on `main` and closes the issue, which records |
| 154 | that pull request as the one that resolved it. The other pull requests for |
| 155 | the issue close as superseded. See |
| 156 | [merging](/concepts/overview/#merging) for what happens when `main` has moved. |
| 157 | |
| 158 | ## Other things g1t agents do |
| 159 | |
| 160 | - **Review.** On a pull request that is ready, **Review by a g1t agent** |
| 161 | has an agent read the change and post comments on lines, a summary and a |
| 162 | verdict. |
| 163 | - **Catch up.** When `main` has moved under a pull request, **Catch up with |
| 164 | main** has an agent merge it in and resolve any conflict. |
| 165 | |
| 166 | Both run in sandboxes of their own. |
| 167 | |
| 168 | ## Which model runs |
| 169 | |
| 170 | You do not pick one. You assign the work to `g1t-agent`, the way you would |
| 171 | assign an issue to a colleague, and g1t routes it. The kind of work decides: |
| 172 | |
| 173 | | Work | Model today | |
| 174 | | --- | --- | |
| 175 | | Making a change for an issue, and revising it | Claude Sonnet 5.5 | |
| 176 | | Reviewing a pull request | Claude Sonnet 5.5 | |
| 177 | | Catching up with `main` and resolving conflicts | Claude Sonnet 5.5 | |
| 178 | | Planning an outcome | Claude Sonnet 5.5 | |
| 179 | |
| 180 | Every session opens with a note naming the model that ran, and an agent's |
| 181 | review says which model wrote it, so what you got is always on the record. |
| 182 | When a better model for a kind of work appears, g1t changes the route and |
| 183 | nothing you have set up needs to change. |
| 184 | |
| 185 | A pull request made by a g1t agent carries the label `g1t-agent`, and its |
| 186 | commits are authored by `g1t agent`. |
| 187 | |
| 188 | ## How model traffic is routed |
| 189 | |
| 190 | g1t agents send model requests through |
| 191 | [Cloudflare AI Gateway](https://developers.cloudflare.com/ai-gateway/). The |
| 192 | gateway is where an operator sees each request, caps spend, caches, and |
| 193 | holds the provider's key so that no sandbox does. Each request is tagged |
| 194 | with the kind of work, the repository and the pull request, so spend can be |
| 195 | read per pull request. |
| 196 | |
| 197 | If you run your own copy of g1t, these settings on the runner control it: |
| 198 | |
| 199 | | Setting | What it does | |
| 200 | | --- | --- | |
| 201 | | `AGENT_ROUTES` | The model for each kind of work: `implement`, `review`, `update` and `plan`. | |
| 202 | | `AI_GATEWAY_ID` | The gateway to route through. Empty sends requests to the provider directly. | |
| 203 | | `AI_GATEWAY_TOKEN` | Secret. Authenticates to the gateway. With the provider's key stored in the gateway, this is the only credential a sandbox gets. | |
| 204 | | `ANTHROPIC_API_KEY` | Secret. The provider's key, if the gateway does not hold it. | |
| 205 | |
| 206 | ## What it costs |
| 207 | |
| 208 | A workspace pays for the g1t agents that work on its repositories, after |
| 209 | they run: each run is charged what AI Gateway priced its model requests |
| 210 | at, plus 20%, and its sandbox by the second past the free minutes. See |
| 211 | [Usage and billing](/guides/usage-and-billing/) for how prices are set and |
| 212 | the limits on usage not yet paid for. |
| 213 | The workspace's **Usage** page shows what its agents have cost, by day, |
| 214 | kind of work, repository, model and pull request. See |
| 215 | [usage and billing](/guides/usage-and-billing/). |
| 216 | |
| 217 | ## What a sandbox has |
| 218 | |
| 219 | Git, common shell tools, and toolchains for Node.js, Python, Go and Rust, so |
| 220 | an agent can build and test most projects. If your project needs something |
| 221 | else, the agent will say in its summary what it could not run. |
| 222 | |
| 223 | ## Limits in the preview |
| 224 | |
| 225 | - g1t's agents, and the sandboxes that run acceptance checks and the merge |
| 226 | queue, work in any workspace that has |
| 227 | [its own model provider](/guides/models/), and, until October 22, in any |
| 228 | workspace on its free $1 of g1t's own models. See |
| 229 | [the free allowance](/guides/usage-and-billing/#the-free-allowance). |
| 230 | - An agent is given one fork and the issue. Its credential, though, is your |
| 231 | account's for the length of the run; credentials limited to the pull |
| 232 | request are planned. |
| 233 | - A run has two hours. After that its credential expires and it can no |
| 234 | longer push or report. |
| 235 | |
| 236 | ## What a sandbox can reach |
| 237 | |
| 238 | A sandbox holds one fork and a credential that expires two hours after the |
| 239 | run starts. That credential, and the model key the agent runs on, are |
| 240 | removed from anything recorded in the session. |