https://jupytext.org/ may be what you're looking for! It saves Notebook files as Python/text files, and can open them as Notebooks. I've mostly used it for improved version control and easier file inspection, but they recently started advertising the agent use case on their website.