From e4e289fe347996807b7792849ec9146e68d6b157 Mon Sep 17 00:00:00 2001 From: iroqueta Date: Wed, 22 Oct 2025 13:20:53 -0300 Subject: [PATCH] ChatHistory after Agent.chat() After calling the chat method of an agent in java, the messages corresponding to the call to tools do not remain in the ChatHistory --- java/src/main/java/com/genexus/GXProcedure.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/src/main/java/com/genexus/GXProcedure.java b/java/src/main/java/com/genexus/GXProcedure.java index 008cd1d45..0f597bbc5 100644 --- a/java/src/main/java/com/genexus/GXProcedure.java +++ b/java/src/main/java/com/genexus/GXProcedure.java @@ -275,6 +275,10 @@ protected String callAssistant(String agent, GXProperties properties, ArrayList< } protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList messages, CallResult result) { + return chatAgent(agent, properties, messages, null, result); + } + + protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList messages, GXExternalCollection history, CallResult result) { ChatResult chatResult = new ChatResult(); new Thread(() -> { @@ -283,6 +287,8 @@ protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList< callAgent(agent, true, properties, messages, result, chatResult); } finally { chatResult.markDone(); + if (history != null) + history.setExternalInstance(messages); } }).start();