1010import java .util .regex .Pattern ;
1111
1212import com .fasterxml .jackson .annotation .JsonAutoDetect ;
13+ import com .fasterxml .jackson .annotation .JsonCreator ;
1314import com .fasterxml .jackson .annotation .JsonInclude ;
1415import com .fasterxml .jackson .annotation .JsonProperty ;
16+ import com .fasterxml .jackson .annotation .JsonPropertyOrder ;
1517import com .fasterxml .jackson .annotation .JsonSubTypes ;
1618import com .fasterxml .jackson .annotation .JsonTypeInfo ;
1719import com .fasterxml .jackson .annotation .PropertyAccessor ;
2830import com .fasterxml .jackson .databind .module .SimpleDeserializers ;
2931import com .fasterxml .jackson .databind .module .SimpleModule ;
3032
33+ import dev .langchain4j .agent .tool .ToolExecutionRequest ;
3134import dev .langchain4j .data .message .AiMessage ;
3235import dev .langchain4j .data .message .ChatMessage ;
3336import dev .langchain4j .data .message .ChatMessageType ;
@@ -129,6 +132,7 @@ public static class ObjectMapperHolder {
129132 MAPPER .addMixIn (SystemMessage .class , SystemMessageMixin .class );
130133 MAPPER .addMixIn (ToolExecutionResultMessage .class , ToolExecutionResultMessageMixin .class );
131134 MAPPER .addMixIn (CustomMessage .class , CustomMessageMixin .class );
135+ MAPPER .addMixIn (ToolExecutionRequest .class , ToolExecutionRequestMixin .class );
132136
133137 // Register Quarkus-specific module
134138 MAPPER .registerModule (SnakeCaseObjectMapperHolder .QuarkusLangChain4jModule .INSTANCE );
@@ -158,6 +162,9 @@ private abstract static class ChatMessageMixin {
158162
159163 @ JsonInclude (JsonInclude .Include .NON_NULL )
160164 private abstract static class SystemMessageMixin {
165+ @ JsonCreator
166+ public SystemMessageMixin (@ JsonProperty ("text" ) String text ) {
167+ }
161168 }
162169
163170 @ JsonInclude (JsonInclude .Include .NON_NULL )
@@ -167,15 +174,31 @@ private abstract static class UserMessageMixin {
167174
168175 @ JsonInclude (JsonInclude .Include .NON_NULL )
169176 @ JsonDeserialize (builder = AiMessage .Builder .class )
177+ @ JsonPropertyOrder ({ "toolExecutionRequests" , "text" , "attributes" , "type" })
170178 private abstract static class AiMessageMixin {
171179 }
172180
173181 @ JsonInclude (JsonInclude .Include .NON_NULL )
174- private abstract static class ToolExecutionResultMessageMixin {
182+ @ JsonPropertyOrder ({ "text" , "id" , "toolName" , "type" })
183+ private static class ToolExecutionResultMessageMixin {
184+ @ JsonCreator
185+ public ToolExecutionResultMessageMixin (
186+ @ JsonProperty ("id" ) String id ,
187+ @ JsonProperty ("toolName" ) String toolName ,
188+ @ JsonProperty ("text" ) String text ) {
189+ }
190+ }
191+
192+ @ JsonInclude (JsonInclude .Include .NON_NULL )
193+ private static class CustomMessageMixin {
194+ @ JsonCreator
195+ public CustomMessageMixin (@ JsonProperty ("attributes" ) Map <String , Object > attributes ) {
196+ }
175197 }
176198
177199 @ JsonInclude (JsonInclude .Include .NON_NULL )
178- private abstract static class CustomMessageMixin {
200+ @ JsonDeserialize (builder = ToolExecutionRequest .Builder .class )
201+ private abstract static class ToolExecutionRequestMixin {
179202 }
180203
181204 public static class SnakeCaseObjectMapperHolder {
0 commit comments