sangkyoonnam commented on issue #1424:
URL: https://github.com/apache/flink-agents/issues/1424#issuecomment-7063061649

   Here are both cases as tests for `ChatModelActionEscalationTest`. They're 
written against option 1, so on the #1363 head (0a07cd1a) both fail, and the 
other 35 tests in the class pass.
   
   - Two tiers, `big` default and down: the request fails with `big`'s error 
after calls `[big, small, big]`. The test expects `small`'s answer and calls 
`[big, small]`.
   - Three tiers, `medium` default and down: calls are `[medium, small, medium, 
big]`. The test expects `[medium, small, big]` and `big`'s answer.
   
   Neither test settles your open points. There's no candidate outside the 
tiers, and the assertions pass whether or not the verifier runs on the kept 
answer.
   
   <details><summary>Tests</summary>
   
   ```java
   @Test
   void escalationDoesNotCallATierThatFailedEarlierInTheRequest() throws 
Exception {
       // Tiers small, big; big is the default and down. Fallback gets an 
answer from small and
       // the verifier rejects it. big already failed, so there is no higher 
tier to try and
       // small's answer is kept.
       ModelRouter router =
               new ModelRouter(
                       of("small", "big")
                               .defaultModel("big")
                               .escalation(
                                       Escalation.tiers("small", "big")
                                               
.when(QualitySignals.decision("dm", 0.7)))
                               .fallback(true)
                               .build(),
                       null);
       FakeRunnerContext ctx =
               new FakeRunnerContext(router)
                       .withRetryBudget(0, 0)
                       .registerDecision("dm", new 
FakeDecisionModel(verdict(0.1)))
                       .register("small", new 
FakeChatModel(ChatFixtures.response("s")))
                       .register(
                               "big",
                               new FakeChatModel(
                                       new RuntimeException("big down"),
                                       new RuntimeException("big down again")));
       send(ctx, "hello");
   
       ChatResponseEvent response = ctx.chatResponse();
       assertThat(response.isFailed()).isFalse();
       assertThat(response.getResponse().getText()).isEqualTo("s");
       assertThat(ctx.resolvedChatModels).containsExactly("big", "small");
   }
   
   @Test
   void escalationSkipsATierThatFailedEarlierInTheRequest() throws Exception {
       // Tiers small, medium, big; medium is the default and down. Fallback 
gets an answer from
       // small and the verifier rejects it. Escalation goes past medium, which 
already failed,
       // straight to big.
       ModelRouter router =
               new ModelRouter(
                       of("small", "medium", "big")
                               .defaultModel("medium")
                               .escalation(
                                       Escalation.tiers("small", "medium", 
"big")
                                               
.when(QualitySignals.decision("dm", 0.7)))
                               .fallback(true)
                               .build(),
                       null);
       FakeRunnerContext ctx =
               new FakeRunnerContext(router)
                       .withRetryBudget(0, 0)
                       .registerDecision("dm", new 
FakeDecisionModel(verdict(0.1)))
                       .register("small", new 
FakeChatModel(ChatFixtures.response("s")))
                       .register(
                               "medium",
                               new FakeChatModel(
                                       new RuntimeException("medium down"),
                                       new RuntimeException("medium down 
again")))
                       .register("big", new 
FakeChatModel(ChatFixtures.response("b")));
       send(ctx, "hello");
   
       ChatResponseEvent response = ctx.chatResponse();
       assertThat(response.isFailed()).isFalse();
       assertThat(response.getResponse().getText()).isEqualTo("b");
       assertThat(ctx.resolvedChatModels).containsExactly("medium", "small", 
"big");
   }
   ```
   
   </details>
   


-- 
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