@@ -51,12 +51,14 @@ public class MLAgentUpdateInput implements ToXContentObject, Writeable {
5151 public static final String MEMORY_TYPE_FIELD = "type" ;
5252 public static final String MEMORY_SESSION_ID_FIELD = "session_id" ;
5353 public static final String MEMORY_WINDOW_SIZE_FIELD = "window_size" ;
54+ public static final String TYPE_FIELD = "type" ;
5455 public static final String APP_TYPE_FIELD = "app_type" ;
5556 public static final String LAST_UPDATED_TIME_FIELD = "last_updated_time" ;
5657
5758 @ Getter
5859 private String agentId ;
5960 private String name ;
61+ private String type ;
6062 private String description ;
6163 private String llmModelId ;
6264 private Map <String , String > llmParameters ;
@@ -73,6 +75,7 @@ public class MLAgentUpdateInput implements ToXContentObject, Writeable {
7375 public MLAgentUpdateInput (
7476 String agentId ,
7577 String name ,
78+ String type ,
7679 String description ,
7780 String llmModelId ,
7881 Map <String , String > llmParameters ,
@@ -87,6 +90,7 @@ public MLAgentUpdateInput(
8790 ) {
8891 this .agentId = agentId ;
8992 this .name = name ;
93+ this .type = type ;
9094 this .description = description ;
9195 this .llmModelId = llmModelId ;
9296 this .llmParameters = llmParameters ;
@@ -105,6 +109,7 @@ public MLAgentUpdateInput(StreamInput in) throws IOException {
105109 Version streamInputVersion = in .getVersion ();
106110 agentId = in .readString ();
107111 name = in .readOptionalString ();
112+ type = in .readOptionalString ();
108113 description = in .readOptionalString ();
109114 llmModelId = in .readOptionalString ();
110115 if (in .readBoolean ()) {
@@ -135,6 +140,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
135140 if (name != null ) {
136141 builder .field (AGENT_NAME_FIELD , name );
137142 }
143+ if (type != null ) {
144+ builder .field (TYPE_FIELD , type );
145+ }
138146 if (description != null ) {
139147 builder .field (DESCRIPTION_FIELD , description );
140148 }
@@ -185,6 +193,7 @@ public void writeTo(StreamOutput out) throws IOException {
185193 Version streamOutputVersion = out .getVersion ();
186194 out .writeString (agentId );
187195 out .writeOptionalString (name );
196+ out .writeOptionalString (type );
188197 out .writeOptionalString (description );
189198 out .writeOptionalString (llmModelId );
190199 if (llmParameters != null && !llmParameters .isEmpty ()) {
@@ -221,6 +230,7 @@ public void writeTo(StreamOutput out) throws IOException {
221230 public static MLAgentUpdateInput parse (XContentParser parser ) throws IOException {
222231 String agentId = null ;
223232 String name = null ;
233+ String type = null ;
224234 String description = null ;
225235 String llmModelId = null ;
226236 Map <String , String > llmParameters = null ;
@@ -244,6 +254,9 @@ public static MLAgentUpdateInput parse(XContentParser parser) throws IOException
244254 case AGENT_NAME_FIELD :
245255 name = parser .text ();
246256 break ;
257+ case TYPE_FIELD :
258+ type = parser .text ();
259+ break ;
247260 case DESCRIPTION_FIELD :
248261 description = parser .text ();
249262 break ;
@@ -314,6 +327,7 @@ public static MLAgentUpdateInput parse(XContentParser parser) throws IOException
314327 return new MLAgentUpdateInput (
315328 agentId ,
316329 name ,
330+ type ,
317331 description ,
318332 llmModelId ,
319333 llmParameters ,
@@ -329,6 +343,9 @@ public static MLAgentUpdateInput parse(XContentParser parser) throws IOException
329343 }
330344
331345 public MLAgent toMLAgent (MLAgent originalAgent ) {
346+ if (type != null && !type .equals (originalAgent .getType ())) {
347+ throw new IllegalArgumentException ("Agent type cannot be updated" );
348+ }
332349 LLMSpec finalLlm ;
333350 if (llmModelId == null && (llmParameters == null || llmParameters .isEmpty ())) {
334351 finalLlm = originalAgent .getLlm ();
0 commit comments