# Take control from an agent

Pause an AI agent, hand control back, end its session, or undo what it changed.

## Take control

One agent session drives a machine at a time.

Choose **Machine > Take Control**, or click, scroll, or type in the machine's window. The agent's typing stops, and its pressed keys are released. Your first click doesn't reach the machine.

To give control back, choose **Machine > Resume Agent**. To end the session, choose **Machine > End Agent Session**. After that, every agent needs your answer again before it uses the machine.

The same actions are in the machine's window, the machine's **Overview**, and the [menu bar](https://osmates.com/docs/app#use-the-menu-bar) menu. The library toolbar has **Take Control** and **Resume Agent**.

To take control, give it back, and end the session in Terminal:

```sh
osmates vm control dev --pause
osmates vm control dev --resume
osmates vm control dev --end
```

While an agent drives, its pointer shows in the machine's window with its name. Its screenshots don't include the pointer.

## Undo an agent's changes

An agent's first change takes a snapshot of the machine's disks, marked Agent. Undoing returns the disks to that snapshot and ends the session. The machine keeps the newest 3 of these snapshots, as [Schedule automatic snapshots](https://osmates.com/docs/snapshots#schedule-automatic-snapshots) lists.

To undo the session, which also loses your own changes since it began:

1. Choose **Machine > Undo Agent Session**, or click it in **Overview**.
2. Click **Undo Session**.

To undo it in Terminal:

```sh
osmates vm undo-session dev
```

Undoing works as a [revert](https://osmates.com/docs/snapshots#take-and-revert-snapshots) does, and a running machine starts again. Shared folders, copies on your Mac, and data sent over the network stay as they are.

If another session's snapshot becomes the latest while you confirm, nothing changes, and a new confirmation names that snapshot. In Terminal, run the command again.

## If an agent can't take control

An agent can't drive a macOS machine or Linux desktop that hears your microphone. Turn off the microphone in the machine's settings, then restart the machine. See [Hear and record sound](https://osmates.com/docs/settings#hear-and-record-sound).
