Skip to main content
AXON is built on 12 cognitive primitives — foundational constructs that represent how AI models think, reason, and process information. Unlike traditional programming languages that abstract over CPU instructions, AXON abstracts over cognitive operations.

Overview

Each primitive maps to a specific cognitive capability or constraint that LLMs naturally possess. By making these explicit in the language, AXON enables you to compose complex AI behaviors declaratively.

Identity & Context

persona, context, memory

Reasoning & Control

reason, flow, intent

Constraints & Validation

anchor, validate, refine

Tools & Synthesis

tool, probe, weave

The 12 Primitives

1. Persona — Cognitive Identity

Defines the identity and capabilities of the AI model. A persona specifies domain expertise, tone, confidence thresholds, and behavioral constraints.
persona LegalExpert {
  domain: ["contract law", "IP", "corporate"]
  tone: precise
  confidence_threshold: 0.85
  cite_sources: true
}
Think of personas as cognitive profiles that shape how the model approaches tasks. They’re not just system prompts — they’re type-checked, composable identities.

2. Context — Working Memory

Establishes the session configuration and working memory parameters for execution. Controls temperature, token limits, language, and computational depth.
contract_analyzer.axon
context LegalReview {
  memory: session
  language: "en"
  depth: exhaustive
  max_tokens: 4096
  temperature: 0.3
}
Key Fields:
  • memory: session, persistent, ephemeral
  • temperature: Controls randomness (0.0 = deterministic, 1.0 = creative)
  • depth: shallow, normal, exhaustive
  • max_tokens: Output length budget

3. Intent — Atomic Semantic Instruction

Represents a single, focused semantic operation. Intents are the smallest unit of cognitive work — they ask the model to perform one specific task.
Example: Extract entities
intent ExtractParties {
  ask: "Identify all parties mentioned in the contract"
  input: Document
  output: EntityMap
}
Intents are composable — they can be chained within flows or invoked independently.

4. Flow — Composable Cognitive Pipeline

Orchestrates multi-step reasoning by composing cognitive operations into a directed acyclic graph (DAG). Each step can reference outputs from previous steps.
contract_analyzer.axon
flow AnalyzeContract(doc: Document) -> ContractAnalysis {
  step Extract {
    given: doc
    ask: "Extract all parties, obligations, dates, and penalties"
    output: EntityMap
  }
  
  step Assess {
    given: Extract.output
    ask: "Identify ambiguous or risky clauses"
    output: RiskAnalysis
  }
  
  step Synthesize {
    weave [Extract.output, Assess.output]
    format: ContractAnalysis
  }
}
Data Dependencies: Steps automatically form a dependency graph. Assess won’t execute until Extract completes. The AXON runtime handles orchestration.

5. Reason — Explicit Chain-of-Thought

Forces the model to show its reasoning before producing an answer. Enables explicit chain-of-thought or tree-of-thought reasoning.
Example: Logical reasoning
step Analyze {
  reason {
    chain_of_thought: enabled
    given: contractText
    ask: "Are there ambiguous or risky clauses?"
    depth: 3
  }
  output: RiskAnalysis
}
Reasoning Modes:
  • chain_of_thought: Linear step-by-step reasoning
  • tree_of_thought: Branching exploration (experimental)
  • depth: Controls reasoning steps (1-5)

6. Anchor — Hard Constraint (Never Violable)

Defines inviolable rules that must never be broken. Anchors are checked at runtime, and violations raise AnchorBreachError.
contract_analyzer.axon
anchor NoHallucination {
  require: source_citation
  confidence_floor: 0.75
  unknown_response: "I don't have sufficient information."
  on_violation: raise AnchorBreachError
}
Anchors are fail-fast by design. If an anchor is breached, execution stops immediately unless a refine block handles recovery.
Use cases:
  • Preventing hallucinations (NoHallucination)
  • Enforcing logical structure (SyllogismChecker)
  • Blocking speculation (AgnosticFallback)
  • Requiring citations (RequiresCitation)

7. Validate — Semantic Validation Gate

Type-checks the semantic meaning of outputs, not just their structure. Ensures outputs match their declared epistemic type.
Example: Validate against schema
step Check {
  validate Assess.output against: ContractSchema
  if confidence < 0.8 -> refine(max_attempts: 2)
  output: ValidatedAnalysis
}
Validation failures raise ValidationError (Level 1) and can trigger automatic refinement.

8. Refine — Adaptive Retry with Failure Context

Enables self-healing by automatically retrying failed operations with injected failure context. The model learns from its mistakes.
Example: Retry with backoff
step ExtractWithRetry {
  refine {
    max_attempts: 3
    backoff: exponential
    pass_failure_context: true
    on_exhaustion: fallback("default_extract")
  }
  ask: "Extract key contract terms"
  output: Terms
}
Self-Healing Mechanism: When a step fails validation or breaches an anchor, refine re-invokes the model with the exact failure reason injected into the prompt. This creates a closed feedback loop.

9. Memory — Persistent Semantic Storage

Provides long-term storage for semantic values across sessions. Unlike context (working memory), memory persists beyond execution.
Example: User preferences
memory UserPreferences {
  schema: {
    language: String,
    expertise_level: String,
    topics_of_interest: List<String>
  }
  backend: vector
  ttl: 30d
}
Supports multiple backends:
  • in_memory: Fast, ephemeral
  • vector: Semantic search (embeddings)
  • kv: Key-value store

10. Tool — External Invocable Capability

Bridges the model to external capabilities like web search, code execution, file I/O, or API calls.
contract_analyzer.axon
tool WebSearch {
  provider: brave
  max_results: 5
  timeout: 10s
}
Built-in Tools:
  • WebSearch — Internet search (Serper.dev)
  • FileReader — Local filesystem access
  • CodeExecutor — Run code sandboxed
  • Calculator — Math operations
  • DateTime — Time/date utilities
See Tool System for details.

11. Probe — Directed Information Extraction

Performs targeted extraction of specific information from unstructured data.
Example: Extract obligations
step ExtractObligations {
  probe doc for [parties, obligations, dates, penalties]
  output: EntityMap
}
Probes are type-aware — the runtime knows what to look for and validates the extraction.

12. Weave — Semantic Synthesis

Combines multiple outputs into a coherent whole. Unlike simple concatenation, weaving performs semantic integration.
Example: Synthesize report
step Report {
  weave [Extract.output, Assess.output, Check.output]
  format: StructuredReport
  include: [summary, risks, recommendations]
}
Weaving is context-aware — the model understands the semantic relationships between inputs and produces a unified representation.

Composability

Primitives are designed to compose naturally:
Full pipeline example
run AnalyzeContract(myDoc)
  as LegalExpert              // persona
  within LegalReview           // context
  constrained_by [NoHallucination]  // anchor
  on_failure: retry(backoff: exponential)  // refine
This single run statement combines:
  • Persona (who)
  • Context (how)
  • Flow (what)
  • Anchor (constraints)
  • Refine (recovery)

Design Philosophy

Primitives describe what you want, not how to do it. The AXON runtime handles orchestration.
Primitives operate on meaning, not bytes. Types represent epistemic states, not memory layouts.
Primitives snap together like neural networks — small units compose into complex behaviors.
refine, validate, and anchor make failure handling explicit and automatic.

Next Steps

Type System

Learn about AXON’s epistemic types

Compilation Pipeline

See how primitives compile to prompts

Error Handling

Understand the 6-level error hierarchy

Examples

See primitives in action

Build docs developers (and LLMs) love