OpenCode’s maker has taken the engine that runs Code Mode scripts and released it on its own. Anomaly, the company behind OpenCode, published Psychoscript as a standalone, MIT-licensed JavaScript interpreter that confines what a script can touch and can freeze a running script into bytes, then resume it later. OpenCode announced it on X on 25 November. The idea is simple: if an agent writes code, the code should only reach what you hand it. I read the repository, the README and the package listing. I haven’t run Psychoscript myself, so everything below comes from those sources and the posts I cite.
What it is, and where it sits in OpenCode
Psychoscript is a bytecode virtual machine for a subset of JavaScript. A script runs with no ambient access: no fetch, no file system, no process, no timers, no eval, no Proxy or Reflect, and no changing of built-in prototypes. Host functions are the only way out, and arguments and results are copied across the boundary rather than shared. It needs Node 24 or newer, or Bun 1.4 or newer, and uses the acorn parser. The repository is anomalyco/psychoscript.

The layering matters if you use OpenCode. Psychoscript is the language layer. The @opencode/codemode package sits on top and adds the tools, schemas, catalogue, search, OpenAPI support, hooks and a cap on tool calls. OpenCode sits on that. When the agent writes a script that chains several MCP tool calls, as I described in the OpenCode 2.0 explainer, Psychoscript is what runs it. The Code Mode explainer covers why agents write scripts instead of calling tools one at a time.
Pause, save and resume
The headline feature is suspension. A script that waits on a slow host call can be paused, its whole state saved to bytes, and resumed later, even in another process. That suits agent work that waits on a person, a queue or a long job.

The README is plain about the catches:
- Snapshots are build-locked. A snapshot only resumes on the same Psychoscript build that made it, so an upgrade between pause and resume breaks it.
- Host calls can run twice. On resume, idempotent host calls are re-run. Anything that charges a card or sends an email needs to be a durable host call or be made safe to repeat.
- Trust a snapshot like code. Resuming one runs it, so don’t load snapshots from a source you wouldn’t run code from.
Only what you hand it

This is a language-level sandbox, not an operating-system one. The script can’t reach your network or disk because the language has nothing that does, and the host decides what to expose. In Code Mode those host functions are the MCP tools and OpenAPI endpoints, so the permission rules you set on a tool still apply to a call made from inside a script.
The limits to settle before you run untrusted code

The README lists what Psychoscript doesn’t promise. timeoutMs and maxOutputBytes are off by default, so you have to turn them on. There is no memory limit and no step limit, only fixed caps. A single regular expression can’t be interrupted once it starts, so a pathological pattern can hold the process. Math.random and Date.now are non-deterministic, which matters if you expect a resumed run to repeat itself.
My view: Psychoscript runs in your process, so for code written by a stranger or a model you don’t trust, put it behind a process boundary as well. That’s my opinion, not the README’s. For scripts an agent writes against your own tools, with the limits switched on, the language-level confinement is a reasonable layer.
The Rust port
A Rust port already lives in the repository’s rust/ folder, with its own benchmark. The author’s run, on an Apple M5 Max, reports starting 34 times faster, running a program 4.3 times faster and using 4.3 to 20 MiB of memory against 83 to 119 MiB for the TypeScript version.

Two cautions. These are the author’s numbers on one machine, and I haven’t reproduced them. And the gain isn’t uniform: on the repository’s own bench programs the speedup is 2.0 times, and one program is slower in Rust. The OpenCode post describes the port as in the works, while the repository already holds it, so treat it as work in progress rather than something to depend on.
How much traction it has
The repository was created on 13 November, the first npm release came on 17 November and 0.3.0 followed on 24 November. The 0.2.0 release was a breaking change and moved the optional Effect integration to psychoscript/effect. npm showed 32,242 downloads for 19 to 25 November, but lists only one dependent. Weekly downloads count installs by people, CI jobs and mirrors alike, so I wouldn’t read that figure as 32,000 users.
A few oddities worth knowing about. The project’s website is a deliberate parody called “NormalScript®”, and its “400 normal organizations” line is a joke, not a customer count. The conformance numbers differ between the site and the README, and the repository’s continuous integration doesn’t run the test262 suite yet. Some of the site’s examples import "normalscript" rather than "psychoscript".
How it compares with the other ways to run agent code
Running model-written code has two broad answers: confine the language, or confine the machine. Psychoscript is the first kind. Here’s where the neighbours sit.
| Option | Isolation | What stands out |
|---|---|---|
| Psychoscript | Language level, in your process | Suspend, save and resume; MIT; tied to Code Mode |
| Cloudflare Dynamic Workers | V8 isolates | Cloudflare reported cutting a 1.17 million token tool surface to about 1,000 tokens, a 99.9% saving |
| Anthropic’s code execution with MCP | Sandboxed execution | Anthropic’s write-up cut a 150,000 token workflow to 2,000, a 98.7% saving |
| Pydantic Monty | A Python subset written in Rust | Subprocess workers, memory and time limits, snapshots |
| isolated-vm | V8 isolates inside Node | A long-standing way to run untrusted JavaScript in Node |
| QuickJS in WebAssembly | WASM sandbox | A small JavaScript engine compiled to WebAssembly |
| Vercel Sandbox | microVM | A full isolated machine for code, rather than a language-level sandbox |
The closest peer in spirit is Pydantic’s Monty, which also snapshots a paused run, though for Python. The Cloudflare and Anthropic figures aren’t Psychoscript results, they show why the approach attracts agent builders: a script that chains calls keeps intermediate results out of the model’s context.
Before you use it
- Switch the limits on. Set
timeoutMsandmaxOutputBytesyourself, because both default to off. - Pin the build. Snapshots only resume on the build that wrote them, so pin the version if you store them.
- Make host calls safe to repeat. A resumed run can repeat an idempotent call.
- Treat snapshots as code. Only resume ones you made.
- Add a process boundary for hostile code. One regular expression can hang the interpreter.
- Expect churn. The package is under two weeks old and has already had a breaking release.
I haven’t run Psychoscript, and this article doesn’t claim it behaves as the README says.
Discover more from Sulat AI & Tech News
Subscribe to get the latest posts sent to your email.




