autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Add an option to auto-delete temp files created by LocalCommandLineExecutor

Open afourney opened this issue 1 year ago • 1 comments

What feature would you like to be added?

LocalCommandLineExecutor leaves a lot of debris on disk like:

tmp_code_84c00a94989f5048ee254cb2e583fc8e75b66c0afef4a7a76c8901a4eb2f5bc5.py
tmp_code_95c44f5140612045a5fb8c5ccad956a2ae4afb4a028201cf836fbb55c09c72f1.py

These files are executed once, and never referred to again.

Please add an (on by default) option to automatically clean up temporary files.

Why is this needed?

Explained above.

afourney avatar Nov 26 '24 19:11 afourney

We don't need to do this work in the framework, using standard python tempdir tooling should work fine: https://github.com/microsoft/autogen/blob/prefix_sub/python/packages/autogen-core/tests/execution/test_commandline_code_executor.py#L92-L93

jackgerrits avatar Nov 26 '24 20:11 jackgerrits

@afourney & @jackgerrits Should this issue be closed or is there still work? If there is work, does this have to do with the functions in autogen_ext/code_exectors/init.py (ln https://github.com/microsoft/autogen/blob/c76a68c780da4ec5f838c88a29a8e6f1ff31a2c0/python/packages/autogen-ext/src/autogen_ext/code_executors/local/init.py#L246) and not the tests?

pierceroberts avatar Feb 17 '25 00:02 pierceroberts

Hi @ekzhu & @jackgerrits , is this issue still in progress, or would it be okay if I picked it up? 🚀

holtvogt avatar May 18 '25 16:05 holtvogt

@jackgerrits I wanted to follow up on https://github.com/microsoft/autogen/pull/6556#discussion_r2094628477 where I indicated that we can reduce the code duplication in CodeExecutors. It may make sense to open a new issue but I'm not able to this. I was thinking about two approaches, and need some input from your side;

  1. Implementing this behaviour in the CodeExecutor parent, where it may not be implemented by all children (Refused Bequest).
  2. Introducing a new TemporaryFileCleanupMixin class that some CodeExecutors (e.g., LocalCommandLineCodeExecutor, DockerCommandLineCodeExecutor) can inherit from and encapsulates the behaviour. But this may be overkill given the rather simple functionality it provides.

What do you think?

CC @ekzhu

holtvogt avatar May 22 '25 12:05 holtvogt