Skip to content

feat: add tab-completion for magic commands using readline and added working groq model#1746

Open
DevaRajan8 wants to merge 3 commits intoopeninterpreter:mainfrom
DevaRajan8:main
Open

feat: add tab-completion for magic commands using readline and added working groq model#1746
DevaRajan8 wants to merge 3 commits intoopeninterpreter:mainfrom
DevaRajan8:main

Conversation

@DevaRajan8
Copy link
Copy Markdown

Fixes #1697

Problem

Open Interpreter has 12+ magic commands (%help, %reset, %verbose,
etc.) but users must remember exact spellings with no discoverability.
Although readline was already imported for up-arrow history,
tab-completion was never wired up for magic commands.

Solution

Added a MagicCommandCompleter class and registered it with readline:

  • Typing % + Tab shows all available magic commands
  • Typing %re + Tab completes to %reset
  • Non-% input is unaffected (no completion)
  • Up-arrow history is unaffected
  • Completer is re-registered before each input call to prevent
    other libraries (e.g. litellm) from resetting it

Changes

Only one file changed: interpreter/terminal_interface/terminal_interface.py

  1. Added MagicCommandCompleter class at the top of the file
  2. Registered the completer in the existing readline try block
  3. Re-registered completer before each input() call to ensure
    it is never overridden by imported dependencies

Code Added

class MagicCommandCompleter:
    """Readline completer for Open Interpreter magic commands."""
    
    MAGIC_COMMANDS = [
        "%help", "%verbose", "%auto_run", "%reset",
        "%save_message", "%load_message", "%undo",
        "%tokens", "%info", "%jupyter", "%markdown", "%%",
    ]
    
    def __init__(self):
        self.matches = []
    
    def __call__(self, text, state):
        if state == 0:
            if text.startswith("%"):
                self.matches = [cmd for cmd in self.MAGIC_COMMANDS 
                                if cmd.startswith(text)]
            else:
                self.matches = []
        return self.matches[state] if state < len(self.matches) else None

Demo

Screenshot From 2026-05-01 13-49-19

Testing

Tested on Python 3.13.3, Ubuntu Linux, open-interpreter 0.4.3:

  • % + Tab → shows all 12 magic commands
  • %re + Tab → completes to %reset
  • %sa + Tab → completes to %save_message
  • %info entered directly → works as before
  • Up-arrow history → unaffected
  • Normal (non-%) input → no completion triggered
  • Windows (no readline) → falls back gracefully

Groq Model Update:

  • Changed to a Working Groq Model (LLama 3.1 to LLama 3.3 versatile 70b model)

now uses llama-3.3-70b-versatile
Model loads without decommission errors
Basic functionality verified

@endolith
Copy link
Copy Markdown
Contributor

endolith commented May 1, 2026

Probably should split this into two PRs since readline and groq are completely unrelated issues

@DevaRajan8
Copy link
Copy Markdown
Author

Probably should split this into two PRs since readline and groq are completely unrelated issues

ok , will do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: tab-completion for magic commands

2 participants