Live data from Hacker News

Monty: A minimal, secure Python interpreter written in Rust for use by AI

github.com

61–70 of 179 posts

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#61
post #5

I got a WebAssembly build of this working and fired up a web playground for trying it out: https://simonw.github.io/research/monty-wasm-pyodide/demo.ht... It doesn't have class support yet! But it doesn't matter, because LLMs that try to use a class will get an error message and rewrite their code to not use classes instead. Notes on how I got the WASM build working here: https://simonwillison.net/2026/Feb/6/pydantic…

[flagged]

You're really stretching things here to classify me pointing out that LLMs can handle syntax errors caused by partial implementations of Python as "being a vapid propagandist".

(This kind of extremely weak criticism often seems to come from newly created Hacker News accounts, which makes me wonder if it's mostly the same person using sockpuppets.)

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#62
post #37

Earlier quoted context omitted.

A big benefit of letting agents run code is they can process data without bloating their context. LLMs are really good at writing python for data processing. I would suspect its due to Python having a really good ecosystem around this niche And the type safety/security issues can hopefully be mitigated by ty and pyodide (already used by cf’s python workers) https://pyodide.org/en/stable/ https://github.com/astral-sh/…

(Pydantic AI lead here) That’s exactly what we built this for: we’re implementing Code Mode in https://github.com/pydantic/pydantic-ai/pull/4153 which will use Monty by default, with abstractions to use other runtimes / sandboxes. Monty’s overhead is so low that, assuming we get the security / capabilities tradeoff right (Samuel can comment on this more), you could always have it enabled on your agents with basically…

Why do you think python without access to the library ecosystem is a good approach? I think you will end up with small tool call subgraphs (i.e. more round trips) or having to generate substantially more utility code.

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#63
post #41

Earlier quoted context omitted.

How do I sandbox CPython using OS features? (Genuine question, I've been trying to find reliable, well documented, robust patterns for doing this for years! I need it across macOS and Linux and ideally Windows too. Preferably without having to run anything as root.)

Docker and other container runners allow it. https://containers.dev/ allows it too. https://github.com/microsoft/litebox might somehow allow it too if a tool can be built on top of it, but there is no documentation.

Every time I use Docker as a sandbox people warn me to watch out for "container escapes".

I trust Firecracker more because it was built by AWS specifically to sandbox Lambdas, but it doesn't work on macOS and is pretty fiddly to run on Linux.

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#64
post #19

Earlier quoted context omitted.

this is pretty performant for short scripts if you measure time "from code to rust" which can be as low as 1us. Of course it's slow for complex numerical calculations, but that's the primary usecase. I think the consensus is that LLMs are very good at writing python and ts/js, generally not quite as good at writing other languages, at least in one shot. So there's an advantage to using python/js/ts.

Seems like we should fix the LLMs instead of bending over backwards no?

They’re good at it because they’ve learned from the existing mountains of python and javascript.

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#65
post #41

It is absurd for any user to use a half baked Python interpreter, also one that will always majorly lag behind CPython in its support. I advise sandboxing CPython instead using OS features.

How do I sandbox CPython using OS features? (Genuine question, I've been trying to find reliable, well documented, robust patterns for doing this for years! I need it across macOS and Linux and ideally Windows too. Preferably without having to run anything as root.)

It could be difficult. My first thought would be a SELinux policy like this article attempted:

https://danwalsh.livejournal.com/28545.html

One might have different profiles with different permissions. A network service usually wouldn't need your hone directory while a personal utility might not need networking.

Also, that concept could be mixed with subprocess-style sandboxing. The two processes, main and sandboxed, might have different policies. The sandboxed one can only talk to main process over a specific channel. Nothing else. People usually also meter their CPU, RAM, etc.

INTEGRITY RTOS had language-specific runtimes, esp Ada and Java, that ran directly on the microkernel. A POSIX app or Linux VM could run side by side with it. Then, some middleware for inter-process communication let them talk to each other.

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#66
post #60
post #49

Earlier quoted context omitted.

Please report any panics, we'll fix them!

[flagged]

Staying true to your username at least. While I hear you in principle, I don’t think shaming people into not building things is going to work out. Even if you could convince some people, you’ll never reach them all. Someone will build it. IMO energy is better spent figuring out how to best structure our society to handle the seemingly inevitable end state where superhuman AI is commonplace.

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#67
post #21
post #3

I'm of the mind that it will be better to construct more strict/structured languages for AI use than to reuse existing ones. My reasoning is 1) AIs can comprehend specs easily, especially if simple, 2) it is only valuable to "meet developers where they are" if really needing the developers' history/experience which I'd argue LLMs don't need as much (or only need because lang is so flexible/loose), and 3) human langua…

I think the hard part about that is you first have to train the model on a BUTT TON of that new language, because that's the only way they "learn" anything. They already know a lot of Python, so telling them to write restricted and sandboxed Python ("you can only call _these_ functions") is a lot easier. But I'd be interested to see what you come up with.

> you first have to train the model on a BUTT TON of that new language

Tokenization joke?

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#68
It seems that AI finally give the space to true pure-blood system software systems to unleash their potential.

Pretty much all morn software tooling, removing the parts that aim at appeal to humans, becomes much more reliable tools. But it's not clear if the performance will be better or not.

Re: Monty: A minimal, secure Python interpreter written in Rust for use by AI

#69
post #60
post #49

Earlier quoted context omitted.

Please report any panics, we'll fix them!

[flagged]

Every AI advancement liberates real humans from drudgery and allows them to create what they want more easily.

The invention of the digital calculator turned human calculators into accountants, and that's great! We're contributing to the same process now

Post reply on HN