Skip to content

About

Deterministic Intent Compiler & Typed DAG Execution Planner for Autonomous AI Agents & Model Context Protocol (MCP)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation


Tests Python Dependencies MCP Native License: MIT Benni OS


Deterministic Intent Compiler & Typed DAG Execution Planner for Autonomous AI Agents & MCP Servers.
Eliminates prompt injection, hallucinated tool calls, and redundant token waste by compiling natural language into typed, cryptographically-sealed execution graphs before invoking LLMs.


agent-intent-compiler Deterministic Intent & DAG Execution Demo

⚡ The Problem: The Unstructured Prompt Injection Tax

In 2026, autonomous agent frameworks like LangChain, AutoGen, and CrewAI feed raw, ambiguous user strings directly into multi-step LLM reasoning loops.

This creates four critical failure modes in production:

  1. Indirect Prompt Injection & Jailbreaks: Hidden zero-width characters or adversarial override payloads ("ignore previous instructions") hijack agent tool chains.
  2. Hallucinated Tool Parameters: LLMs generate invalid JSON or missing required arguments, resulting in catastrophic runtime exceptions mid-pipeline.
  3. Loop Runaways & Token Burn: Agents spend hundreds of tokens debating which tool to call sequentially when tasks could be grouped and executed in parallel.
  4. Lack of Non-Repudiation: There is no cryptographic audit proof verifying whether an executed tool call actually matched the user's intended request.

🛡️ The Solution: agent-intent-compiler

agent-intent-compiler acts as a Deterministic Pre-Execution Compiler situated between user inputs and agent runtimes.


🏗️ Architecture

  User Prompts / Agent Frameworks / MCP Clients
         │
         ├──► Python API  IntentCompiler.compile(prompt)
         └──► CLI / JSON  agent-intent-compiler "<prompt>"
                       │
                       ▼
  ┌─────────────────────────────────────────────────────────────────────┐
  │                       agent-intent-compiler                         │
  │                                                                     │
  │  ┌───────────────────┐  ┌───────────────────┐  ┌─────────────────┐  │
  │  │ Prompt Sanitizer  │  │  Typed Intent &   │  │ Kahn's DAG      │  │
  │  │ • Zero-Width      │─►│  Slot Compiler    │─►│ Planner         │  │
  │  │   Strip           │  │  • Query/Mutation │  │ • Cycle Guard   │  │
  │  │ • Entropy Shield  │  │  • Research/Eval  │  │ • Parallel      │  │
  │  └───────────────────┘  └───────────────────┘  │   Stages        │  │
  │                                                └─────────────────┘  │
  │  ┌───────────────────┐  ┌───────────────────┐  ┌─────────────────┐  │
  │  │ SHA-256 Merkle    │  │  MCP JSON-RPC 2.0 │  │ Live Telemetry  │  │
  │  │ Execution Seal    │  │  Adapter          │  │ & Doctor /      │  │
  │  │ • Non-Repudiation │  │  • tools/call     │  │ Bench Matrix    │  │
  │  └───────────────────┘  └───────────────────┘  └─────────────────┘  │
  └─────────────────────────────────────────────────────────────────────┘
         │                                         │
         ▼                                         ▼
   Cryptographic ExecutionPlan               MCP Tool Runtime
   (Staged Nodes + Merkle Root)              (JSON-RPC 2.0 Payloads)

Key Capabilities

  • Zero-Cloud, Sub-Millisecond Execution: Compiles execution DAGs in under 0.3ms on local CPU with zero cloud API dependencies.
  • Topological Stage Parallelism: Automatically groups independent tool calls into concurrent batches via Kahn's algorithm, cutting sequential wait stages.
  • Zero Tool Injection: Strict parameter validation and static pattern + Shannon entropy checks block adversarial prompts (IntentType.SECURITY_AUDIT) before any tool is dispatched.
  • Cryptographic SHA-256 Merkle Root: Every ExecutionPlan computes a deterministic 64-char SHA-256 Merkle hash sealing the intended execution trajectory.
  • Native MCP Compatibility: Directly translates execution stages into standard Model Context Protocol tools/call JSON-RPC 2.0 payloads.

🚀 Installation & Quickstart

Installation

pip install agent-intent-compiler

Zero external dependencies (dependencies = []). Works across Python 3.9, 3.10, 3.11, and 3.12.

1. Compile User Prompt into a Typed Execution DAG

from agent_intent_compiler import IntentCompiler

compiler = IntentCompiler()

# Compile a multi-step user prompt
prompt = "Migrate the production PostgreSQL database schema and verify data integrity"
plan = compiler.compile(prompt)

print(f"Plan ID: {plan.plan_id}")
print(f"Intent Type: {plan.intent_type}")
print(f"Compilation Latency: {plan.compilation_latency_ms:.2f}ms")
print(f"Execution Stages (Parallel Groups): {plan.execution_order}")
print(f"Cryptographic Merkle Seal: {plan.merkle_root}")

2. Export Directly to Model Context Protocol (MCP)

from agent_intent_compiler import IntentCompiler, MCPAdapter

compiler = IntentCompiler()
plan = compiler.compile("Search for recent advancements in quantum error correction")

# Generate standard MCP JSON-RPC 2.0 tool requests
mcp_requests = MCPAdapter.to_mcp_requests(plan)

for req in mcp_requests:
    print(f"MCP Tool Call -> {req['params']['name']}: {req['params']['arguments']}")

3. Command Line Interface (CLI)

agent-intent-compiler "Deep research on LLM inference optimizations on edge hardware"

Running the Test Suite

pytest -v
# 14 passed (test_compiler.py, test_dag.py, test_mcp_adapter.py, test_sanitizer.py, test_subpackages.py, test_telemetry.py, test_tools.py)

📁 Project Structure

