Documentation

Full language reference, compiler architecture, and quick start guides.

SkCC

Skills Compiler — compile agent skills into optimized runtime modules.

EvoBench

Agent benchmark suite — measure and compare autonomous agent performance.

EpiContext

Evolutionary context management — genetic algorithms for optimal context windows.

Nexa Organization

GitHub organization with all Nexa projects and repositories.

Author

Owen — creator of the Nexa language and Harness Native methodology.

v2.3.1 — Terminal UI + CJK Input

The First
Harness Native
Agent Language

Nexa is the first Harness Native Agent Language — where agent safety is enforced by the compiler, not by runtime frameworks. Write flows, not glue code.

pip install nexa
bugfixer.nx — Harness Native
// Nexa — Harness Native Agent Language
agent BugFixer(issue: string) {
    system `Fix: #{issue}`

    // Harness C: Context policy
    context_policy {
        max_tokens: 100000,
        on_overflow: summarize
    }

    // Harness E: Autonomous loop
    autoloop max_steps: 50 exit_when: "resolved" {
        // Harness L: AI-native error recovery
        try_agent {
            step();
        } catch_correction(e: ToolError) {
            reflect `Error: #{e}. Retry.`
        }
    }
}
Harness C: compiler-verified context eviction
Harness E: compiler-verified exit condition
Harness L: AI-native self-correction

A Language Designed for Agents,
Not Adapted for Them

Every other "agent framework" is a library bolted onto a general-purpose language. Nexa is built from the ground up with the Harness Native methodology — agent safety, context management, and autonomous execution as first-class language constructs.

Harness Native Syntax

Agents, tools, protocols, and flows are first-class citizens — not library wrappers. The Harness six-tuple (E, T, C, S, L, V) is enforced at the language level.

Compiler-Enforced Safety

26 Harness Validator rules check your code at compile time. Missing exit conditions, untyped tools, context overflow risks — caught before a single line runs.

DAG Orchestration

Native fork, merge, pipeline, and conditional branch operators. Compose complex agent workflows as directed acyclic graphs with zero boilerplate.

Gradual Type System

From forgiving to strict — choose your safety level. Structural types, semantic types, Option/Result types, and compile-time protocol verification.

1,800+ Tests

Battle-tested across 16+7 major features. v1.x: Design by Contract, Error Propagation, Pattern Matching, ADTs, Background Jobs, HTTP Server, Database, Auth. v2.0: Harness Native Runtime with autoloop, @tool, with_context, snapshot, reflect, verify, Actor. v2.1: optional Anthropic SDK adapter, hardened runtime (shell=False, path allowlist, safe_eval), and grammar fixes for semantic_if fast_match colon form.

AVM Runtime

A Rust-powered Agent Virtual Machine with WASM sandboxing, COW memory, context paging, and work-stealing scheduler — 20× faster than Python transpilation.

Harness Native — Safety by Design

In Nexa, the Harness six-tuple (E, T, C, S, L, V) is enforced at the language level. The compiler verifies exit conditions, context policies, and error recovery — before a single line runs.

bugfixer.nx — 18 lines, compiler-verified safety
// Nexa — Harness Native Agent Language
@tool("Search codebase with regex")
fn grep(pattern: string, path: string = "."): string {
    return std.shell.exec("grep -rn #{pattern} #{path}");
}

agent BugFixer(issue: string) uses grep {
    system `You are an expert engineer. Fix: #{issue}`

    // Harness C: compiler verifies eviction strategy exists
    context_policy { max_tokens: 100000, on_overflow: summarize }

    // Harness E: compiler verifies exit condition exists
    autoloop max_steps: 50 exit_when: "issue is resolved" {
        // Harness L: AI-native error self-correction
        try_agent { step(); }
        catch_correction(e: ToolError) { reflect `Error: #{e}. Retry.` }
    }
}
Harness C — Context Manager
The context_policy block is compiler-verified. If you forget to specify max_tokens or an on_overflow strategy, the Harness Validator rejects your code at compile time — before a single token is sent to the LLM. No more silent context window overflows that degrade model performance mid-task.
Harness E — Execution Loop
autoloop is a first-class language construct, not a while-loop with manual bookkeeping. The compiler enforces that every loop has an exit_when condition or max_steps limit. Infinite agent loops are caught at build time, not discovered at 3 AM when your cloud bill arrives.
Harness L — Lifecycle Hooks
try_agent + catch_correction implements AI-native error recovery. When a tool fails, the error is automatically fed back to the LLM via reflect — triggering self-correction instead of crash-and-burn. Traditional try-catch walks away; Harness L teaches the agent to try again, smarter.
bugfixer.py — 55+ lines, no compile-time safety
# Python + LangGraph — manual glue code
from langgraph.graph import StateGraph, END
from langchain.chat_models import ChatOpenAI
from langchain.tools import tool
import subprocess, json

# Manual tool schema — must match OpenAI format exactly
@tool
def grep(pattern: str, path: str = ".") -> str:
    """Search codebase with regex"""
    r = subprocess.run(["grep","-rn",pattern,path],capture_output=True)
    return r.stdout.decode()

