-
Couldn't load subscription status.
- Fork 5.2k
Description
Describe the bug
Description
When running R code in Open Interpreter that defines and calls functions, the function's return value is often captured as NULL instead of the actual computed value. Simple print statements and direct assignments work fine, but function calls often fail to capture return values properly.
What Works
- Simple prints:
print("Hello, world!")✓ - Direct calculations:
normalized_x <- (x - min(x)) / (max(x) - min(x))✓
What Fails
- Function return values show as
NULLwhen using implicit returns
Technical Details
The preprocessing in interpreter/core/computer/terminal/languages/r.py wraps all code in tryCatch() blocks (line 32-38), which suppresses function return values. The tryCatch wrapper is intended for error handling but ends up suppressing normal R function returns.
Suggested Fix
Modify the tryCatch() wrapper in r.py to preserve and display return values or use a different error handling approach that doesn't suppress returns.
Reproduce
Steps to Reproduce
- Start an Open Interpreter session
- Ask the AI to create a normalization function in R, for example:
normalize <- function(x) {
(x - min(x)) / (max(x) - min(x))
}
result <- normalize(c(1, 2, 3, 4, 5))
print(result)- Observe output shows
NULLinstead of expected normalized values
Expected behavior
Expected Behavior
Function return values should be captured and displayed correctly, regardless of whether they use implicit or explicit returns.
Actual Behavior
Function return values are captured as NULL when using implicit returns (which is the normal R convention - the value of the last evaluated expression).
Screenshots
No response
Open Interpreter version
0.4.3 (develop branch)
Python version
3.10.13
Operating System name and version
Windows 10
Additional context
No response