Skip to content

Commit db5218c

Browse files
committed
next step
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
1 parent 562e9d8 commit db5218c

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

experimental/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/LC4JEquivalenceIT.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ public void sequentialWorkflow() {
7575
@Test
7676
@DisplayName("Looping agents via DSL.loop(...)")
7777
public void loopWorkflow() {
78-
79-
var scorer = AgentsUtils.newStyleScorer();
80-
var editor = AgentsUtils.newStyleEditor();
78+
var creativeWriter = AgentsUtils.newCreativeWriter();
79+
var styleScorer = AgentsUtils.newStyleScorer();
80+
var styleEditor = AgentsUtils.newStyleEditor();
8181

8282
Workflow wf =
8383
AgentWorkflowBuilder.workflow("retryFlow")
84-
.loop("reviewLoop", c -> c.readState("score", 0).doubleValue() >= 0.8, scorer, editor)
84+
.agent(creativeWriter)
85+
.loop(
86+
"reviewLoop",
87+
c -> c.readState("score", 0).doubleValue() >= 0.8,
88+
styleScorer,
89+
styleEditor)
8590
.build();
8691

8792
List<TaskItem> items = wf.getDo();

experimental/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,18 @@ StyleScorer styleScorer = AgenticServices
164164
<tr>
165165
<td style="vertical-align:top;">
166166
<pre style="background:none; margin:0; padding:0; font-family:monospace; line-height:1.4;">
167-
<code class="language-java" style="background:none;white-space:pre;">
168-
&nbsp;
169-
&nbsp;
167+
<code class="language-java" style="background:none;white-space:pre;">UntypedAgent styleReviewLoop = AgenticServices
168+
.loopBuilder()
169+
.subAgents(styleScorer, styleEditor)
170+
.maxIterations(5)
171+
.exitCondition(agenticScope -> agenticScope.readState("score", 0.0) >= 0.8)
172+
.build();
173+
170174
StyledWriter styledWriter = AgenticServices
171-
.sequenceBuilder(StyledWriter.class)
172-
.subAgents(creativeWriter, styleReviewLoop)
173-
.outputName("story")
174-
.build();
175+
.sequenceBuilder(StyledWriter.class)
176+
.subAgents(creativeWriter, styleReviewLoop)
177+
.outputName("story")
178+
.build();
175179

176180
String story = styledWriter.writeStoryWithStyle("dragons and wizards", "comedy");
177181

@@ -183,13 +187,17 @@ String story = styledWriter.writeStoryWithStyle("dragons and wizards", "comedy")
183187
<pre style="background:none; margin:0; padding:0; font-family:monospace; line-height:1.4;">
184188
<code class="language-java" style="background:none;white-space:pre;">Map&lt;String, Object> input = Map.of("story", "dragons and wizards","style", "comedy");
185189
Predicate<AgenticScope> until = s -> s.readState("score", 0).doubleValue() >= 0.8;
186-
187-
Workflow wf = workflow("retryFlow")
188-
.loop(until, scorer, editor)
189-
.build();
190190
&nbsp;
191191
&nbsp;
192192
&nbsp;
193+
&nbsp;
194+
&nbsp;
195+
&nbsp;
196+
Workflow wf = workflow("retryFlow")
197+
.agent(creativeWriter)
198+
.loop(until, styleScorer, styleEditor)
199+
.build();
200+
&nbsp;
193201
String result = app.workflowDefinition(wf).instance(input).start().get().asText().orElseThrow();
194202

195203
</code>

0 commit comments

Comments
 (0)