@@ -378,7 +378,6 @@ def modify_agent_tools(
378378
379379 filename = _framework_filename (framework , path )
380380
381- # Read the original source and store line information
382381 with open (filename , 'r' , encoding = 'utf-8' ) as f :
383382 source_lines = f .readlines ()
384383
@@ -389,29 +388,22 @@ def modify_agent_tools(
389388 if stripped .startswith ('#' ):
390389 comments [i + 1 ] = line
391390
392- # Parse and modify the AST
393391 tree = ast .parse ('' .join (source_lines ))
394392
395393 class ModifierTransformer (ast .NodeTransformer ):
396394 def visit_FunctionDef (self , node ):
397395 return _modify_agent_tools (node , tool_data , operation , agents , base_name )
398396
399397 modified_tree = ModifierTransformer ().visit (tree )
400-
401- # Generate the modified source without comments
402398 modified_source = astor .to_source (modified_tree )
403-
404- # Split the modified source into lines
405399 modified_lines = modified_source .splitlines ()
406400
407- # Reinsert comments at appropriate positions
401+ # Reinsert comments
408402 final_lines = []
409403 for i , line in enumerate (modified_lines , 1 ):
410- # If there was a comment at this line number in the original file, add it
411404 if i in comments :
412405 final_lines .append (comments [i ])
413406 final_lines .append (line + '\n ' )
414407
415- # Write the final source back
416408 with open (filename , 'w' , encoding = 'utf-8' ) as f :
417409 f .write ('' .join (final_lines ))
0 commit comments