Skip to content

Commit 21d2e92

Browse files
committed
feat(quarkus): use .agent-run suffix for child workflow names
Child AgentRunWorkflows now use agent-specific names with .agent-run suffix (e.g., dapr.langchain4j.WeatherAssistant.agent-run) instead of the generic "agent" name. This avoids conflicts with orchestration workflow names (.workflow suffix) while keeping descriptive names visible in the Dapr dashboard. Signed-off-by: Javier Aliaga <javier@diagrid.io>
1 parent 70b999a commit 21d2e92

6 files changed

Lines changed: 52 additions & 9 deletions

File tree

quarkus/deployment/src/main/java/io/dapr/quarkus/langchain4j/deployment/DaprAgenticProcessor.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,32 @@ void setupWorkflowRuntime(DaprWorkflowRuntimeRecorder recorder,
287287
recorder.registerAgentName(interfaceName, agentName);
288288
}
289289

290+
// Register AgentRunWorkflow under *.agent-run names for ALL agents
291+
// (both standalone and composite). Used by orchestration workflows for
292+
// child workflows — avoids conflicts with orchestration *.workflow names.
293+
for (Map.Entry<DotName, String> entry : AGENT_ANNOTATION_TO_WORKFLOW.entrySet()) {
294+
for (AnnotationInstance ann : index.getAnnotations(entry.getKey())) {
295+
AnnotationValue nameValue = ann.value("name");
296+
if (nameValue == null || nameValue.asString().isEmpty()) {
297+
continue;
298+
}
299+
String runName = "dapr.langchain4j."
300+
+ toTitleCase(nameValue.asString()) + ".agent-run";
301+
recorder.registerWorkflow(builder, runName, agentRunClass);
302+
}
303+
}
304+
for (AnnotationInstance ann : index.getAnnotations(AGENT_ANNOTATION)) {
305+
if (ann.target().kind() != AnnotationTarget.Kind.METHOD) {
306+
continue;
307+
}
308+
AnnotationValue nameValue = ann.value("name");
309+
if (nameValue != null && !nameValue.asString().isEmpty()) {
310+
String runName = "dapr.langchain4j."
311+
+ toTitleCase(nameValue.asString()) + ".agent-run";
312+
recorder.registerWorkflow(builder, runName, agentRunClass);
313+
}
314+
}
315+
290316
recorder.startRuntime(builder);
291317
}
292318

quarkus/runtime/src/main/java/io/dapr/quarkus/langchain4j/workflow/DaprAgentServiceUtil.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,20 @@ public static String agentWorkflowName(String agentName) {
7676
return "dapr.langchain4j." + toTitleCase(agentName) + ".workflow";
7777
}
7878

79+
/**
80+
* Returns the child AgentRunWorkflow name for an agent.
81+
* Uses {@code .agent-run} suffix to avoid conflicts with orchestration
82+
* workflow names (which use {@code .workflow} suffix).
83+
*
84+
* @param agentName the agent name (e.g., "weather-assistant")
85+
* @return the child workflow name (e.g., "dapr.langchain4j.WeatherAssistant.agent-run")
86+
*/
87+
public static String agentRunName(String agentName) {
88+
if (agentName == null || agentName.isEmpty()) {
89+
return WorkflowNameResolver.resolve(
90+
io.dapr.quarkus.langchain4j.agent.workflow.AgentRunWorkflow.class);
91+
}
92+
return "dapr.langchain4j." + toTitleCase(agentName) + ".agent-run";
93+
}
94+
7995
}

quarkus/runtime/src/main/java/io/dapr/quarkus/langchain4j/workflow/orchestration/ConditionalOrchestrationWorkflow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public WorkflowStub create() {
5050
AgentRunInput agentInput = new AgentRunInput(agentRunId, metadata.agentName(),
5151
metadata.userMessage(), metadata.systemMessage());
5252

53-
String childName = DaprAgentServiceUtil.agentWorkflowName(metadata.agentName());
54-
var childWorkflow = ctx.callChildWorkflow(childName, agentInput, agentRunId, Void.class);
53+
var childWorkflow = ctx.callChildWorkflow(
54+
DaprAgentServiceUtil.agentRunName(metadata.agentName()), agentInput, agentRunId, Void.class);
5555
// Submit agent to planner (non-blocking activity — returns immediately)
5656
ctx.callActivity("agent-call",
5757
new AgentExecInput(input.plannerId(), i, agentRunId), Void.class).await();

quarkus/runtime/src/main/java/io/dapr/quarkus/langchain4j/workflow/orchestration/LoopOrchestrationWorkflow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public WorkflowStub create() {
5959
AgentRunInput agentInput = new AgentRunInput(agentRunId, metadata.agentName(),
6060
metadata.userMessage(), metadata.systemMessage());
6161

62-
String childName = DaprAgentServiceUtil.agentWorkflowName(metadata.agentName());
63-
var childWorkflow = ctx.callChildWorkflow(childName, agentInput, agentRunId, Void.class);
62+
var childWorkflow = ctx.callChildWorkflow(
63+
DaprAgentServiceUtil.agentRunName(metadata.agentName()), agentInput, agentRunId, Void.class);
6464
// Submit agent to planner (non-blocking activity -- returns immediately)
6565
ctx.callActivity("agent-call",
6666
new AgentExecInput(input.plannerId(), i, agentRunId), Void.class).await();

quarkus/runtime/src/main/java/io/dapr/quarkus/langchain4j/workflow/orchestration/ParallelOrchestrationWorkflow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public WorkflowStub create() {
5454
metadata.userMessage(), metadata.systemMessage());
5555

5656
// Start AgentRunWorkflow as a child workflow with agent-specific name
57-
String childName = DaprAgentServiceUtil.agentWorkflowName(metadata.agentName());
58-
childWorkflows.add(ctx.callChildWorkflow(childName, agentInput, agentRunId, Void.class));
57+
childWorkflows.add(ctx.callChildWorkflow(
58+
DaprAgentServiceUtil.agentRunName(metadata.agentName()), agentInput, agentRunId, Void.class));
5959
// Submit agent to planner (non-blocking activity -- returns immediately)
6060
submitTasks.add(ctx.callActivity("agent-call",
6161
new AgentExecInput(input.plannerId(), i, agentRunId), Void.class));

quarkus/runtime/src/main/java/io/dapr/quarkus/langchain4j/workflow/orchestration/SequentialOrchestrationWorkflow.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ public WorkflowStub create() {
4545
AgentRunInput agentInput = new AgentRunInput(agentRunId, metadata.agentName(),
4646
metadata.userMessage(), metadata.systemMessage());
4747

48-
// Start AgentRunWorkflow as a child workflow with agent-specific name
49-
String childWorkflowName = DaprAgentServiceUtil.agentWorkflowName(metadata.agentName());
50-
var childWorkflow = ctx.callChildWorkflow(childWorkflowName, agentInput, agentRunId, Void.class);
48+
// Start AgentRunWorkflow as child with agent-specific .agent-run name
49+
var childWorkflow = ctx.callChildWorkflow(
50+
DaprAgentServiceUtil.agentRunName(metadata.agentName()),
51+
agentInput, agentRunId, Void.class);
5152
// Submit agent to planner (non-blocking activity — returns immediately)
5253
ctx.callActivity("agent-call",
5354
new AgentExecInput(input.plannerId(), i, agentRunId), Void.class).await();

0 commit comments

Comments
 (0)