diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py
index 1f999877b4a..6e252224ed0 100644
--- a/lib/galaxy/tools/actions/__init__.py
+++ b/lib/galaxy/tools/actions/__init__.py
@@ -975,6 +975,13 @@ def determine_output_format(output, parameter_context, input_datasets, input_dat
# the type should match the input
ext = output.format
if ext == "input":
+ if input_datasets and random_input_ext in {'data', 'auto'}:
+ # Probably dealing with an implicitly converted dataset
+ try:
+ first_input_dataset = next(iter(input_datasets.values()))
+ random_input_ext = get_ext_or_implicit_ext(first_input_dataset)
+ except Exception:
+ pass
ext = random_input_ext
format_source = output.format_source
if format_source is not None and format_source in input_datasets:
diff --git a/test/functional/tools/implicit_conversion_format_input.xml b/test/functional/tools/implicit_conversion_format_input.xml
new file mode 100644
index 00000000000..e93f5409559
--- /dev/null
+++ b/test/functional/tools/implicit_conversion_format_input.xml
@@ -0,0 +1,22 @@
+
+
+ cut -f 1 '$input1' > '$output1'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml
index 2c220b12a2e..ae5ae08fa4c 100644
--- a/test/functional/tools/samples_tool_conf.xml
+++ b/test/functional/tools/samples_tool_conf.xml
@@ -133,6 +133,7 @@
+