# Manual context management — no auto-eviction
def manage_context(messages, max_tokens=100000):
    total = sum(len(m["content"])//4 for m in messages)
    if total > max_tokens * 0.8:
        return messages[:5] + messages[-3:]  # crude truncation
    return messages

# Manual ReAct loop — no exit condition verification
def bug_fixer(issue: str, max_steps=50):
    model = ChatOpenAI(model="minimax-m2.5")
    messages = [{"role":"system","content":f"Fix: {issue}"}]
    for step in range(max_steps):
        response = model.invoke(messages, tools=[grep])
        messages.append({"role":"assistant","content":response.content})
        if response.tool_calls:
            for tc in response.tool_calls:
                try:
                    result = tc.execute()
                    messages.append({"role":"tool","content":result})
                except Exception as e:
                    messages.append({"role":"tool","content":f"Error: {e}"})
        messages = manage_context(messages)
        if "resolved" in response.content.lower(): break
    return messages[-1]["content"]
# No Harness Validator. No sandbox. No trace. No HITL.

Less Code, More Intent

Multi-agent DAG orchestration that takes 40+ lines of Python takes just 8 lines of Nexa — with compiler-verified topology.

pipeline.nx — 8 lines
// Nexa — declarative DAG orchestration
agent Researcher { prompt: "Research the given topic." }
agent Analyst   { prompt: "Analyze findings quantitatively." }
agent Writer    { prompt: "Synthesize into a report." }
agent Reviewer  { prompt: "Review for accuracy." }

flow main(topic: string) {
    // Fork: parallel research + analysis → Merge: review → Pipeline: write
    result = topic |>> [Researcher, Analyst] &>> Reviewer >> Writer;
    print(result);
}
Fork — |>> [A, B]
Parallel fan-out to multiple agents with a single operator. The compiler statically verifies that every target in the fork list is a declared agent — no runtime NameError surprises. Results are collected concurrently with automatic thread pooling.
Merge — &>> C
Combine parallel results into a single downstream agent. Choose your strategy: concat (append all), vote (majority selection), consensus (LLM-mediated agreement), or summarize (intelligent compression). The compiler verifies the merge target exists.
Pipeline — >> D
Sequential chaining with automatic type propagation. Output flows left-to-right through each agent. The compiler traces the full pipeline to verify every hop connects a valid agent — catching broken chains before execution.
DAG Topology — Compiler-Verified
Unlike LangGraph's runtime graph construction, Nexa DAG operators are validated at compile time. The compiler checks for cycles, verifies all node references, and ensures the topology is well-formed — eliminating an entire class of runtime orchestration bugs.
pipeline.py — 40+ lines
# Python + LangGraph — manual DAG construction
from langgraph.graph import StateGraph, END
from langchain.chat_models import ChatOpenAI
from typing import TypedDict
import concurrent.futures

model = ChatOpenAI(model="minimax-m2.5")

class State(TypedDict):
    topic: str; research: str; analysis: str; review: str; report: str

def research_node(state: State) -> State:
    state["research"] = model.invoke(f"Research: {state['topic']}")
    return state

def analysis_node(state: State) -> State:
    state["analysis"] = model.invoke(f"Analyze: {state['topic']}")
    return state

def review_node(state: State) -> State:
    combined = state["research"] + "\n" + state["analysis"]
    state["review"] = model.invoke(f"Review: {combined}")
    return state

def writer_node(state: State) -> State:
    state["report"] = model.invoke(f"Write report: {state['review']}")
    return state

# Manual graph construction — 15+ lines of wiring
graph = StateGraph(State)
graph.add_node("research", research_node)
graph.add_node("analysis", analysis_node)
graph.add_node("review", review_node)
graph.add_node("writer", writer_node)
graph.add_edge("research", "review")
graph.add_edge("analysis", "review")
graph.add_edge("review", "writer")
graph.set_entry_point("research")
graph.add_edge("writer", END)
app = graph.compile()
result = app.invoke({"topic": "Quantum Computing"})
# No compile-time topology verification

From Source to Execution

Nexa compiles through a multi-stage pipeline with Harness validation — ensuring safety before a single line runs.

.nx Source

Harness Native DSL

Lark Parser

Earley Algorithm

AST Transformer

Desugaring + Scoring

Harness Validator

Compile-time Safety

Code Generator

Python / AVM / WASM

23+
Core Features
1,935
Tests Passed
12+4
v2.0 + v2.1 Examples
20×
AVM vs Python Speed

Six Dimensions. One Language. Compiler-Verified.

The Harness six-tuple is not a framework — it's syntax, enforced by the compiler.

E — Execution
autoloop max_steps: 10, exit_when: "resolved" { ... }

Autonomous ReAct loop with compiler-enforced exit conditions. No more infinite agent loops.

T — Tool
@tool("description") fn my_tool(x: string): string { ... }

Zero-cost tool binding. Compiler auto-generates OpenAI function calling schema from type signature.

C — Context
with_context max_tokens: 50000, strategy: sliding_window { ... }

Importance-weighted context paging. Silent context overflow degraded performance — eliminated at language level.

S — State
snap = snapshot(); ... restore(snap);

COW state snapshots with fork/merge for Tree-of-Thoughts exploration. Roll back decisions as a primitive.

L — Lifecycle
before_step { ... }; reflect "What went wrong?";

Compiler-enforced lifecycle hooks + AI-native self-reflection. Agents learn instead of crashing.

V — Verify
verify result satisfies ExpectedOutput;

Compile-time + runtime output verification with multi-model routing. Quality is a language property.

Ready to Build the Future of Agents?

Join us in making agent programming safe, declarative, and beautiful — with the Harness Native methodology.