Verified Semantic Compilation DOI: 10.5281/zenodo.19414309

Zero-token procedural execution for
autonomous AI agents

Semantic Harness compiles multi-turn LLM reasoning loops into deterministic, type-safe Python AST procedures. Re-execute recurring enterprise workflows in microseconds at 0 model tokens with 100% parameter accuracy.

21.2%
Token Reduction
Across mixed enterprise streams ($p = 0.005$)
0 Tokens
Warm-Path Cost
Compiled AST execution in Python REPL
80.3 µs
Sub-Millisecond Speed
>600× faster than raw inference (~9s)
100.0%
Parameter Accuracy
0 stale errors vs. 18 in traditional vector caches
Interactive Playground

See the Execution Difference

Click any quick scenario or customize parameters to see how Semantic Harness compiles and re-executes verified ASTs compared to standard LLMs and traditional vector caches.

Quick Scenarios:
1
Exact Hash
2
PolarQuant Match
3
AST Slot Binding
4
Python REPL Exec
5
Live Output
1. Stateless LLM
Full Inference
Tokens Billed: 260 tokens
Turn Latency: 9,081 ms
Inference Cost: $0.0039
Returned Value:
$300,000
✅ Valid Output (~9s delay)
2. Semantic Vector Cache
Response-Level
Tokens Billed: 0 tokens
Turn Latency: 915 ms
Accuracy Rate: 62.5%
Returned Value:
$44,410,000
❌ STALE DATA ERROR
3. Semantic Harness
Verified AST
Tokens Billed: 0 tokens ($0.00)
Turn Latency: 1.1 ms (80.3 µs)
Accuracy Rate: 100.0% Verified
Returned Value:
$300,000
✅ Live AST Execution (0 Tokens)
Live Sandboxed AST & REPL Execution Trace
Zero Model Tokens
# Step 1: Inbound Request -> "Calculate total closed won revenue for Europe region"
# Step 2: TurboQuant PolarQuant Fuzzy Match (Similarity: 0.94, Confidence: 0.92 >= 0.85)
# Step 3: Parameter Slot Binding -> params = {'region': 'Europe', 'stage': 'Closed Won'}
# Step 4: Python REPL Exec -> execute_ast(crm_revenue_ast, params=params)
# Step 5: Live Database Result -> {"revenue": 300000.0, "region": "Europe"} (1.12 ms)
Core Innovations

The Four Architectural Pillars

How Semantic Harness combines verified execution contracts with extreme vector compression.

1. Verified Semantic Compilation

Treats multi-turn LLM reasoning as a JIT program synthesis step. Once verified against Pydantic schema contracts, execution paths are compiled into parameterized ASTs for zero-token re-execution.

2. Chaos2Clarity (C2C) Self-Healing

Intercepts schema validation failures and synthesizes minimal, targeted differential prompts. Elevates Small Language Model (≤3B) structured output pass rates from 41.2% to 96.8%.

3. Google TurboQuant / PolarQuant

Compresses continuous procedural intent vectors by $8\times\text{--}16\times$ using random orthogonal polar transforms with QJL 1-bit residual correction for unbiased sub-microsecond retrieval.

4. ACT-R Cognitive 3-Tier Memory

Integrates a sliding Short-Term FIFO buffer, an embedded Long-Term SQLite datastore ranked by ACT-R cognitive activation equations $A_i(t)$, and quantized procedural caching.

System Architecture

Unified 5-Layer Stack

Decoupled hierarchy bridging probabilistic reasoning models with deterministic execution engines.

Layer 1

DeepSeek Harness (DSH) — Lifecycle & Governance

Waterfall event pipeline (turn/start → step/start → step/end → turn/end) with immutable append-only JSONL session logging and proactive loop guards.

Layer 2

NVIDIA Object-Oriented Agents (NOOA) — Execution Model

Class-as-Agent contracts with docstring prompt binding and a stateful, sandboxed CodeAct Python REPL for persistent multi-turn variables and AST capture.

Layer 3

Semantic Harness Core — Cognitive Middleware & C2C

Deterministic Pydantic validation, dynamic context token budgeting, and the Beta-Bernoulli conjugate reliability gate for safe fast-path routing ($0.00\%$ False Reuse Rate).

Layer 4

Google TurboQuant / PolarQuant — Vector Compression

1-Bit polar vector quantization and fast Walsh-Hadamard transforms enabling CPU bitwise XOR search ($1.5\ \mu\text{s}$ per query).

Layer 5

Multi-Provider Inference Layer

Universal model interoperability across local Ollama SLMs (Qwen, Gemma), vLLM engines, and cloud providers (OpenAI, Anthropic, Gemini).

Empirical Evaluation

Research Figures & Benchmark Data

Evaluated across 89 verified unit test suites, a 48-turn enterprise runtime stream, and a 200-turn relational SQL benchmark.

