Comment by ActorNightly
2 days ago
>You can mess around with PYTHONPATH and importlib to work around that but that's a horrible hack that also breaks all tooling
....no.
import keyword uses importlib under the hood. It just does a lot of things for you like setting up namespace. But importlib has all the functionality to add the code in any python file cleanly.
My custom agent that I use basically has the functionality to wrap every piece of code it writes as a tool and stores it into python files. During tool calls, it pretty much dynamically imports that code as part of a module within the project. Works perfectly fine.
> Works perfectly fine.
Unless you want to use type checkers, linters, IDEs, etc.