# How to Reset Interpreter State Between Conversations in Open Interpreter

> Learn how to reset interpreter state in Open Interpreter by calling interpreter.reset() or using %reset in the REPL. Start fresh sessions easily.

- Repository: [Open Interpreter/open-interpreter](https://github.com/openinterpreter/open-interpreter)
- Tags: how-to-guide
- Published: 2026-03-05

---

**Call `interpreter.reset()` programmatically or type `%reset` in the REPL to clear chat history, terminate running runtimes, and unload the Computer API for a fresh session.**

Open Interpreter maintains a persistent state across interactions, including the full conversation history, generated code snippets, and the **Computer API** sandbox. When you need to isolate conversations or eliminate context from previous turns, you must explicitly reset this state. The library provides two official mechanisms to reset interpreter state between conversations—one for scripts and one for interactive sessions.

## Why Persistent State Requires Explicit Clearing

By default, Open Interpreter keeps the entire dialogue in `self.messages`, passing the complete history to the model with every new request. While this enables powerful multi-turn interactions, it also means previous code executions, imported modules, and conversation context bleed into subsequent queries unless cleared.

The **Computer API** (the sandbox that executes generated code) also accumulates state. Language runtimes remain active, and the `_has_imported_computer_api` flag tracks whether the API has been loaded into the environment. Without a proper reset, these artifacts can cause cross-talk between unrelated sessions or introduce hidden dependencies that affect code execution.

## How to Reset Interpreter State Between Conversations

### Programmatic Reset Using `interpreter.reset()`

For Python scripts and applications embedding Open Interpreter, invoke the `reset()` method on your instance. This method, implemented in [`interpreter/core/core.py`](https://github.com/openinterpreter/open-interpreter/blob/main/interpreter/core/core.py) around line 430, performs four critical cleanup operations:

- Terminates any running language runtimes via `self.computer.terminate()`
- Clears the Computer API import flag by setting `self.computer._has_imported_computer_api = False`
- Empties the conversation history with `self.messages = []`
- Resets the internal message counter (`self.last_messages_count = 0`)

```python
from interpreter import Interpreter

interpreter = Interpreter()

# First conversation

interpreter.chat("Calculate 15 * 23")
interpreter.chat("Now write that as a Python function")

# Reset to start fresh

interpreter.reset()

# Second conversation starts with no prior context

interpreter.chat("What is the capital of France?")  # Treated as brand new session

```

After calling `reset()`, the interpreter behaves as if freshly instantiated, with no prior context influencing the next request.

### Interactive Reset Using the `%reset` Magic Command

When using Open Interpreter in a REPL or Jupyter notebook, use the `%reset` magic command. This command, defined in [`interpreter/terminal_interface/magic_commands.py`](https://github.com/openinterpreter/open-interpreter/blob/main/interpreter/terminal_interface/magic_commands.py) (lines 41-44), internally calls the same `reset()` method but provides visual confirmation in the terminal.

```text
>>> %reset
> Reset Done

```

In a Jupyter notebook, you can load the extension and reset within a cell:

```python
%load_ext interpreter
%reset  # Clears history and computer state immediately

```

Both approaches achieve identical results—the magic command simply wraps the programmatic API for convenience in interactive environments.

## Verifying the Reset in Automated Tests

The test suite confirms that `reset()` properly clears state. In [`tests/test_interpreter.py`](https://github.com/openinterpreter/open-interpreter/blob/main/tests/test_interpreter.py) (lines 95-99), the `test_reset` function validates that the message list is empty after invocation:

```python
def test_reset():
    # make sure that interpreter.reset() clears out the messages Array

    interpreter.reset()
    assert interpreter.messages == []

```

You can implement similar assertions in your own validation logic to ensure deterministic behavior between conversation batches.

## Summary

- **Persistent state** includes chat history (`self.messages`), Computer API imports, and active language runtimes.
- **Programmatic method**: Call `interpreter.reset()` in Python code to clear all state according to the implementation in [`interpreter/core/core.py`](https://github.com/openinterpreter/open-interpreter/blob/main/interpreter/core/core.py).
- **Interactive method**: Type `%reset` in the REPL or Jupyter notebooks, handled by [`interpreter/terminal_interface/magic_commands.py`](https://github.com/openinterpreter/open-interpreter/blob/main/interpreter/terminal_interface/magic_commands.py).
- **Validation**: After resetting, `interpreter.messages` returns an empty list, confirming a clean slate.

## Frequently Asked Questions

### What exactly does `interpreter.reset()` clear?

The method clears the conversation message history, terminates active language runtimes in the Computer API sandbox, and resets the flag indicating whether the Computer API has been imported. It effectively returns the interpreter to its post-instantiation state without requiring you to create a new object.

### Can I reset the interpreter in a Jupyter notebook?

Yes. Load the interpreter extension with `%load_ext interpreter`, then execute `%reset` in any cell. This invokes the same underlying `reset()` method and clears all conversation context and computer state immediately.

### Is there a CLI flag to reset on startup?

No dedicated `--reset` flag exists for conversation state. The `--reset_profile` flag mentioned in [`interpreter/terminal_interface/profiles/profiles.py`](https://github.com/openinterpreter/open-interpreter/blob/main/interpreter/terminal_interface/profiles/profiles.py) resets configuration profiles, not conversation history. To start fresh, either instantiate a new `Interpreter` object or explicitly call `interpreter.reset()` after initialization.

### How do I know if the reset succeeded?

Check the `messages` attribute: `assert interpreter.messages == []` should return `True`. Additionally, subsequent `chat()` calls will not reference previous conversation topics, and the Computer API will re-import fresh on the next code execution rather than using cached imports.