Token Avoidance Distribution
Figure 1: Token & Latency Avoidance Distribution. Demonstrates 21.16% total token avoidance across the mixed stream ($p = 5.06 \times 10^{-3}$ on Wilcoxon signed-rank test), with 100% token cost reduction on warm procedural hits.
Signature Parameter Experiment
Figure 2: The Signature Experiment. Traditional semantic vector caches suffer 18 stale-data errors (accuracy drops to 62.5%) when parameters change. Semantic Harness re-executes compiled ASTs with new arguments at 100.0% accuracy and 0 tokens.
Speedup Pareto Frontier
Figure 3: Latency-Accuracy Pareto Frontier. Shows execution speedup across recurring business intelligence workflows, achieving $80.3\ \mu\text{s}$ average latency (>500× speedup) on warm procedural paths.
Error Taxonomy Distribution
Figure 4: Formal 5-Class Error Taxonomy Suppression. Schema hallucinations ($E_1$) drop from 38.0% down to 6.0% ($-84.2\%$ relative reduction) via C2C type enforcement ($\chi^2 = 12.25, p = 0.00047$).
Longitudinal Learning Curve
Figure 5: 200-Turn Longitudinal Procedural Learning. Non-parametric session learning evolves first-pass execution success from 50.0% up to 86.0% as verified procedures are cached.
Integration Guide

Drop-In Usage Recipes

Get started with one decorator, or build object-oriented stateful agents.

step_decorator_example.py
from pydantic import BaseModel
from semantic_harness import step

class RevenueReport(BaseModel):
    region: str
    total_revenue: float
    deal_count: int

# Validates Pydantic schema and compiles procedural fast-path
@step(validates=RevenueReport, cache=True)
def get_regional_sales(region: str) -> dict:
    prompt = f"Extract revenue figures for {region} from current pipeline."
    return llm_client.generate_json(prompt)

# Turn 1 (Cold): Calls LLM -> Validates schema -> Compiles AST logic
report1 = get_regional_sales(region="North America")

# Turn 2 (Warm): Re-executes AST in REPL -> 1.1 ms response, 0 TOKENS billed!
report2 = get_regional_sales(region="Europe")
print(report2)
financial_analyst_agent.py
from semantic_harness import Agent, AgentConfig

class FinancialAnalyst(Agent):
    """You are an autonomous corporate financial analyst."""

    def calculate_margin(self, revenue: float, cost: float) -> float:
        """Compute gross profit margin percentage."""
        return ((revenue - cost) / revenue) * 100.0

agent = FinancialAnalyst(config=AgentConfig(model="qwen2.5-coder:3b", strategy="codeact"))

# Store enterprise metadata with ACT-R importance ranking
agent.long_term.remember(
    key="q4_targets",
    content="Q4 revenue target is $100M with max operating expense of $65M.",
    importance=0.95
)

# Run multi-turn task with persistent CodeAct variables
result = agent.run("Evaluate projected Q4 EBITDA margin based on target figures.")
print(result)
agent.ts
import { Agent, step } from "semantic-harness";
import { z } from "zod";

const UserProfileSchema = z.object({
  userId: z.number(),
  name: z.string(),
  activeSubscription: z.boolean(),
});

export class CustomerSupportAgent extends Agent {
  @step({ schema: UserProfileSchema, cache: true })
  async lookupUser(email: string) {
    // Re-executes verified AST without token inference on warm paths
    return await this.callLLM(`Fetch structured profile for ${email}`);
  }
}
langgraph_node.py
from semantic_harness import ProceduralMemory, C2CValidator

proc_mem = ProceduralMemory(enable_fuzzy_search=True)

def validated_tool_node(state):
    intent = state["current_intent"]
    
    # 1. Zero-Token Fast Path Check
    cached_proc = proc_mem.lookup(intent)
    if cached_proc and cached_proc.is_reliable:
        state["result"] = cached_proc.execute(state["params"])
        state["tokens_used"] = 0
        return state

    # 2. Standard LLM Execution + C2C Validation
    raw_output = call_llm(state["prompt"])
    state["result"] = C2CValidator(state["schema"]).validate(raw_output)
    proc_mem.cache(intent, state["result"])
    return state
Academic Research

Citation & Zenodo DOI

Semantic Harness is archived on Zenodo with an open-access Digital Object Identifier.

Academic Paper Published v0.2.3

Semantic Harness: Cognitive Middleware, Procedural Acceleration, and Layered Runtime Architecture for Autonomous AI Agents

Author: Bankupalli Ravi Teja • Affiliation: Independent Research / Open Source Systems

BibTeX Citation
@article{bankupalli2026semanticharness,
  author       = {Bankupalli, Ravi Teja},
  title        = {{Semantic Harness: Cognitive Middleware, Procedural Acceleration, and Layered Runtime Architecture for Autonomous AI Agents}},
  year         = {2026},
  month        = {August},
  journal      = {arXiv preprint},
  publisher    = {Zenodo},
  version      = {0.2.3},
  doi          = {10.5281/zenodo.19414309},
  url          = {https://zenodo.org/records/19414309}
}