purushah commented on code in PR #1363:
URL: https://github.com/apache/flink-agents/pull/1363#discussion_r4607796984
##########
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:
> The models called are `[big, small, big]`, and the request fails with
`big`'s second error
I get the same trace. Fallback walks down the list, escalation walks up the
tiers, and neither knows what the other tried. Today's result matches the docs,
the request fails with big's own error and not for quality.
> Which do you prefer?
(a) in spirit, but not in this PR. I want to keep this one to the escalation
feature and wenjin272's two refactors. I'll open a follow-up issue with the
options: a failed tier is never called again in the request, fallback follows
the tiers when tiers are declared, or the chain always starts at the first
tier. I'll add a row to the docs table for this order so the current behavior
is written down. Please share your test, I'll use it in the follow-up.
--
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]