Sulat.com / Writing on AIFriday, November 27, 2026
Agent Engineering/27 November 2026

OpenCode pulls the runtime behind Code Mode out as Psychoscript, a JavaScript interpreter you can pause, save and resume

Anomaly, the company behind OpenCode, has split the interpreter inside Code Mode out as Psychoscript, an MIT-licensed package that can save a paused script as bytes. I check what it limits, what it leaves to you, and where it sits among its peers.

Glossy 3D OpenCode logo tile beside a sealed glass cube holding gears and a code scroll, a pause symbol above and a coiled byte ribbon below
Illustration: Sulat, featuring the OpenCode logo

At a glance

  • Anomaly, the company behind OpenCode, released Psychoscript, the confined JavaScript interpreter that runs Code Mode scripts, as a standalone MIT-licensed package.
  • Scripts have no fetch, files, timers or eval. The only way out is a host function you pass in, and a paused run can be saved as bytes and resumed later, on the same build only.
  • Timeouts and output caps are off by default, there is no memory limit, and a single regular expression can't be interrupted, so hostile code still deserves a process boundary.
  • A Rust port in the repository reports starting 34 times faster and running programs 4.3 times faster in the author's own benchmark, which I haven't reproduced.
  • The package had 32,242 weekly npm downloads but one listed dependent, and I haven't run it myself.

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.

OpenCode’s post announcing Psychoscript, made on 25 November 2026.

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.

Hand-drawn stack of three layers: OpenCode on top, the codemode package in the middle, standalone Psychoscript at the base
Psychoscript is the base layer of OpenCode’s Code Mode, and language fixes land there first. Illustration: Sulat

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.

Hand-drawn three steps: a script waits on a slow call, pause and save state as bytes, resume later in another process
A paused Psychoscript run is saved as bytes and resumed later. Illustration: Sulat. Source: psychoscript README

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

Hand-drawn: fetch, files, timers and eval crossed out inside a script box; host functions are the only way out
A script has no fetch, files, timers or eval unless the host passes something in. Illustration: Sulat. Source: psychoscript README

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

Hand-drawn checklist: timeout off by default, no memory limit, one regex can run long, snapshots act like code
Four limits from the README to settle before running untrusted code. Illustration: Sulat. Source: psychoscript README

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.

Hand-drawn bars: Rust port starts in 2 ms against 68 ms, runs a program in 0.027 ms against 0.114 ms, peaks at 20 MiB against 119
The Rust port’s own benchmark: 34x faster to start, 4.3x faster per program. Illustration: Sulat. Source: psychoscript repository

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.

OptionIsolationWhat stands out
PsychoscriptLanguage level, in your processSuspend, save and resume; MIT; tied to Code Mode
Cloudflare Dynamic WorkersV8 isolatesCloudflare reported cutting a 1.17 million token tool surface to about 1,000 tokens, a 99.9% saving
Anthropic’s code execution with MCPSandboxed executionAnthropic’s write-up cut a 150,000 token workflow to 2,000, a 98.7% saving
Pydantic MontyA Python subset written in RustSubprocess workers, memory and time limits, snapshots
isolated-vmV8 isolates inside NodeA long-standing way to run untrusted JavaScript in Node
QuickJS in WebAssemblyWASM sandboxA small JavaScript engine compiled to WebAssembly
Vercel SandboxmicroVMA full isolated machine for code, rather than a language-level sandbox
The token savings come from different setups and aren’t comparable with each other. They measure how much tool description the model reads, not how fast the interpreter runs.

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

  1. Switch the limits on. Set timeoutMs and maxOutputBytes yourself, because both default to off.
  2. Pin the build. Snapshots only resume on the build that wrote them, so pin the version if you store them.
  3. Make host calls safe to repeat. A resumed run can repeat an idempotent call.
  4. Treat snapshots as code. Only resume ones you made.
  5. Add a process boundary for hostile code. One regular expression can hang the interpreter.
  6. 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.