### The Engine Schema (Draft-07)
This schema uses a `oneOf` discriminator block. This forces the LLM's output
validator to strictly adhere to the specific property requirements of each
node type, rejecting any hybrid or hallucinated nodes.
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AgentState",
"description": "The complete execution state and AST for the AI Agent
microkernel.",
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": ["RUNNING", "HALTED", "COMPLETED", "WAITING"]
},
"intent_log": { "type": "array", "items": { "type": "object" }, "default":
[] },
"debug_buffer": { "type": "array", "items": { "type": "object" },
"default": [] },
"cpu_state": {
"type": "object",
"properties": {
"instruction_pointer": {
"type": "string",
"description": "Must match a key in program_ast"
},
"local_vars": {
"type": "object",
"description": "Initial key-value pairs for the execution memory."
},
"global_memory": { "type": "object" }
},
"required": ["instruction_pointer", "local_vars"]
},
"program_ast": {
"type": "object",
"description": "The flat-map Abstract Syntax Tree. Keys are node IDs.",
"patternProperties": {
"^[a-zA-Z0-9_]+$": {
"$ref": "#/definitions/ast_node"
}
},
"additionalProperties": false
}
},
"required": ["status", "cpu_state", "program_ast"],
"definitions": {
"ast_node": {
"type": "object",
"required": ["type"],
"oneOf": [
{ "$ref": "#/definitions/node_execute_tool" },
{ "$ref": "#/definitions/node_eval_condition" },
{ "$ref": "#/definitions/node_set_variable" },
{ "$ref": "#/definitions/node_end" }
]
},
"node_execute_tool": {
"properties": {
"type": { "const": "EXECUTE_TOOL" },
"tool_name": { "type": "string" },
"params": {
"type": "object",
"description": "Payload parameters. Can include [[...]] dynamic
interpolation syntax."
},
"returns_to": { "type": "string", "description": "Local variable to
store the result." },
"next": { "type": "string", "description": "The ID of the next node to
execute." }
},
"required": ["type", "tool_name", "params", "returns_to", "next"],
"additionalProperties": false
},
"node_eval_condition": {
"properties": {
"type": { "const": "EVAL_CONDITION" },
"variable": { "type": ["string", "number", "boolean"] },
"target_value": { "type": ["string", "number", "boolean"] },
"next_true": { "type": "string" },
"next_false": { "type": "string" }
},
"required": ["type", "variable", "target_value", "next_true",
"next_false"],
"additionalProperties": false
},
"node_set_variable": {
"properties": {
"type": { "const": "SET_VARIABLE" },
"assign_to": { "type": "string" },
"value": { "type": ["string", "number", "boolean", "object", "array"]
},
"next": { "type": "string" }
},
"required": ["type", "assign_to", "value", "next"],
"additionalProperties": false
},
"node_end": {
"properties": {
"type": { "const": "END" }
},
"required": ["type"],
"additionalProperties": false
}
}
}
```