How Multi_Line Mode Affects Code Input and Execution in Open Interpreter

Multi_Line mode in Open Interpreter enables users to input multi-line text blocks using triple-quote delimiters ("""), but does not alter how the interpreter parses or executes code generated by the LLM.

Open Interpreter is an open-source tool that allows language models to execute code on your local machine. Understanding how the multi_line mode configuration affects user input handling is essential for effectively interacting with the REPL interface, especially when pasting large code blocks or detailed prompts.

What Is Multi_Line Mode in Open Interpreter?

Multi_Line mode controls whether the terminal interface accepts single-line or multi-line user input. When enabled (the default), users can wrap text in triple quotes (""") to submit blocks containing newlines, markdown formatting, or code fences. When disabled, the interface uses standard single-line input(), requiring users to press Enter after each line.

How Multi_Line Mode Is Configured

The configuration flows through several key files in the Open Interpreter repository.

Core Attribute Definition

In interpreter/core/core.py (lines 80-82), the OpenInterpreter class initializes the multi_line attribute:


# From interpreter/core/core.py

self.multi_line = True  # Default enables multiline input

This attribute is exposed to the command-line interface via the --ml or -ml flag.

CLI Interface Registration

The interpreter/terminal_interface/start_terminal_interface.py (lines 43-46) registers the CLI option and displays help text explaining the triple-quote syntax for multi-line input blocks.

Runtime Input Selection

In interpreter/terminal_interface/terminal_interface.py (lines 96-100), the REPL loop checks interpreter.multi_line to determine which input function to use:


# Conceptual logic from terminal_interface.py

if interpreter.multi_line:
    user_input = cli_input()  # Custom multiline handler

else:
    user_input = input()      # Standard single line

How Multi_Line Mode Changes User Input

When multi_line mode is active, the cli_input() function in interpreter/terminal_interface/utils/cli_input.py (lines 2-13) handles the actual input collection:


# From interpreter/terminal_interface/utils/cli_input.py

def cli_input():
    # Looks for opening """

    # Collects lines until closing """

    # Returns complete string with newlines preserved

This implementation allows users to paste entire Python functions, bash scripts, or markdown-formatted prompts without escaping newlines or sending multiple messages.

Impact on Code Execution

Multi_Line mode does not alter code execution. The interpreter processes user messages through the same pipeline regardless of how the input was collected:

  1. The message is stored in the conversation history
  2. The LLM generates a response containing markdown code blocks
  3. Code blocks are extracted and passed to language-specific preprocessors
  4. Execution occurs via SubprocessLanguage implementations

The mode only expands the input surface, allowing complex user prompts. All safety checks, active-line markers, and execution markers remain identical to single-line mode.

Practical Examples

Using Multi_Line Mode in the REPL

Start Open Interpreter (multiline is enabled by default):

interpreter

Enter a multi-line block:


> """
> Please analyze this Python function:
> ```python
> def factorial(n):
>     if n <= 1:
>         return 1
>     return n * factorial(n-1)
> ```

> Explain the recursion and potential stack overflow risks.
> """

The interpreter receives the complete formatted block, preserving code fences and newlines.

Disabling Multi_Line Mode

Force single-line input via CLI flag:

interpreter --ml false

Now pressing Enter immediately submits the message. To include newlines, you must explicitly use \n or send multiple separate messages.

Programmatic Configuration

from interpreter import interpreter

# Enable multiline for API usage

interpreter.multi_line = True

complex_prompt = """\
Write a bash script that:
1. Lists all .log files
2. Archives them with tar
3. Removes originals
"""

interpreter.chat(complex_prompt)

Summary

Frequently Asked Questions

How do I enable multi-line input in Open Interpreter?

Multi-line input is enabled by default when you start Open Interpreter. You can explicitly enable it by starting the interpreter without the --ml false flag, or programmatically by setting interpreter.multi_line = True before calling interpreter.chat().

What delimiter should I use for multi-line input?

When multi-line mode is active, wrap your input with triple double-quotes ("""). The cli_input() function in interpreter/terminal_interface/utils/cli_input.py detects these markers and collects all text between them, preserving newlines and formatting.

Does multi-line mode change how code is executed?

No. Multi-line mode only affects how user input is collected in the terminal interface. Once submitted, messages are processed through the standard pipeline: stored in conversation history, sent to the LLM, and any generated code is extracted and executed via SubprocessLanguage implementations exactly as in single-line mode.

Can I disable multi-line mode when using the CLI?

Yes. Pass the --ml false or -ml false flag when starting Open Interpreter from the command line. This forces the terminal interface to use standard input() instead of cli_input(), requiring you to press Enter to submit each line individually.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →