Fix auto_run not supporting callable values#1700
Open
Br1an67 wants to merge 1 commit intoopeninterpreter:mainfrom
Open
Fix auto_run not supporting callable values#1700Br1an67 wants to merge 1 commit intoopeninterpreter:mainfrom
Br1an67 wants to merge 1 commit intoopeninterpreter:mainfrom
Conversation
When auto_run is set to a callable (e.g. a function that inspects the code before deciding whether to run it), the previous logic failed: - In core.py, `self.auto_run == False` never matched a callable (truthy), so the confirmation chunk was never yielded to the terminal interface. - In terminal_interface.py, `not interpreter.auto_run` treated the callable as truthy, skipping the user confirmation prompt entirely. Now: - core.py yields the confirmation chunk when auto_run is False OR callable. - terminal_interface.py calls the callable with the code content to determine whether to auto-run, falling back to the original bool check otherwise. Fixes openinterpreter#1696
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the changes you have made:
When
auto_runis set to a callable (as described in #1696), the interpreter fails to work correctly:core.py:self.auto_run == Falsenever matches a callable (which is truthy), so the confirmation chunk is never yielded to the terminal interface — the user never gets a chance to approve/reject.terminal_interface.py:not interpreter.auto_runtreats the callable as truthy, so the confirmation prompt is skipped entirely and all code runs without approval.Fix:
core.py: Yield the confirmation chunk whenauto_runisFalseorcallable— both cases need the terminal interface to handle the confirmation flow.terminal_interface.py: Whenauto_runis callable, call it with the code content to determine whether to auto-run. Otherwise fall back to the original boolean check.Reference any relevant issues (e.g. "Fixes #000"):
Fixes #1696
Pre-Submission Checklist (optional but appreciated):
docs/CONTRIBUTING.mddocs/ROADMAP.mdOS Tests (optional but appreciated):