<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hoàn Lương</title>
    <description>The latest articles on Forem by Hoàn Lương (@hoanluong123).</description>
    <link>https://forem.com/hoanluong123</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3950758%2F3aa5381a-a0c9-4c32-8919-1a5da59883f7.png</url>
      <title>Forem: Hoàn Lương</title>
      <link>https://forem.com/hoanluong123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hoanluong123"/>
    <language>en</language>
    <item>
      <title>We built a scripting language just for AI agents. Here's why.</title>
      <dc:creator>Hoàn Lương</dc:creator>
      <pubDate>Mon, 25 May 2026 13:41:22 +0000</pubDate>
      <link>https://forem.com/hoanluong123/we-built-a-scripting-language-just-for-ai-agents-heres-why-1gm9</link>
      <guid>https://forem.com/hoanluong123/we-built-a-scripting-language-just-for-ai-agents-heres-why-1gm9</guid>
      <description>&lt;p&gt;One of our AI agents deleted a directory it was never supposed to touch. The Python it wrote was valid. The model was confident. It did the wrong thing.&lt;/p&gt;

&lt;p&gt;The agent was only supposed to query a database. But we gave it a full Python runtime, so it had access to &lt;code&gt;os&lt;/code&gt;, &lt;code&gt;shutil&lt;/code&gt;, everything. That's when we realized the problem wasn't the model — it was us handing it way too much power.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why sandboxing is harder than it looks
&lt;/h2&gt;

&lt;p&gt;The usual options aren't great:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full runtime (Python/Node.js):&lt;/strong&gt; easy to set up, hard to lock down properly. Restricting it after the fact is whack-a-mole.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker per agent:&lt;/strong&gt; proper isolation, but ~200ms cold start and 100MB+ RAM each. At 50 concurrent agents that's 5GB just idling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We wanted something lighter. Not "restricted Python" — something designed from scratch for how AI actually writes code.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI code has a specific profile
&lt;/h2&gt;

&lt;p&gt;After running a lot of agent scripts in production, the pattern is pretty consistent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Under 100 lines almost always&lt;/li&gt;
&lt;li&gt;Runs frequently, not once&lt;/li&gt;
&lt;li&gt;Doesn't need filesystem, network, or OS access&lt;/li&gt;
&lt;li&gt;Tends to produce infinite loops, wrong types, null accesses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;General-purpose languages aren't built for this. So we built &lt;strong&gt;Autolang&lt;/strong&gt; — a small scripting VM where AI can only call functions you explicitly registered. Nothing else is reachable.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AI writes Autolang script
    → static compiler validates types and scope
        → your registered JS / C++ functions do the actual work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You wrap your existing functions as bindings. The AI calls those. That's it. It can't reach outside what you've registered.&lt;/p&gt;

&lt;p&gt;Here's a real example — register a database binding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;compiler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;registerBuiltInLibrary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;company/products&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`
  class Product (val name: String, val price: Int, val inStock: Bool)
  class Database {
    @native("get_products")
    static func get_products(): Array&amp;lt;Product&amp;gt;
  }
`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;autoImport&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get_products&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;fetchFromYourDB&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI then writes something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"company/products"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;affordable&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_products&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;{|&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inStock&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;affordable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt; &lt;span class="p"&gt;{|&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nf"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"- ${p.name}: $${p.price}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It can't touch anything outside &lt;code&gt;company/products&lt;/code&gt;. If it writes an infinite loop, the opcode limit kills it before it hangs your process.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Native&lt;/th&gt;
&lt;th&gt;npm&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cold start&lt;/td&gt;
&lt;td&gt;~10ms&lt;/td&gt;
&lt;td&gt;~20ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Warm start&lt;/td&gt;
&lt;td&gt;1–2ms&lt;/td&gt;
&lt;td&gt;2–4ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RAM per instance&lt;/td&gt;
&lt;td&gt;~4MB&lt;/td&gt;
&lt;td&gt;~12MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;50 concurrent agents: ~200MB total. Docker would be 5GB+.&lt;/p&gt;

&lt;h2&gt;
  
  
  When it makes sense
&lt;/h2&gt;

&lt;p&gt;Good fit if you're running 5+ concurrent agents, scripts are short and frequent, and you want controlled access to existing functions without rewriting them.&lt;/p&gt;

&lt;p&gt;Probably not worth it if you have only a handful of agents, need OS-level security guarantees, need Python bindings (not ready yet), or your AI writes long complex programs.&lt;/p&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;autolang-compiler
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Github: &lt;a href="https://github.com/hoansdz/Autolang" rel="noopener noreferrer"&gt;https://github.com/hoansdz/Autolang&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Philosophy: &lt;a href="//autolang.vercel.app/docs/philosophy-vision"&gt;autolang.vercel.app/docs/philosophy-vision&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Live editor: &lt;a href="//autolang.vercel.app/docs/editor"&gt;autolang.vercel.app/docs/editor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Curious how others are handling this. What's your current setup for sandboxed agent code?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cpp</category>
      <category>llm</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