agent-intent-compiler/
├── src/
│   └── agent_intent_compiler/
│       ├── __init__.py               # Public package exports
│       ├── cli.py                    # CLI entrypoint
│       ├── compiler.py               # Backwards-compatible shim -> core.compiler
│       ├── dag.py                    # Backwards-compatible shim -> core.dag
│       ├── mcp_adapter.py            # Backwards-compatible shim -> serve.mcp_adapter
│       ├── models.py                 # Backwards-compatible shim -> core.models
│       ├── sanitizer.py              # Backwards-compatible shim -> core.sanitizer
│       ├── core/
│       │   ├── __init__.py           # Core compilation subpackage exports
│       │   ├── compiler.py           # Deterministic IntentCompiler orchestrator
│       │   ├── dag.py                # Kahn's algorithm topological DAG planner
│       │   ├── models.py             # Typed ExecutionNode, ExecutionPlan & Merkle seal
│       │   └── sanitizer.py          # Zero-width, regex & Shannon entropy shield
│       ├── serve/
│       │   ├── __init__.py           # Serving & telemetry subpackage exports
│       │   ├── mcp_adapter.py        # MCP JSON-RPC 2.0 tools/call emitter
│       │   └── telemetry.py          # P50/P90/P99 latency & intent distribution
│       └── tools/
│           ├── __init__.py           # Diagnostics & benchmark subpackage exports
│           ├── bench_matrix.py       # Multi-category compilation latency matrix
│           └── doctor.py             # Runtime health & injection shield probe
├── docs/
│   └── ARCHITECTURE.md               # Detailed compiler & DAG architecture spec
├── examples/
│   ├── mcp_pipeline_export.py        # Compile + MCP JSON-RPC export + telemetry
│   └── quickstart_compile.py         # Minimal multi-step DAG compilation example
├── scripts/
│   ├── benchmark_latency.py          # Sub-millisecond compilation matrix runner
│   └── gate_injection_shield.py      # Adversarial prompt injection gate suite
└── tests/                            # Full pytest suite (14 tests)

📊 Benchmark Comparison

Metric Raw Prompt to LLM Multi-Turn Agent Frameworks agent-intent-compiler
Compilation Latency 1,800ms – 3,500ms (network + LLM) 450ms – 1,200ms < 0.3ms (Observed ~0.12ms Local CPU)
Token Cost per Intent ~450 – 1,200 tokens ~250 – 600 tokens 0 Tokens ($0.00)
Prompt Injection Defense 0% (Vulnerable) Inconsistent Sub-ms Regex + Zero-Width + Entropy Shield
DAG Cycle Prevention None (Risk of loops) Runtime crash Static Kahn's Algorithm
Cryptographic Receipt No No SHA-256 Merkle Root
MCP Native JSON-RPC Manual boilerplate Partial 1-Click Native MCPAdapter
Runtime Dependencies Cloud SDKs Heavy Python/JS stacks Zero (Pure Python Stdlib)

🌐 The Benni OS Open-Source Ecosystem

agent-intent-compiler is part of the coordinated Benni Master OS v9.4 open-source infrastructure suite:

Repository Focus & Architecture Stars
conductor-sdd Zero-Dependency Spec-Driven Development, Static AST Drift Detector & MCP Guardrail GitHub Stars
benni-inference-engine High-Throughput Sovereign Local Inference for 8GB–16GB Consumer GPUs GitHub Stars
agent-eval-harness Deterministic Zero-Cloud Agent Evaluation, Red-Teaming & Benchmark Harness GitHub Stars
agent-code-sandbox Micro-Second Zero-Dependency Code Sandbox & Execution Shield for AI Agents GitHub Stars
agent-deep-research Autonomous Multi-Source Deep Research & Evidence Synthesis Engine GitHub Stars
agent-browser-mesh Token-Saving Resilient Headless Browser Automation & A11y DOM Compiler GitHub Stars
agent-intent-compiler Deterministic Intent Compiler & Typed DAG Execution Planner for AI Agents GitHub Stars
agent-token-optimizer Sub-Millisecond Context Compression & Semantic Deduplication Engine GitHub Stars
bio-sync-operator-os Real-Time Biometric Swarm Governance & 120 FPS Resonant Kinetic Interface GitHub Stars
agent-cyber-sentinel Zero-Trust Runtime Security, Prompt Injection Firewall & Secrets Redaction GitHub Stars
agent-run-ledger Deterministic Multi-Step Task Execution Ledger & Anti-Looping Engine GitHub Stars
reality-lock Cryptographic State Verification & Invariant Proof Engine for Agents GitHub Stars
agent-memory-mesh Hybrid Vector + BM25 Hierarchical Session Memory & Continuity Engine GitHub Stars
benni-operator-gateway Human-in-the-Loop Approval & Policy Enforcement Gateway GitHub Stars
mcp-forge Rapid Model Context Protocol (MCP) Server Scaffolding & Dynamic Tooling GitHub Stars
benni-nexus Autonomous Multi-Agent Intent Routing & Swarm Coordination Hub GitHub Stars
community-autopilot Autonomous GitHub Community Triaging & PR Feedback Agent GitHub Stars

🏛️ Commercial & Sovereign Architecture

Need deterministic intent compilation, autonomous multi-agent swarm orchestration, or enterprise Spec-Driven Governance?


📄 License & Provenance

  • License: MIT License
  • Author: Benni Alencar (bennialencar@gmail.com)
  • Architecture: Benni Master OS v9.4 Deterministic Intent Standard

agent-intent-compiler — Deterministic Intent Compiler & Typed DAG Execution Planner • benni-os.net • MIT License

About

Deterministic Intent Compiler & Typed DAG Execution Planner for Autonomous AI Agents & Model Context Protocol (MCP)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages