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.
Closing the "Procedural Gap"
Every major breakthrough in LLM infrastructure has solved a distinct architectural bottleneck. Until now, no framework addressed why production agents re-reason through deterministic, identical steps every single turn.
Live Mission Control & Observability Console
Inspect real-time tokenomics, intelligent model routing, 4-tier memory capacities (Procedural, Semantic, Episodic, Working), and the interactive Knowledge Graph. Zero headless mystery.
| Turn ID | User Intent | Execution Path | Billed | Saved | Turn Latency | Status |
|---|---|---|---|---|---|---|
| #TRN-9402 | Calculate closed-won revenue for Europe |
COMPILED_AST | 0 tok ($0.00) | +$0.0074 | 82 µs | ✅ HIT (Verified) |
| #TRN-9401 | Analyze customer churn for Mid-Market segment |
COMPILED_AST | 0 tok ($0.00) | +$0.0092 | 79 µs | ✅ HIT (Verified) |
| #TRN-9400 | Synthesize new multi-region compliance summary |
LLM_REASONING | 1,820 tok ($0.014) | $0.0000 | 1,940 ms | ⚡ COMPILED NEW AST |
| Model Name | Provider | Blended / 1M Tokens | Calls | Tokens Incurred | Tokens Bypassed | Net Saved |
|---|---|---|---|---|---|---|
| Claude 3.7 Sonnet | Anthropic | $9.00 / M | 420 | 184,200 | 1,120,000 | +$756.00 |
| GPT-4o | OpenAI | $6.25 / M | 380 | 158,100 | 980,000 | +$487.50 |
| Gemini 2.0 Flash | Google DeepMind | $0.25 / M | 940 | 198,950 | 318,920 | +$184.90 |
| In-Process Llama 3.2 SLM | Local TorchProvider | $0.00 / M (MPS) | 1,840 | 0 (Local RAM) | — | +$0.00 (Zero Cost) |
| Procedure Signature | Intent Matcher | Executions | Success Rate | Reliability | Action |
|---|---|---|---|---|---|
crm_closed_won_revenue(region: str) |
"Calculate enterprise sales revenue for {region}" | 412 | 100.0% | RELIABLE | |
compute_churn_ltv(segment: str) |
"Compute customer churn and LTV for {segment}" | 289 | 100.0% | RELIABLE | |
carrier_delay_vs_returns(carrier: str) |
"Analyze delivery delay vs return rate for {carrier}" | 198 | 100.0% | RELIABLE | |
inventory_reorder_trigger(sku: str) |
"Check inventory reorder safety threshold for {sku}" | 84 | 98.8% | RELIABLE |
sql_repl_engineinv:RegionEnument:SalesforceOpportunitydef crm_closed_won_revenue(region: str) -> dict:
query = f"SELECT SUM(amount) FROM opps WHERE region='{region}'"
res = sql_engine.execute(query)
return {"amount": res[0][0], "status": "verified"}
Token Savings & ROI Calculator
Model reasoning is an upfront compilation investment. Input your monthly LLM spend to calculate amortized savings from procedural execution.
Drop-In FastAPI & ASGI Middleware
Add SemanticHarnessMiddleware to any existing Python backend in 3 lines of code. Automatically intercepts API routes, checks compiled procedural memory, and adds transparent cost-saving headers.
from fastapi import FastAPI
from pydantic import BaseModel
from semantic_harness.integrations.fastapi import (
SemanticHarnessMiddleware,
procedural_route,
)
app = FastAPI(title="Enterprise Agent Backend")
# 1. Add middleware to intercept and accelerate agent endpoints
app.add_middleware(
SemanticHarnessMiddleware,
cache_paths=["/api/v1/agent", "/api/v1/generate"],
pricing_model="gpt-4o",
)
class AnalysisOutput(BaseModel):
summary: str
action_items: list[str]
# 2. Or decorate specific routes with procedural validation
@app.post("/api/v1/agent")
@procedural_route(validates=AnalysisOutput, cache=True)
async def run_agent_workflow(payload: dict):
# Executes once via LLM; repeat calls execute at $0 in <1ms!
return await my_agent_core.run(payload["query"])
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.
# 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)
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.
Unified 5-Layer Stack
Decoupled hierarchy bridging probabilistic reasoning models with deterministic execution engines.
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.
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.
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).
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).
Multi-Provider Inference Layer
Universal model interoperability across local Ollama SLMs (Qwen, Gemma), vLLM engines, and cloud providers (OpenAI, Anthropic, Gemini).
Research Figures & Benchmark Data
Evaluated across 89 verified unit test suites, a 48-turn enterprise runtime stream, and a 200-turn relational SQL benchmark.
Drop-In Usage Recipes
Get started with one decorator, or build object-oriented stateful agents.
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)
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)
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}`);
}
}
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
Citation & Zenodo DOI
Semantic Harness is archived on Zenodo with an open-access Digital Object Identifier.
Semantic Harness: Cognitive Middleware, Procedural Acceleration, and Layered Runtime Architecture for Autonomous AI Agents
@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.5},
doi = {10.5281/zenodo.19414309},
url = {https://zenodo.org/records/19414309}
}