Skip to content

Commit 8e2bd3f

Browse files
authored
ChatHistory after Agent.chat() (#1035)
After calling the chat method of an agent in java, the messages corresponding to the call to tools do not remain in the ChatHistory
1 parent 03155bb commit 8e2bd3f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

java/src/main/java/com/genexus/GXProcedure.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ protected String callAssistant(String agent, GXProperties properties, ArrayList<
275275
}
276276

277277
protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList<OpenAIResponse.Message> messages, CallResult result) {
278+
return chatAgent(agent, properties, messages, null, result);
279+
}
280+
281+
protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList<OpenAIResponse.Message> messages, GXExternalCollection<?> history, CallResult result) {
278282
ChatResult chatResult = new ChatResult();
279283

280284
new Thread(() -> {
@@ -283,6 +287,8 @@ protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList<
283287
callAgent(agent, true, properties, messages, result, chatResult);
284288
} finally {
285289
chatResult.markDone();
290+
if (history != null)
291+
history.setExternalInstance(messages);
286292
}
287293
}).start();
288294

0 commit comments

Comments
 (0)