@@ -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-   ;
169-   ;
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+
170174StyledWriter 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
176180String 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< ; String, Object> input = Map.of("story", "dragons and wizards","style", "comedy");
185189Predicate<AgenticScope > until = s -> s.readState("score", 0).doubleValue() >= 0.8;
186-
187- Workflow wf = workflow("retryFlow")
188- .loop(until, scorer, editor)
189- .build();
190190  ;
191191  ;
192192  ;
193+   ;
194+   ;
195+   ;
196+ Workflow wf = workflow("retryFlow")
197+ .agent(creativeWriter)
198+ .loop(until, styleScorer, styleEditor)
199+ .build();
200+   ;
193201String result = app.workflowDefinition(wf).instance(input).start().get().asText().orElseThrow();
194202
195203</code >
0 commit comments