This is related to my recent thread, https://list.orgmode.org/87wmi9etku.fsf@gmail.com/T/#m93bd964243638ee358d4375c9ed4f40e066238d4 which addresses problems with prompt filtering of R and python async evaluation in Org 9.7. Here, I address the non-async case. First, I introduce options to `org-babel-comint-with-output' to skip the cleanup of prompts and dangling text. This allows individual Babel languages to handle these tasks in a more robust, language-specific manner, e.g. by sourcing temp files or relying on functionality from external libraries like python.el or ESS. In particular, as I discussed in the link above, it is very difficult to do the prompt cleanup in a way that is robust to false positives. ob-shell accomplishes this by changing the prompt to a unique string, but this is not an option for other languages, and has its own drawbacks (e.g. with conda). ob-python takes a different approach, and evaluates code in a way that avoids leaking prompts, thereby skipping the need to clean them up. Previously, ob-python had eschewed using `org-babel-comint-with-output', and re-implemented its own version without the cleanup steps. With this patch, ob-python can go back to using `org-babel-comint-with-output', thereby reducing code duplication. Finally, I add a new implementation for R non-async output, that follows the ob-python approach of avoiding prompt leakage altogether, thereby skipping the need for a cleanup step. I add a unit test to demonstrate the improved robustness of this approach: previously, this test would fail due to a false positive prompt, but it passes with the new implementation.