Skip to main content
Given a repository and a task, Sensei clones the repository into a sandbox, runs the tests to see what already fails, makes the change, runs the tests again and opens a pull request. A task that is a question is answered and nothing is changed.

Connect the repository

Open Runs, click Connections and add the repository, or use the terminal:
The token needs to be able to push and open pull requests. It is stored encrypted and shown afterwards only as its last four characters.
Connections on the Runs page: a connected repository with the last four characters of its token, tools, settings and secrets, and Slack
You can write the repository as an https URL, as git@host:org/repo, or as org/repo for GitHub. GitHub and GitLab repositories get pull requests. Working on an existing pull request is for GitHub repositories for now.

Start the run

In a checkout, the repository defaults to the checkout’s origin and the branch to the one you are on:
From anywhere else, name both:
To hand Sensei a failure you can reproduce, let the command run it and attach the output:

How Sensei sets up

Sensei picks an image, setup commands, a test command and the services the tests need from the repository, and reports the basis for each choice in the run’s timeline.
The start of a run's timeline: the commit cloned, the environment chosen, the services started from the CI workflow, and the tests before any change
Override the test command with --test-command. In a definition, check sets the test command and image sets the image. A sensei.yaml file at the root of the repository sets any of these for every run on it, and is used before what Sensei works out. Values and tokens the tests or the setup need are given to the project as settings and secrets. See Services, settings and secrets.
The Environment card on a run's page: the image, language, test and setup commands, where they were read from, the services and the settings

How a change is verified

The tests run before any change, so Sensei knows what already fails. After the change they run again, on the test files as they were at the start.
The Verification card on a run's page: tests passed before and after the change, and the lint check from CI
A run whose tests cannot pass because the project was not given a value they need ends Failed before any model call and names the value. See When a run is missing a value. If the change edits test files, Sensei restores them to the starting commit before the check and says so on the run. The result is against your original tests. A run whose task is about the tests is told it may edit them, and the same restore applies.

Lint and format checks

When a CI workflow runs a lint or format check, the run does too: once before any change and once on the finished change, test files included. Each check is listed under the verdict with what it printed when it does not pass. A command that rewrites code, such as ruff check --fix or prettier --write, is never run as a check. Type checkers are not run.

More than one attempt

--attempts 3 runs up to five independent attempts from the same starting point and keeps the best: a verified change first, then an unverified one, then a failed one.

How the change is delivered

By default Sensei pushes a branch named sensei/<run id> and opens a pull request. The pull request body has the task, what changed, the verification verdict and the diff summary.
The Change card on a run's page: the files changed, with buttons to copy or download the patch and to read the diff
To apply a run’s change locally:

Fix an open pull request

Sensei reads the review comments and the failing checks, adds one commit to the pull request’s branch and says what it did in a comment. It never force pushes. You can add a task after the number to say what to do. The repository must be connected with a token. Pull requests from forks are refused, because Sensei cannot push to a fork’s branch. Review comments and check output are other people’s text. Sensei reads them as review of the code and does not take instructions from them.

Several changes at once

To hand off several changes to the same repository, start them as one batch. Each is worked alone from the same commit, and the verified changes are tested together before the pull requests open. See Several changes at once.

Ask a question

A task that asks about the repository gets an answer and no change:
The run ends Done, and the answer is the result.

A saved agent on a repository

A definition can name its repository, so the team runs the same work by name:
sensei check and sensei push say which repository the definition names and whether it is connected. A definition that names none starts on an empty computer, or on the repository you pass with --repo when you run it. An agent that works on a repository cannot also list tools or use a browser. Do that part in a step before it and pass what it finds as input. See Steps.