purushah commented on code in PR #1363:
URL: https://github.com/apache/flink-agents/pull/1363#discussion_r4637454533


##########
plan/src/main/java/org/apache/flink/agents/plan/actions/ChatModelAction.java:
##########
@@ -378,35 +405,112 @@ private static void chat(
                         result.model,
                         result.retryCount,
                         result.totalRetryWaitSec);
-                if (selection.isRouter()) {
-                    if (!result.model.equals(selection.getSelectedModel())) {
-                        // The strategy's pick failed and another candidate 
answered; emit a
-                        // routing Event to report the fallback outcome.
+
+                // Quality gate: on a tier below the last one, an answer that 
fails a structural
+                // check or a declared signal is discarded before any of its 
tool calls runs, and
+                // the conversation so far goes to the next tier, where the 
request then stays.
+                Optional<Escalation> policy = selection.getEscalation();
+                if (policy.isPresent()) {
+                    Optional<EscalationGate.Outcome> escalate;
+                    try {
+                        escalate =
+                                EscalationGate.check(
+                                        policy.get(),
+                                        initialRequestId,
+                                        selection.getRequestedModel(),
+                                        candidate,
+                                        escalations,
+                                        messages,
+                                        promptArgs,
+                                        result,
+                                        ctx);
+                    } catch (ModelRoutingResolver.RoutingFailure e) {
+                        // A signal that cannot judge the round (verifier out 
of retries, custom
+                        // signal threw) fails the logical request, like a 
failed routing decision.
+                        takeRoutingMetadata(ctx.getSensoryMemory(), 
initialRequestId);
+                        sendFailure(initialRequestId, e, ctx);
+                        return;
+                    }
+                    if (escalate.isPresent()) {

Review Comment:
   Opened #1424 for this, with the three options. Can you share your test there?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to