Skip to content

Commit a212fdc

Browse files
committed
handle none as next agent
1 parent 8950f38 commit a212fdc

File tree

1 file changed

+9
-0
lines changed
  • app/copilot/langchain4j-agents/src/main/java/com/microsoft/openai/samples/assistant/langchain4j/agent

1 file changed

+9
-0
lines changed

app/copilot/langchain4j-agents/src/main/java/com/microsoft/openai/samples/assistant/langchain4j/agent/SupervisorAgent.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ public void invoke(List<ChatMessage> chatHistory) {
7575

7676

7777
protected void singleTurnRouting(String nextAgent, List<ChatMessage> chatHistory) {
78+
if("none".equalsIgnoreCase(nextAgent)){
79+
LOGGER.info("Gracefully handle clarification.. ");
80+
AiMessage clarificationMessage = AiMessage.builder().
81+
text(" I'm not sure about your request. Can you please clarify?")
82+
.build();
83+
chatHistory.add(clarificationMessage);
84+
return;
85+
}
86+
7887
Agent agent = agents.stream()
7988
.filter(a -> a.getName().equals(nextAgent))
8089
.findFirst()

0 commit comments

Comments
 (0)