Download Game! Currently 76 players and visitors. Last logged in:PotionOmnipotentCelbornKandahar

Blitzer's Blog >> 71948

Back to blogs index
Posted: 02 Sep 2026 21:19 [ permalink ]
### Why this Schema is Bulletproof for LLMs

1. **The `additionalProperties: false` Rule:** By setting this on every node
definition, we mathematically forbid the LLM from appending "helpful" but
system-crashing fields like `"description": "This node fetches the user"`. It
forces extreme strictness.
2. **The `const` Discriminator:** The schema checks the `"type"` field first.
If it is `"EXECUTE_TOOL"`, it validates *only* against `node_execute_tool`. If
the LLM tries to put `next_true` inside an `EXECUTE_TOOL` node, the schema
validator will instantly throw an error.
3. **`patternProperties` for Node IDs:** The regex `"^[a-zA-Z0-9_]+$"`
enforces that the LLM only generates safe, alphanumeric node IDs without
spaces or special characters that could break string parsing later.

### How to use this with the LLM Compiler

When you build the system prompt for your "Compiler" (the LLM responsible for
translating user intent into AST), you do not actually ask it to generate the
*entire* state object every time. The LLM shouldn't waste tokens generating
empty `intent_log` arrays.

Instead, you write a wrapper script that builds the boilerplate. The LLM's
only job is to return a JSON object containing `local_vars` and `program_ast`.

**The Compiler Prompt Pattern:**

> "You are an AI compiler. Your job is to translate the user's request into a
flat-map Abstract Syntax Tree (AST) that our deterministic engine can execute.
> You have access to the following tools: `fetch_user(id)`, `log_telemetry(msg)
`.
> You may use double-bracket syntax `[[locals.var_name]]` to resolve
variables, or `[[history.1.result]]` to reference the previous tool's output.
> Output ONLY valid JSON that strictly conforms to the provided JSON Schema
for `program_ast` and `local_vars`."

If you pass this schema to modern APIs that support "Structured Outputs" (like
Gemini's `response_schema` or OpenAI's structured outputs), the API will
natively enforce the schema during the token generation process, guaranteeing
a 100% syntactically valid AST every single time.