DSPy: The framework for programming—not prompting—language models
Python
fix(RLM): no longer get stuck on imports (#9234)
Isaac Miller6f8e8e9ceca5
diff --git a/dspy/primitives/python_interpreter.py b/dspy/primitives/python_interpreter.pyindex 12f1d6169..a49c99f69 100644--- a/dspy/primitives/python_interpreter.py+++ b/dspy/primitives/python_interpreter.py@@ -477,13 +477,18 @@ class PythonInterpreter:err_output = self.deno_process.stderr.read()raise CodeInterpreterError(f"No output from Deno subprocess. Stderr: {err_output}")+ # Skip non-JSON lines (e.g., Pyodide package loading messages)+ if not output_line.startswith("{"):+ logger.debug(f"Skipping non-JSON output: {output_line}")+ continue+# Parse that line as JSONtry:msg = json.loads(output_line)except json.JSONDecodeError:- # If not valid JSON, just return raw text- self._sync_files()- return output_line+ # Malformed JSON starting with '{' - log and continue+ logger.info(f"Skipping malformed JSON: {output_line[:100]}")+ continue# Handle incoming requests (tool calls from sandbox)if "method" in msg: