@@ -50,12 +50,14 @@ public class MLAgentUpdateInput implements ToXContentObject, Writeable {
5050 public static final String MEMORY_TYPE_FIELD = "type" ;
5151 public static final String MEMORY_SESSION_ID_FIELD = "session_id" ;
5252 public static final String MEMORY_WINDOW_SIZE_FIELD = "window_size" ;
53+ public static final String TYPE_FIELD = "type" ;
5354 public static final String APP_TYPE_FIELD = "app_type" ;
5455 public static final String LAST_UPDATED_TIME_FIELD = "last_updated_time" ;
5556
5657 @ Getter
5758 private String agentId ;
5859 private String name ;
60+ private String type ;
5961 private String description ;
6062 private String llmModelId ;
6163 private Map <String , String > llmParameters ;
@@ -72,6 +74,7 @@ public class MLAgentUpdateInput implements ToXContentObject, Writeable {
7274 public MLAgentUpdateInput (
7375 String agentId ,
7476 String name ,
77+ String type ,
7578 String description ,
7679 String llmModelId ,
7780 Map <String , String > llmParameters ,
@@ -86,6 +89,7 @@ public MLAgentUpdateInput(
8689 ) {
8790 this .agentId = agentId ;
8891 this .name = name ;
92+ this .type = type ;
8993 this .description = description ;
9094 this .llmModelId = llmModelId ;
9195 this .llmParameters = llmParameters ;
@@ -104,6 +108,7 @@ public MLAgentUpdateInput(StreamInput in) throws IOException {
104108 Version streamInputVersion = in .getVersion ();
105109 agentId = in .readString ();
106110 name = in .readOptionalString ();
111+ type = in .readOptionalString ();
107112 description = in .readOptionalString ();
108113 llmModelId = in .readOptionalString ();
109114 if (in .readBoolean ()) {
@@ -134,6 +139,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
134139 if (name != null ) {
135140 builder .field (AGENT_NAME_FIELD , name );
136141 }
142+ if (type != null ) {
143+ builder .field (TYPE_FIELD , type );
144+ }
137145 if (description != null ) {
138146 builder .field (DESCRIPTION_FIELD , description );
139147 }
@@ -184,6 +192,7 @@ public void writeTo(StreamOutput out) throws IOException {
184192 Version streamOutputVersion = out .getVersion ();
185193 out .writeString (agentId );
186194 out .writeOptionalString (name );
195+ out .writeOptionalString (type );
187196 out .writeOptionalString (description );
188197 out .writeOptionalString (llmModelId );
189198 if (llmParameters != null && !llmParameters .isEmpty ()) {
@@ -220,6 +229,7 @@ public void writeTo(StreamOutput out) throws IOException {
220229 public static MLAgentUpdateInput parse (XContentParser parser ) throws IOException {
221230 String agentId = null ;
222231 String name = null ;
232+ String type = null ;
223233 String description = null ;
224234 String llmModelId = null ;
225235 Map <String , String > llmParameters = null ;
@@ -243,6 +253,9 @@ public static MLAgentUpdateInput parse(XContentParser parser) throws IOException
243253 case AGENT_NAME_FIELD :
244254 name = parser .text ();
245255 break ;
256+ case TYPE_FIELD :
257+ type = parser .text ();
258+ break ;
246259 case DESCRIPTION_FIELD :
247260 description = parser .text ();
248261 break ;
@@ -313,6 +326,7 @@ public static MLAgentUpdateInput parse(XContentParser parser) throws IOException
313326 return new MLAgentUpdateInput (
314327 agentId ,
315328 name ,
329+ type ,
316330 description ,
317331 llmModelId ,
318332 llmParameters ,
@@ -328,6 +342,9 @@ public static MLAgentUpdateInput parse(XContentParser parser) throws IOException
328342 }
329343
330344 public MLAgent toMLAgent (MLAgent originalAgent ) {
345+ if (type != null && !type .equals (originalAgent .getType ())) {
346+ throw new IllegalArgumentException ("Agent type cannot be updated" );
347+ }
331348 LLMSpec finalLlm ;
332349 if (llmModelId == null && (llmParameters == null || llmParameters .isEmpty ())) {
333350 finalLlm = originalAgent .getLlm ();
0 commit comments