g1t/apps/docs/src/content/docs/guides/working-with-g1t.md

721 lines38,233 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent1---
2title: g1t's agent
3description: Assign an issue to g1t and it does the work.
4---
5
6g1t can do the work itself. Its agent is named `g1t`: assign an open issue
7to g1t and it opens a pull request for the issue, works in a sandbox and a
8fork of its own, and reports back as it goes. There is nothing to
9configure: you do not say how many agents or which model. Scale comes from
10assigning many issues, each worked on by its own run, all at once.
11
12Everything g1t does shows as `g1t`: the pull requests it opens, its
13commits, comments, reviews, plans and security updates, assignments,
14timeline events, the audit log, notifications and webhooks. A pull request
15g1t opens shows g1t as its author, with **requested by** naming the person
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights16who asked for it. See [who a pull request is for](#who-a-pull-request-is-for).
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent17
18g1t's runs are paid for by the workspace they work for, so they need a
19paid workspace or the free trial; see [who can run agents](#who-can-run-agents)
20and [usage and billing](/guides/usage-and-billing/). Everyone can also
21[bring their own agent](/guides/bring-your-own-agent/), which costs
22nothing on g1t.
23
24To hand over a whole outcome rather than one issue at a time, have an agent
25plan it first: see [hand off an outcome](/guides/outcomes/).
26
27## Put an agent on it in one step
28
29When the work is not written down yet, open the issue and hand it to the
30agent at once:
31
321. On Mission control, choose **Put an agent on it**.
332. Pick the project, give a title, and say what you want done in plain
34 words, with what done means if you know it.
353. Choose **Put an agent on it**.
36
37You land on the new issue with the agent already at work on its pull
38request. The same choice is on a project's **New issue** page, as **Assign
39g1t now**, and in the ⌘K palette as **Put an agent on …** followed by
40a project's name.
41
42Putting an agent to work needs the Write role on the project. Without it,
43nothing is opened. With it, the issue is always opened, even when the
44agent cannot start:
45
46| What happened | What you see |
47| --- | --- |
48| The agent started | The issue, with its draft pull request under **Assignees**. |
49| Every agent slot of the workspace is busy | The issue, queued for g1t. It starts by itself when a slot frees up. |
50| The workspace's plan or limits refused it | The issue is opened, and the composer says why and links to the fix: start the plan or the trial (`not_paid`, `trial_used`), raise the monthly limit (`limit`) or the cap per issue (`issue_cap`), or connect a model (`no_model`). A workspace g1t `paused` says to contact support. |
51
52From the API or an agent of your own, it is one call:
53
54```sh
55curl -X POST https://api.g1t.sh/repos/<workspace>/<repo>/issues/delegate \
56 -H "Authorization: Bearer $G1T_TOKEN" \
57 -H "Content-Type: application/json" \
58 -d '{"title": "Retry webhooks with exponential backoff", "body": "Deliveries that fail are dropped today. Retry them up to six times."}'
59```
60
61The answer holds the `issue`, the `pull` request the agent opened (or
62`null`), and `agent`: its `status` (`started`, `queued` or `not_started`),
63and when it did not start, a `code`, a `message` and a `fix_url`. On the MCP
64server it is the `agent` tool's `delegate` action. See
65[put an agent on it](/reference/api/issues/delegate/).
66
67The `checks` field this call and `create_issue` used to take is
68deprecated. It is still accepted: its commands are added to the issue's
69body under `## Definition of done`, one line each (`` - `npm test` passes. ``),
70and the answer carries a `deprecation` string saying so. What has to pass
71before the pull request merges is the default branch's
72[required status checks](/guides/pull-requests/#required-status-checks).
73
74## Assigning agents
75
76One issue:
77
781. Open an issue on a repository.
792. In **Assign to g1t**, optionally add guidance for this run, on top
80 of the issue's description.
813. Choose **Assign**.
82
83Many issues:
84
851. Open the repository's **Issues** tab.
862. Tick the issues to hand over, up to ten at a time.
873. Choose **Assign to g1t**.
88
89From the API, an agent of your own, or a script:
90
91```sh
92curl -X POST https://api.g1t.sh/repos/<workspace>/<repo>/issues/12/assign \
93 -H "Authorization: Bearer $G1T_TOKEN"
94```
95
96The same thing is the `agent` tool's `assign` action on the MCP server, so an agent
97planning work can hand issues to g1t itself.
98
99In a comment: write `@g1t take this` on the issue. See
100[mentioning g1t](#mentioning-g1t).
101
102By label: a project can hand every issue given a label to the agent. See
103[the label rule](#the-label-rule).
104
105Each run appears as a draft pull request on its issue within a few
106seconds. The pages update on their own while g1t works.
107
108An issue can still have more than one pull request: assign it again, or
109have your own agent open one alongside. That is for when you want a second
110attempt, not the normal way of working.
111
112## What an agent does
113
1141. Clones its pull request's fork.
1152. Is told what else is in progress: every other open pull request in the
116 repository, what it is for and which files it changes. Its session
117 starts with a note of what it was told.
1183. Reads the code and makes the change the issue asks for, keeping clear of
119 the other work where it can.
1204. Commits its work.
1215. Pushes to the fork and marks the pull request ready for review, with a
122 summary as its description.
123
124Everything it reads, runs and decides is recorded in the pull request's
125**Session** as it happens; see [sessions and why-blame](/guides/why-blame/).
126The **Files changed** tab shows the resulting diff.
127
128If an agent fails, or finishes without changing anything, its pull request
129is closed and its session says why.
130
131## Repository instructions
132
133Every g1t run reads the repository's own instructions for agents
134and is told them, labelled as the repository's, before it starts: making a
135change, revising it, reviewing, catching up, answering, and planning.
136
137| File | Read by |
138| --- | --- |
139| `AGENTS.md` and `CLAUDE.md` at the root | Every run. |
140| `AGENTS.md` and `CLAUDE.md` in a subdirectory | Runs whose task touches files under it: the nearest one above each file. Where it disagrees with the root's, it wins for the files under it. |
141| `.g1t/review.md` | Reviews: what to check, house rules, paths that need extra care. |
142
143Write them for an agent that knows nothing about the project: how to build
144and test, how things are named, what never to touch. For example:
145
146```md
147# AGENTS.md
148- Run `npm test` and `npm run typecheck` before you finish.
149- API handlers return a Result; they never throw.
150- Never edit files under `vendor/`.
151```
152
153Which directories a task touches comes from the pull request's changed
154files, and for new work from the paths the issue names, so naming the
155files in an issue helps the right instructions reach the agent.
156
157**Where they are read from.** The default branch, as it is when the run
158starts. A pull request from one of the repository's own branches is read at
159its head instead, since only people who can push to the repository can
160change it. A pull request from a fork, which includes every change g1t
161makes, is never followed: the agent keeps the default branch's
162instructions, and if the fork changes them, it is shown the changed text as
163part of the change, marked as not instructions. That way nobody can steer
164an agent, or the review of their own change, by editing these files in a
165pull request. Treat what a fork's head says as untrusted, as you would its
166code.
167
168**Limits.** Each file is cut at 8,000 characters and all of them together
169at 24,000; what is left out is named in the prompt. Files are read once per
170commit and reused.
171
172The project's **Agents** page lists the files its runs read, what they say
173and when each last changed, with a link to each in the code. Each run's
174session starts with a note of which files it read. To change them, change
175the files and merge to the default branch.
176
177## Seeing it through
178
179Making the change is the first step. g1t takes the rest itself, and you
180get the pull request back ready to merge:
181
1821. **Checks.** Every push the agent makes runs the repository's
183 [workflows](/guides/actions/) on the pull request, as for anyone's pull
184 request. g1t waits for them to finish. Only the workflow runs report, so
185 the agent has no say in the result.
1862. **Review.** A different agent reads the change and posts comments on
187 lines, a summary and a verdict.
1883. **Revision.** If a check fails or the review asks for changes, the
189 author is sent back with exactly what was found. For a failed check,
190 that is the end of the log of each failed job, up to three jobs and
191 about 3,000 characters each; it can read more with `get_workflow_run`
192 and `get_job_logs`. Steps 1 and 2 run again on the result. This happens
193 at most twice, or as often as the repository's **Revisions before asking
194 you** allows.
1954. **Ready to merge.** The required checks passed and it is approved.
196 Merging is yours, unless the repository says otherwise (below).
197
198Agents are told to run the same tests and linters the workflows run before
199they finish, so most failures are caught in the sandbox. What "done" means
200for the issue, if its description says so, is context for the agent and
201its reviewer; what decides the merge is the default branch's
202[required status checks](/guides/pull-requests/#required-status-checks).
203A repository with no workflows has nothing to prove a change works; **Add
204CI** gives it one ([add CI](/guides/actions/#add-ci)).
205
206If `main` has moved in the meantime, that does not hold the pull request
207up. Merging it brings it up to date first: g1t merges `main` in, an agent
208resolves any conflict, and it lands. A repository that wants every pull
209request caught up and checked again before it may merge turns on **Require
210pull requests to be up to date before merging** in its settings; catching
211up is then a step of its own, before "ready".
212
213g1t also works out ahead of time whether each pull request still merges
214cleanly, every time it or `main` moves
215([how](/guides/pull-requests/#conflicts)). When one of an agent's pull
216requests is found to conflict, g1t does not wait for a merge to trip over
217it: the agent is sent to merge `main` in and resolve the conflicts, told
218which files conflict, and the checks run again on the result.
219
220The pull request's page shows which step it is at. While a required check
221has not reported on its latest commit, it says so: "Waiting for the
222required check CI to report on its latest commit." If g1t cannot finish,
223because a required check still fails after the agent revised as often as
224the repository allows ("The required check CI still fails after the agent
225revised twice."), a review could not be written, or a conflict could not
226be resolved while bringing it up to date, it stops and the page says
227**Needs you**, with the reason. A check that is not required and still
228fails after the last revision does not hold it. Pushing to the pull
229request yourself starts it moving again.
230
231### What a repository can ask for
232
233Under a project's **Settings → Branches and merging**, someone with the
234Maintain [role](/guides/access-and-roles/) or higher sets the rules its pull
235requests follow. **Branch protection** holds the rules for every pull
236request, a person's or an agent's; they are described in
237[required status checks](/guides/pull-requests/#required-status-checks):
238
239| Setting | Default | What it does |
240| --- | --- | --- |
241| Require a pull request to change the default branch | Off | Refuses pushes to the default branch. |
242| Required status checks | None | The checks that must pass on a pull request's head before it merges. |
243| Required approvals | None | How many reviewers must approve before a merge. A reviewer who asked for changes blocks it. |
244| g1t's approval counts | On | Off means approvals have to come from people. |
245| Require branches to be up to date before merging | Off | On means catching up is a step of its own and the checks run again. |
246| Merge through a queue | Off | Merging tests a pull request together with those ahead of it; the default branch only moves to a combination that passed. See [merge queue](/guides/merge-queue/). |
247| Allow bypassing required checks | On | Lets someone who may merge merge without the required checks passing. Off means nobody can. |
248
249In the **g1t** section, you set what g1t does with its own pull requests:
250
251| Setting | Default | What it does |
252| --- | --- | --- |
253| Review by a second agent | On | Off leaves review to people. |
254| Revisions before asking you | 2 | How often an agent is sent back before g1t stops. |
255| Merge automatically when ready | Off | Lands g1t's pull request once every rule is met. |
256| Ask a person before merging low-confidence changes | On | A change by g1t [rated low](#how-sure-the-agent-is) waits for a person's approval instead of merging by itself or joining the queue. |
257
258A pull request g1t opens follows the same rules as anyone's. If the
259repository wants approvals from people, it waits for them, and shows
260**Needs you** until they arrive.
261
262### Talking to an agent
263
264While g1t works, you can steer it with **Message the agent** on its
265pull request; it reads the message at its next step, without starting
266over. Once it is done, a review with **Request changes** sends it back to
267make them, and the checks and review run again. g1t's runs working at the
268same time can also ask each other questions and hand each other work. See
269[talk to agents](/guides/talking-to-agents/).
270
271### Merging automatically
272
273A repository can land g1t's pull request by itself once it is
274ready. Someone with the Maintain role or higher turns this on under the repository's
275**Settings → Branches and merging**; it is off to begin with. The merge is recorded as made by
276`g1t`, the issue closes naming the pull request, and nothing short of
277ready is ever merged this way: every required check has passed on its
278head. One that is behind `main` is brought up to
279date as part of the merge. Pull requests from people and from other
280agents always wait for a person to merge them.
281
282Every step is recorded: revisions and catch-ups in the pull request's
283**Session**, reviews in its conversation.
284
285This applies to pull requests g1t opens. One you or your own
286agent opened is yours to drive; the same workflows run on it, and you can ask
287for a review or a catch-up from its page.
288
289### How sure the agent is
290
291Once g1t has finished a change, g1t records how sure it is that the
292change is right: **high**, **medium** or **low**, with a few words saying
293why, such as "Low — tests not added, 3 revisions". It shows on the pull
294request, under the agent, and on Mission control. It is worked out again as
295the change moves through checks, review and revision, and kept with each
296run, so a run's page says how the change stood when that run left it.
297
298Confidence comes from what g1t can observe, not from how the agent sounds.
299Each signal below that tells against the change adds points, or makes it
300low on its own. No points is high, one or two is medium, and three or more
301is low.
302
303| Signal | Effect |
304| --- | --- |
305| Required checks fail | Low |
306| It failed in the [merge queue](/guides/merge-queue/) | Low |
307| The reviewer agent asks for changes | Low |
308| A run was stopped at its cost or time cap | Low |
309| Sent back to revise | 1 point per revision, at most 3 |
310| Required checks have not finished, or have not run on its head | 1 point |
311| Checks passed only on a retry | 1 point |
312| The default branch has no required checks | 1 point |
313| No review yet, or the repository has no reviewer agent | 1 point |
314| The reviewer approved but left three or more comments on lines | 1 point |
315| Code changed and no test was added or changed | 1 point |
316| More than 400 lines changed; more than 1,000 | 1 point; 2 points |
317| More than 30 files changed | 1 point |
318| Files changed outside the area its [plan](/guides/outcomes/) expected; four or more | 1 point; 2 points |
319| Touches CI workflows, repository automation, secrets, infrastructure or `CODEOWNERS` | 2 points |
320| Its latest run used 80% or more of its cost or time cap | 1 point each |
321| Steps refused by [guardrails](/guides/guardrails/); three or more | 1 point; 2 points |
322| A question or handoff it sent another agent is unanswered | 2 points |
323| The agent said it was unsure about something | 1 point |
324
325At the end of every run that makes or revises a change, the agent is also
326asked how sure it is, and what it could not verify. g1t takes the lower of
327the two: what it observes can lower the agent's own word, never raise it.
328When the agent's word is lower, the reasons start with "agent says low",
329and the pull request lists what it was unsure about.
330
331For high confidence, the reasons say what it rests on: required checks pass,
332approved on the first review, tests added, a small change.
333
334The pull request's `confidence` in the
335[API](/reference/api/pull-requests/get-pull-request/) has the `level`,
336`reasons`, `self_reported`, `uncertain_about`, the `run_id` it was worked out
337after, and `assessed_at`. [Webhooks](/guides/webhooks/) for pull requests
338carry it too.
339
340### Low-confidence changes wait for a person
341
342With **Ask a person before merging low-confidence changes** on, which it is
343unless someone turns it off, a change by g1t rated low is not merged
344by itself and does not join the merge queue, even with **Merge
345automatically when ready** on. Once everything else the repository asks
346for is met, it stops at **Needs you**, saying why, and Mission control
347lists it under **Needs you** with a **Low confidence** chip, the reasons in
348**What the agent already knows**, and the reasons again in **Why this
349needs you**.
350
351To let it land, approve it: a person's approval since the agent last
352revised lifts the hold, and it merges as the repository's rules say. To
353send it back, request changes. Merging it yourself works as usual. The
354setting is under **Settings → Branches and merging**, in the **g1t** section,
355and is `hold_low_confidence` in
356[`update_repo_settings`](/reference/api/repositories/update-repo-settings/).
357
358## Choosing between pull requests
359
360Each pull request on the issue's page shows whether its checks passed. Open
361the ones that did, read their descriptions and changes, and merge the one
362you want. Merging lands it on `main` and closes the issue, which records
363that pull request as the one that resolved it. The other pull requests for
364the issue close as superseded. See
365[merging](/concepts/overview/#merging) for what happens when `main` has moved.
366
367## Other things g1t does
368
369- **Review.** On a pull request that is ready, **Request review from g1t**
370 has g1t read the change and post comments on lines, a summary and a
371 verdict.
372- **Catch up.** When `main` has moved under a pull request, **Catch up with
373 main** merges it in. When the two changed different files g1t does that
374 itself in seconds, with no agent; otherwise an agent merges it in a
375 sandbox and resolves any conflict
376 ([catching up](/guides/pull-requests/#catching-up)).
377- **Finish a security update.** g1t raises a vulnerable dependency to its
378 fixed version itself, with no agent. When raising the version is not
379 enough (the bump fails, or the pull request's required checks fail
380 because code must change), g1t opens an issue and assigns it to g1t.
381 That session shows as **started by g1t** on the project's **Agents** page.
382 See [security updates](/guides/security/#security-updates).
383
384Each runs in a sandbox of its own.
385
386## Mentioning g1t
387
388Write `@g1t` in a comment on an issue or a pull request, with what
389you want, and it does it. The comment box offers to complete the name as
390you type `@`.
391
392| Where | You write | What happens |
393| --- | --- | --- |
394| An issue | A request: `@g1t take this`, `@g1t fix the empty case` | The issue is assigned to g1t, which opens a pull request, as if you had chosen **Assign**. |
395| An issue | A question: `@g1t why is this slow?` | g1t reads the code on the default branch and answers in the thread. It changes nothing. |
396| A pull request g1t made | A request: `@g1t also handle the empty list` | g1t is sent back to make the change, with your comment as what to address, and the checks and review run again. If it is still working, it gets your comment as a message at its next step. |
397| Any pull request | `@g1t review this` | A review by g1t, as with **Request review from g1t**. |
398| Any pull request | A question | g1t reads the change at its head and answers in the thread. On someone else's pull request, which it cannot push to, a request is answered too: it says what it would change. |
399
400A request is a comment whose words after the mention start with what to
401do (`take`, `fix`, `add`, `please rename`, `can you update`); a question
402starts with a question word or ends with a question mark. `review` near the
403start asks for a review.
404
405g1t always replies in the thread, saying what it started or why it
406did not. Every run a mention starts shows on the project's **Agents** page
407as started by whoever mentioned it, and a mention that started nothing
408shows there as a failed run with the reason.
409
410**What does not count.** Mentions in code (`` `@g1t` `` or a code
411block), in quoted lines (`> @g1t …`), in email addresses
412(`ops@g1t.sh`), in URLs, in package scopes (`@g1t/platform`) and in longer
413names (`@g1t-bot`) are ignored. Matching ignores case. Agents mentioning
414`@g1t` start nothing, so
415agents cannot set each other to work this way.
416
417**Who can.** People with the Write [role](/guides/access-and-roles/) or higher on the
418repository, members or not. Anyone else who mentions it gets a short reply
419saying that putting g1t to work needs the Write role on the
420repository, and nothing starts. When
421the workspace's plan does not let the agent start (a free workspace with no
422trial left, a paused workspace, an issue at its spending cap), g1t
423replies with why and where to fix it. When every agent slot is busy, it
424replies that the run is waiting for a free slot, and starts it when one
425finishes.
426
427Each comment starts one run at most; to ask again, write a new comment.
428
429## The label rule
430
431Under a project's **Settings → Agents**, someone with the Maintain role or
432higher sets a label, such as `agent`. From then on, when someone with the
433Write role or higher gives an open issue that label, either
434when opening it or later, g1t takes it: the issue is queued for
435g1t, the conversation says so, and the agent starts as soon as the
436project has room and nothing the issue depends on is still open, exactly as
437for a [plan's](/guides/outcomes/) issues. An issue that already had the
438label is not affected; removing and adding it again counts. **Turn off**
439removes the rule.
440
441## Which model runs
442
443You do not pick one. You assign the work to `g1t`, the way you would
444assign an issue to a colleague, and g1t routes it. On g1t's hosted models,
445each piece of work goes to the least costly of two tiers that can do it:
446
447| Tier | Model today |
448| --- | --- |
449| Small | Claude Haiku 4.5 |
450| Large | Claude Sonnet 5.5 |
451
452The work decides the tier:
453
454| Work | Tier |
455| --- | --- |
456| Making a change for an issue, revising it, and answering a mention | Large |
457| Reviewing a pull request that changes at most 10 files and 200 lines, touches no sensitive path, and is not for an issue labelled `security` | Small |
458| Reviewing any other pull request, or one whose changed files g1t does not know yet | Large |
459| Catching up with `main` and resolving conflicts | Small |
460| Planning an outcome | Small |
461| Any of these again, after the last attempt at the same work failed or stopped at a guardrail cap | Large |
462
463Sensitive paths are the ones that run, configure or guard things: CI
464workflows, `.g1t/` and `.github/`, `CODEOWNERS`, secrets such as `.env`
465and `.pem` files, and infrastructure such as Dockerfiles, Terraform and
466`wrangler.*` files. They are the same paths that lower a change's
467[confidence](#how-sure-the-agent-is).
468
469The agent's own small background steps run on the small tier.
470
471Every session opens with a note naming the model that ran, and an agent's
472review says which model wrote it, so what you got is always on the record.
473When a better model for a tier appears, g1t changes the route and nothing
474you have set up needs to change.
475
476A workspace that routes its work to [its own provider](/guides/models/)
477is not routed by tier: its work runs on the model its route names.
478
479A pull request g1t opens has `g1t` as its author and as its `agent` in the
480API, and its commits are authored `g1t <g1t@users.noreply.g1t.sh>`.
481
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights482## Who a pull request is for
483
484g1t is the author of every pull request it makes and of every issue it
485files while at work. The person who asked for the work, by assigning the
486issue or handing g1t the task, is kept beside it as **requested by**. Work
487g1t starts itself, such as a [security update](/guides/security/), names
488nobody.
489
490| Where | Author | Who asked |
491| --- | --- | --- |
492| The pull request's page, lists and link previews | **g1t** | **requested by** *name*, or **for** *name* |
493| The API and MCP (`get_pull_request`, `list_pull_requests`, `get_issue`) | `author`: `{ "username": "g1t", "kind": "agent" }` | `requested_by`, or `null` |
494| [Webhooks](/guides/webhooks/) | `data.author` | `data.requested_by`, left out when nobody asked |
495| [Actions](/guides/actions/) (`github.event`) | `pull_request.user`, a `Bot` named `g1t` | `pull_request.requested_by`; `sender` is whoever caused the event |
496| [Search](/guides/search/) | `author:g1t` finds it | shown as **for** *name* |
497
498The person who asked answers for the pull request as its author would:
499
500- they can update, close and mark it ready, catch it up and steer its
501 agent without the Triage role;
502- they are never asked to review it, and they cannot approve it or
503 request changes on it; nor does their approval count toward the
504 repository's required approvals;
505- it is on their own lists: what they are working on, and their profile;
506- the sandboxes that work on it act as them, so it reaches what they can;
507- its workflows and preview get secrets only when they have the Write
508 role or higher, as theirs would.
509
510Being its author gives g1t nothing more: a review by g1t's agent still
511counts where the repository lets an agent's approval count.
512
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent513## How model traffic is routed
514
515g1t's runs send model requests to g1t's model proxy at
516`https://models.g1t.sh`, with a token for their run in place of a key; see
517[your keys never reach a sandbox](/guides/models/#your-keys-never-reach-a-sandbox).
518Requests for g1t's hosted models go on through
519[Cloudflare AI Gateway](https://developers.cloudflare.com/ai-gateway/),
520which holds g1t's key. Each of those requests is tagged with the kind of
521work, the tier, the repository and the pull request, so spend can be read
522per tier and per pull request. Requests for a workspace's own provider go to that provider.
523
524If you run your own copy of g1t, these settings control it:
525
526| Setting | Where | What it does |
527| --- | --- | --- |
528| `AGENT_ROUTING` | Runner | JSON. `tiers`: the model behind `small` and `large`, each `{ "modelName", "model" }`. `tasks`: the tier of `implement`, `review`, `update` and `plan`, or `change` to decide by the change. `smallChange`: the most `files` and `lines` a `change` review runs on the small tier with. `largeLabels`: issue labels that keep a review on the large tier. Anything left out takes the defaults above. |
529| `MODELS_URL` | Runner | Where sandboxes send model requests: the model proxy. |
530| `AI_GATEWAY_ID` | Model proxy | The gateway hosted requests go through. Empty sends them to the provider directly. |
531| `AI_GATEWAY_TOKEN` | Model proxy | Secret. Authenticates to the gateway. |
532| `ANTHROPIC_API_KEY` | Model proxy | Secret. The provider's key, if the gateway does not hold it. |
533
534## What it costs
535
536A workspace pays for g1t's runs on its repositories, after
537they run: each run is charged its sandbox by the second, at cost plus 20%,
538and, on g1t's hosted models, what AI Gateway priced its model requests at,
539plus 20%. A workspace's [own provider](/guides/models/) bills it for the
540model directly. See
541[Usage and billing](/guides/usage-and-billing/) for how prices are set and
542the limits on usage not yet paid for.
543The workspace's **Usage** page shows what its agents have cost, by day,
544kind of work, repository, model and pull request. See
545[usage and billing](/guides/usage-and-billing/).
546
547## What a sandbox has
548
549Git, common shell tools, and toolchains for Node.js, Python, Go and Rust, so
550an agent can build and test most projects. If your project needs something
551else, the agent will say in its summary what it could not run.
552
553A workspace (or a project) can send its agents' work to
554[its own runners](/guides/self-hosted-runners/#agents-on-your-runners)
555instead, so agents build and test with what those machines have. The agent
556works the same way there, with the same short-lived credentials, and its
557model calls still go through g1t; the machine time is free. g1t's network
558guardrails cannot be enforced on your machines, and the run says so.
559
560## Who can run agents
561
562Putting an agent to work (assigning it, mentioning it, asking it for a
563review, planning, sending it back to revise) needs the Write
564[role](/guides/access-and-roles/) or higher on the repository. That
565includes an [outside collaborator](/guides/access-and-roles/#outside-collaborators)
566with Write: their runs are charged to the repository's workspace, as a
567member's are, and count against its plan, caps and agent slots. They see
568what their agents do, but not which model ran or what a run cost; those
569are for members of the workspace. A run for an outside collaborator is
570told the project's memory, never the workspace's.
571
572Agents cost g1t real money, so they run for paid workspaces. A free
573workspace has the whole forge, and two ways to try agents:
574
575- **The trial.** $5 of usage, once per workspace, after a card check.
576- **The open-source pool.** Workflows and the merge queue on public
577 repositories, after the same card check. It does not pay for agents.
578
579This holds whether the agent uses g1t's hosted models or
580[the workspace's own model provider](/guides/models/): the sandbox an agent
581works in is g1t's either way. Before anyone assigns, asks for a review or
582plans, a free workspace's pages say "Agents need a paid workspace or the
583free trial", with a link to its **Billing** page.
584
585Every agent run, of every kind (making a change, revising, reviewing,
586catching up, planning, answering a mention), asks billing before it
587starts. Billing reserves what the run is expected to cost: its model's
588recent average (about $0.10 to make a change or plan, $0.07 to review)
589plus its sandbox for its whole time cap. When the run ends, what it really
590cost is settled against that. If billing refuses, nothing starts, and you
591see why where you started it:
592
593| Where you started it | Where the refusal shows |
594| --- | --- |
595| **Assign to g1t**, **Request review**, **Plan it**, catching up | Under the button |
596| A mention or the label rule | A comment from g1t on the issue or pull request |
597| A step g1t takes by itself (a review, a revision, a catch-up) | The pull request's status, which then waits for you |
598
599Each refusal says what to do: start the plan or the trial, raise the spend
600limit, or wait for next month's open-source pool, with the page to do it
601on.
602
603### Caps on a plan
604
605A workspace's plan sets caps on its agents. A new paid workspace in its
606first month, and a workspace on the trial, has tighter ones. The amounts
607are on [usage and billing](/guides/usage-and-billing/#caps).
608
609| Cap | What happens at it |
610| --- | --- |
611| Agents at once | A run over the cap waits for a free slot instead of being refused. An assigned issue goes back in the queue; a review, catch-up, plan or answer someone asked for waits its turn; a step g1t takes by itself is tried again at its next sweep, within five minutes. Each says "Waiting for a free slot". |
612| Time per run | The lower of the project's [guardrails](/guides/guardrails/) time cap for that kind of run and the plan's. |
613| Cost per run | The lower of the guardrails' cost cap and the plan's. The agent is stopped when it reaches it, as with any cost cap. |
614| Cost per issue | What every agent run on an issue and its pull requests has cost in all. Past it, g1t does not start on that issue again and says so on it; an owner can raise the cap on the **Billing** page. |
615
616When the workspace's compute is paused (a spend spike waiting for an owner,
617or a hold by g1t), nothing new starts, and the refusal gives the reason.
618
619### When billing cannot be reached
620
621g1t's own billing service could be briefly unreachable. Then:
622
623- A paid workspace's runs go ahead, and the miss is logged. A billing blip
624 never stops a paying customer's work.
625- A free workspace's runs do not start: they would be paid for by nobody.
626 Try again in a minute.
627
628g1t decides which a workspace is from its plan, or from the last plan it
629saw for it in the past day.
630
631### Other limits
632
633- A run has two hours. After that its credentials expire and it can no
634 longer push or report.
635- Agents do not run on an [archived](/guides/managing-repositories/#archive-a-repository)
636 or deleted repository: nothing new starts, whether from an assignment,
637 a mention or the label rule, and a run under way cannot push or merge.
638 What was refused does not start by itself when the repository is
639 unarchived or restored; assign the work again.
640
641## Credentials
642
643Every sandbox run gets credentials of its own, made when it starts and
644revoked the moment it stops. They are not your access tokens, and they are
645not listed with them.
646
647Each credential carries a composite identity: the agent, acting on behalf
648of the person who started the work. A run you started by assigning an issue
649is `g1t on behalf of you`, and that is how it appears in the
650[audit log](/guides/audit-log/), on the run's page and in the pull
651request's **Agent** panel.
652
653What it may do is the intersection of two things:
654
655- **The run's scope.** The credential is bound to the run, its repository,
656 and what that kind of run needs. It expires no later than the run's
657 timeout.
658- **What you may do now.** It works only in the repository's workspace,
659 with your [role](/guides/access-and-roles/) on the repository as it is now, and never
660 more than Write: an owner's agent has Write, not Admin. If you leave the
661 workspace or lose your role, every agent working on your behalf there
662 loses it too. It can never change who has access.
663
664A sandbox holds two credentials. One is for g1t's runner, which clones,
665pushes the result and records the session; downstream it acts as you, so
666what it pushes is yours, within the run's scope. The other is for the
667agent's own tools over MCP, and acts as the agent; it cannot be used with
668git at all.
669
670| Kind of run | Git | API and MCP tools |
671| --- | --- | --- |
672| Implement | Reads the repository; pushes to its pull request's fork only | Records the session and marks its own pull request ready; tools to read issues, pull requests, the merge queue, workflow runs and memory, to [search all of g1t](/guides/search/) and the workspace's context hub, open issues, comment, remember, and message other agents |
673| Revise, answer | Reads the repository; pushes to the pull request's fork, or to its branch only when the change is a branch of the repository | Records the session of its own pull request; the same tools as implement |
674| Catch up | Reads the repository; pushes to the pull request's fork or branch only | Records the session of its own pull request |
675| Review | Reads the change and the repository; pushes nothing | Reports its review through its own run |
676| Plan | Reads the repository; pushes nothing | Reports its plan through its own run, for a person to apply; it can create issues in its repository only |
677| Merge check | Reads the change; pushes nothing | None |
678| Merge queue | Reads each queued change; pushes the queue's own branch only | None |
679| Deploy | Reads the commit it builds; pushes nothing | None |
680
681Nothing an agent's credential holds can reach another repository, or a
682workspace's settings, members, access tokens, billing, integrations,
683webhooks, secrets and variables, or workflows' controls. It cannot merge a
684pull request or put more agents to work. It cannot change its repository's
685details or default branch, rename it or its branches, make it public or
686private, archive, transfer, delete, restore or purge it; see
687[managing a repository](/guides/managing-repositories/). A call that would is refused, and
688the refusal is recorded with the rule that refused it:
689
690| Rule | Refused because |
691| --- | --- |
692| `never` | No agent's credential may ever do this. |
693| `scope:operation` | The run's kind does not include this operation. |
694| `scope:repository` | It names a repository other than the run's. |
695| `scope:pull` | The runner tried to change a pull request other than its own. |
696| `on-behalf-of:membership` | The person the agent works for is no longer a member of the workspace, and has no role on its repositories. |
697| `git:read`, `git:push`, `git:ref` | The run has no grant to clone that repository, push to it, or move that branch or tag. |
698| `git:not-a-run` | An agent's tools credential was used with git. |
699
700Personal and workspace access tokens are unchanged by any of this.
701
702## What a sandbox can reach
703
704A sandbox holds one fork and its run's credentials, which expire when the
705run's time is up and are revoked as soon as it stops. Those credentials,
706and the model key the agent runs on, are removed from anything recorded in
707the session.
708
709## Guardrails
710
711A workspace decides what its agents may do in their sandboxes, and each
712project can override it: which hosts a sandbox can reach (g1t, the package
713registries the project needs, and domains you list; enforced outside the
714sandbox), which commands the harness refuses (force-pushing, rewriting the
715default branch, reading outside the project, printing the environment,
716sudo, and your own patterns), and how much one run may cost and how long it
717may take. A run that is refused something shows it as a step; one that
718reaches a cap is stopped and its pull request waits for you. A run on a
719fork's head loads none of the fork's `CLAUDE.md`, `.claude` settings,
720hooks, MCP servers or commands. See [guardrails](/guides/guardrails/) for
721every rule and exactly how each is enforced.