@@ -170,7 +170,7 @@ public Map<Path, List<TextEdit>> toSource(SourceBuilder sourceBuilder) {
170
170
}
171
171
172
172
// If model is not set, create a default model provider node
173
- if (model .get ().value () == null || model .get ().value ().equals ( "" )) {
173
+ if (model .get ().value () == null || model .get ().value ().toString (). isEmpty ( )) {
174
174
NodeBuilder .TemplateContext modelProviderContext = new NodeBuilder .TemplateContext (
175
175
sourceBuilder .workspaceManager ,
176
176
sourceBuilder .filePath ,
@@ -188,7 +188,7 @@ public Map<Path, List<TextEdit>> toSource(SourceBuilder sourceBuilder) {
188
188
}
189
189
190
190
// If connection is not set, create a default agent node
191
- if (connection .get ().value () == null || connection .get ().value ().equals ( "" )) {
191
+ if (connection .get ().value () == null || connection .get ().value ().toString (). isEmpty ( )) {
192
192
agentContext = new TemplateContext (
193
193
sourceBuilder .workspaceManager ,
194
194
sourceBuilder .filePath ,
@@ -204,6 +204,7 @@ public Map<Path, List<TextEdit>> toSource(SourceBuilder sourceBuilder) {
204
204
FlowNode agentNode = new AgentBuilder ().setConstData ().setTemplateData (agentContext ).build ();
205
205
updateAgentNodeProperties (agentNode , agentCallNode );
206
206
207
+ // If new model provider is created, copy variable name to agent model
207
208
if (modelProviderNode != null ) {
208
209
FlowNodeUtil .copyPropertyValue (agentNode , modelProviderNode , MODEL , Property .VARIABLE_KEY );
209
210
} else {
@@ -260,8 +261,8 @@ private static void updateAgentNodeProperties(FlowNode agentNode, FlowNode agent
260
261
if (agentNode .properties () == null ) {
261
262
return ;
262
263
}
264
+ copyCommonProperties (agentNode , agentCallNode );
263
265
updateSystemPromptProperty (agentNode , agentCallNode );
264
- // TODO: Copy values of other properties of agentCallNode to agentNode (maxIter, verbose, etc.)
265
266
}
266
267
267
268
private static void updateSystemPromptProperty (FlowNode agentNode , FlowNode agentCallNode ) {
@@ -279,10 +280,32 @@ private static void updateSystemPromptProperty(FlowNode agentNode, FlowNode agen
279
280
agentNode .properties ().put (SYSTEM_PROMPT , updatedProperty );
280
281
}
281
282
282
- /**
283
- * Finds the agent context for a given connection variable name. If the connection exists, searches for the agent
284
- * symbol using visibleSymbols and returns its context. Otherwise, returns a default agent context.
285
- */
283
+ private static void copyCommonProperties (FlowNode agentNode , FlowNode agentCallNode ) {
284
+ if (agentNode .properties () == null || agentCallNode .properties () == null ) {
285
+ return ;
286
+ }
287
+
288
+ for (Map .Entry <String , Property > agentPropertyEntry : agentNode .properties ().entrySet ()) {
289
+ String propertyName = agentPropertyEntry .getKey ();
290
+ Property agentProperty = agentPropertyEntry .getValue ();
291
+
292
+ // Skip copying variable and type properties
293
+ if (Property .VARIABLE_KEY .equals (propertyName ) || Property .TYPE_KEY .equals (propertyName )) {
294
+ continue ;
295
+ }
296
+
297
+ Optional <Property > agentCallProperty = agentCallNode .getProperty (propertyName );
298
+
299
+ if (agentCallProperty .isPresent () &&
300
+ (agentCallProperty .get ().value () != null &&
301
+ !agentCallProperty .get ().value ().toString ().isEmpty ())) {
302
+ Property updatedProperty = FlowNodeUtil .createUpdatedProperty (agentProperty ,
303
+ agentCallProperty .get ().value ().toString ());
304
+ agentNode .properties ().put (propertyName , updatedProperty );
305
+ }
306
+ }
307
+ }
308
+
286
309
private static NodeBuilder .TemplateContext findAgentContext (SourceBuilder sourceBuilder , String agentVariableName ) {
287
310
Optional <NodeBuilder .TemplateContext > agentContext =
288
311
findAgentContextByVariableName (sourceBuilder , agentVariableName );
@@ -294,9 +317,6 @@ private static NodeBuilder.TemplateContext findAgentContext(SourceBuilder source
294
317
return agentContext .get ();
295
318
}
296
319
297
- /**
298
- * Searches for an agent symbol by variable name using visibleSymbols and returns its context.
299
- */
300
320
private static Optional <NodeBuilder .TemplateContext > findAgentContextByVariableName (
301
321
SourceBuilder sourceBuilder , String variableName ) {
302
322
try {
@@ -325,9 +345,6 @@ private static Optional<NodeBuilder.TemplateContext> findAgentContextByVariableN
325
345
return Optional .empty ();
326
346
}
327
347
328
- /**
329
- * Builds the agent context from the variable symbol.
330
- */
331
348
private static Optional <NodeBuilder .TemplateContext > buildAgentContext (SourceBuilder sourceBuilder ,
332
349
VariableSymbol varSymbol ) {
333
350
try {
0 commit comments