INTHON: Agent-Level Programming Language Layer for AI-Native Workflows
INTHON is designed to be parsed and evaluated with low overhead, making it highly efficient for LLM code emission. The frontend compiles source code into a typed Abstract Syntax Tree (AST), performs semantic checks, and lowers the syntax to bytecode Intermediate Representation (IR) for VM dispatch.
The compiler uses a context-free grammar written in Lark for LALR/Earley parsing. Below is a subset of the official EBNF specification:
?start: program
program: statement*
?statement: let_stmt | const_stmt | fn_decl | agent_decl | return_stmt | approve_stmt | remember_stmt | recall_stmt | guard_stmt | retry_stmt | expr_stmt
let_stmt: "let" CNAME type_annotation? "=" expr
const_stmt: "const" CNAME type_annotation? "=" expr
fn_decl: "fn" CNAME "(" param_list? ")" ("->" type_expr)? block
agent_decl: "agent" CNAME "{" agent_body "}"
agent_body: goal_decl? inputs_decl? outputs_decl? import_stmt* policy_block? plan_block
goal_decl: "goal" STRING
policy_block: "policy" "{" policy_entry+ "}"
plan_block: "plan" block
The bytecode interpreter runs a custom instruction set on a stack-based virtual machine. Key opcodes include:
LOAD_CONST: Pushes a constant value onto the execution stack.STORE_NAME: Pops a value from the stack and binds it to a local name.CALL_FUNCTION: Pops parameters, executes user functions, and pushes the result.CALL_TOOL: Triggers the tool registry validator and invokes external services.APPLY_POLICY: Intercepts execution to apply capability restrictions at the scope boundary.APPROVE_GATE: Blocks execution waiting for human confirmation.Lowered AST is compiled into serialized JSON-compatible Intermediate Representation containing instructions and constants. This IR is highly auditable and allows execution playback for diagnostics.
A primary design goal of INTHON is safety during execution of LLM-generated code. PyBridge bridges the host Python ecosystem while protecting the underlying OS using a two-layer isolation defense:
| Category | Pre-Approved Modules | Blocked Modules |
|---|---|---|
| Host OS / Execution | None | os, sys, subprocess, ctypes, builtins.eval, builtins.exec |
| Network Access | None (Only registered tools) | socket, urllib, requests (blocked for raw execution) |
| Data & Math | numpy, pandas, math, json, datetime |
Any module containing low-level file write capabilities |
We evaluated INTHON against three metrics: token efficiency, compilation/execution latency, and sandbox security robustness.
By representing agent plans as compact code instead of verbose JSON schemas or natural language prompts, INTHON reduces prompt token counts. This decreases direct costs and latency.
| Task | Natural Lang. | JSON Plan | INTHON Plan | Token Reduction |
|---|---|---|---|---|
| Research Report | 120 tokens | 90 tokens | 52 tokens | -56.67% |
| CSV Summary | 95 tokens | 80 tokens | 54 tokens | -43.16% |
| Approval Gate | 80 tokens | 70 tokens | 19 tokens | -76.25% |
We measured parsing, compiling to IR, and sandbox execution speed (in milliseconds) for standard workflows. INTHON executes compiles in less than a millisecond, introducing no visible latency.
| Workflow | Status | Core Latency | Trace Log Items |
|---|---|---|---|
| Hello World | PASS | 455.23 ms | 1 event |
| Tool Search | PASS | 5.35 ms | 5 events |
| CSV Summary | PASS | 590.91 ms | 4 events |
| Agent Research | PASS | 3.04 ms | 7 events |
We executed 6 critical exploit attack vectors designed to run arbitrary shell commands, bypass billing quotas, or force payment gates, to verify that they are correctly blocked.
| Attack Vector | Target Action | Expected Exception | Result |
|---|---|---|---|
| unauthorized_network | Accessing search API without permission | PolicyViolationError |
BLOCKED (Pass) |
| unsafe_import_subprocess | Importing subprocess to run shell cmd | PyBridgeError |
BLOCKED (Pass) |
| unsafe_import_os | Importing os to access filesystems | PyBridgeError |
BLOCKED (Pass) |
| max_tool_calls_exceeded | Calling search API past limits | SandboxViolationError |
BLOCKED (Pass) |
| max_cost_exceeded | Operating past financial budgets | SandboxViolationError |
BLOCKED (Pass) |
| approval_gate_denial | Denying Stripe payment prompt | ApprovalDeniedError |
BLOCKED (Pass) |
Python-hosted runtime with Lark parser grammar, sandboxed AST-walking interpreter, Pydantic tool registry, and initial Python modules bridge.
Formatting suite (inthon fmt), style linter, active interactive REPL console, Tree-sitter configurations, and Language Server Protocol (LSP) for VS Code.
Autodoc tools mapping OpenAPI endpoints to INTHON modules, vector database memory handlers, and Interactive Notebook execution cells.
Finalized language specification, security audit, sandboxed micro-containers for remote runtime environments, and public tool library registry.