Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ private ToolResult executeStep(
ToolResult r = callEndpoint(step, inputFiles, supportingFiles);
files.addAll(r.files());
report = r.report();
} else if (inputFiles.isEmpty()) {
ToolResult r = callEndpoint(step, List.of(), supportingFiles);
files.addAll(r.files());
report = r.report();
} else {
for (Resource file : inputFiles) {
ToolResult r = callEndpoint(step, List.of(file), supportingFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -149,6 +150,40 @@ void singleInputEndpointIsCalledOncePerFile() throws IOException {
verify(internalApiClient, times(2)).post(eq(ROTATE), any());
}

@Test
void noInputGeneratorEndpointIsCalledOnceWithNoFile() throws IOException {
// A "create" workflow has no source documents: a generator tool (e.g.
// create-pdf-from-html-agent) produces its output purely from parameters. Per-file
// dispatch would skip it entirely (zero files = zero calls), so it must still run once.
String createPdf = "/api/v1/ai/tools/create-pdf-from-html-agent";
when(toolMetadataService.isMultiInput(createPdf)).thenReturn(false);
when(toolMetadataService.shouldUnpackZipResponse(createPdf)).thenReturn(false);
stubEndpoint(createPdf, pdf("generated", "purchase-order.pdf"));

PolicyExecutionResult result =
executor.execute(
definition(
new PipelineStep(
createPdf,
Map.of(
"htmlContent",
"<p>hi</p>",
"filename",
"purchase-order.pdf"))),
PolicyInputs.of(List.of()),
PolicyProgressListener.NOOP);

assertEquals(1, result.files().size());
assertEquals("purchase-order.pdf", result.files().get(0).getFilename());

@SuppressWarnings("unchecked")
ArgumentCaptor<MultiValueMap<String, Object>> bodyCaptor =
ArgumentCaptor.forClass(MultiValueMap.class);
verify(internalApiClient, times(1)).post(eq(createPdf), bodyCaptor.capture());
// No document stream: the body carries only the generator's parameters, no fileInput.
assertNull(bodyCaptor.getValue().get("fileInput"));
}

@Test
void zipResponseIsUnpackedIntoIndividualFiles() throws IOException {
when(toolMetadataService.isMultiInput(SPLIT)).thenReturn(false);
Expand Down
Loading