# Fix a failing test with Codex

Sign in to Codex in a VM, clone your repository, ask for a fix to a failing test, and review the diff.

Source: https://slashinfra.com/docs/agents/codex
Last modified: 2026-11-30T16:36:19.000Z

Your VM runs a signed-in Codex that fixes a failing test in your repository. The diff of that fix appears in your terminal.

## Before you start

- An account on the [dashboard](https://app.slashinfra.com/). New accounts need approval first; the dashboard shows your status. 
- A Codex account that allows device sign-in. The [Codex authentication guide](https://developers.openai.com/codex/auth/) covers the other options. Model usage follows your provider’s terms and billing. 
- A repository with a failing test that you can clone. A public repository needs nothing else. For a private one, follow [Open pull requests](https://slashinfra.com/docs/agents/pull-requests) first. 
- `si` for the CLI tab. Install it as shown in [From your terminal](https://slashinfra.com/docs/start/cli).

## 1. Create a VM with Codex

Every VM has Codex installed, so you install nothing.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms). 
- Select Create SVM. 
- Enter a name, such as `codex-example`, and keep the other fields. 
- Select Create SVM. 
- Select Open terminal on the new row.

### CLI

```bash
VM=codex-example
si create --name "$VM"
```

## 2. Sign in to Codex

### Dashboard

- In the terminal, run:

```bash
codex login --device-auth
``` 
- Open the link it prints in your browser and enter the one-time code. 
- Run the command below to confirm the sign-in.

```bash
codex login status
``` 
- Run:

```bash
exit
```

### CLI

```bash
si shell "$VM"
```

In the shell, run `codex login --device-auth` and enter the code in your browser. Run `codex login status`, then `exit`.

Your SlashInfra sign-in does not sign Codex in. Codex keeps its own login inside the VM.

## 3. Clone your repository

### Dashboard

- In the terminal, run:

```bash
git clone https://github.com/your-org/your-repo.git /home/user/app
```

### CLI

```bash
si exec "$VM" -- git clone https://github.com/your-org/your-repo.git /home/user/app
```

Use an HTTPS URL. Git over SSH does not receive the GitHub credential.

## 4. Ask for the fix

### Dashboard

- Open [Companion](https://app.slashinfra.com/companion). 
- Choose Codex as the agent. 
- Choose your VM in the SVM menu. 
- Choose Other folder, and enter `~/app`. 
- Enter `Run the tests, fix the failing test and explain the change.` in Task. 
- Select Start agent. The agent may ask for approval while it works. Answer in Companion.

### CLI

```bash
si agent run "$VM" --agent codex --cwd /home/user/app -- 'Run the tests, fix the failing test and explain the change.'
```

The agent runs with full access inside the VM: it edits files and runs commands without asking. The output streams to your terminal, and the command ends with the agent’s exit code. If it reports an error, follow its message.

## 5. Review the diff

### Dashboard

- In the terminal, run:

```bash
cd /home/user/app && git diff
```

Output

```text
diff --git a/<path> b/<path>
...
```

### CLI

```bash
si exec "$VM" -- git -C /home/user/app diff
```

Output

```text
diff --git a/<path> b/<path>
...
```

The diff should change the code under test and leave the test file as it was.

## Check it works

You should now see the diff of the fix in your terminal. Run your project’s test command in the terminal. The test that failed passes.

## If it doesn’t work

| Symptom | Cause | Fix |
| --- | --- | --- |   
| `Repository not found` on clone | The repository is private and not connected, or the URL uses SSH. | Use an `https://github.com/` URL. For a private repository, follow [Open pull requests](https://slashinfra.com/docs/agents/pull-requests). | 
| `codex login --device-auth` fails | Your account does not allow device sign-in. | Allow device sign-in for your account, or use another method in the [Codex authentication guide](https://developers.openai.com/codex/auth/). | 
| The test still fails | The agent stopped early or changed another file. | Read the output, then ask again with the error text. |

## Clean up

> Caution
> 
> 
> 
> Deletes the VM and its files. Download the files you want to keep first. Deletion cannot be undone.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms). 
- Select Delete on the row of the VM.

### CLI

```bash
si rm "$VM"
```

## Next

- [Open pull requests](https://slashinfra.com/docs/agents/pull-requests): push the fix from the VM and open a pull request. 
- [One VM per task](https://slashinfra.com/docs/agents/many-tasks): run each task in its own VM, on its own branch. 
- [Agent sessions](https://slashinfra.com/docs/platform/agent-sessions): list, resume and delete the sessions this guide starts.
