CTX Language

6 features

7 Operators × 7 Planes

Seven operators (search, call, store, update, delete, lookup, delegate) work across seven planes — tools, knowledge, memory, skills, agents, inspection, and LLM — forming a complete grammar for agent-to-system communication.

Pipeline Verbs

Chain multiple operations in a single statement using pipe (|), fork (&), and stream (>>) verbs. Enables complex multi-step workflows without multiple round-trips.

Hybrid Parser

Accepts CTX, JSON, or natural language input in the same session. The parser detects format automatically, allowing gradual adoption without breaking existing agent behavior.

Schema Registry

Validates CTX statements against registered schemas at parse time. Catches malformed operations before they reach the gateway, providing field-level error feedback.

ISA Primitives

Core syscall-like primitives — action, assign, pipe, query, and complete — that map to agent lifecycle operations the same way POSIX syscalls map to OS operations.

Inspection Plane

The +i operator enables agents to inspect their own active context, loaded tools, memory state, and budget usage at runtime — like /proc for agents.

Gateway & Routing

8 features

Unified Context Router

Every agent operation — tool calls, memory reads, knowledge searches, and skill lookups — routes through one gateway. One connection replaces dozens of individual tool integrations.

Middleware Pipeline

Requests pass through a composable middleware chain: OIDC authentication, role-based access control, audit logging, alignment checks, scope enforcement, recursion depth limits, and token budget tracking.

Lazy Backend Spawn

MCP backend servers are spawned only when first called, not at gateway startup. Reduces memory footprint and startup time for deployments with many configured backends.

Broker Meta-Tools

Auto-generated meta-tools that let agents query the gateway itself — discover available backends, check their health status, and introspect tool schemas without separate API calls.

Dynamic Boot Prompts

Role-scoped boot prompts inject only the context each agent needs at session start, reducing boot token overhead by up to 10× compared to static system prompts.

Token Paging (L1/L2/L3)

Three-tier cache hierarchy: L1 (active context window), L2 (SurrealDB hot storage), L3 (cold archive). Facts page in and out on demand instead of pre-loading everything.

Depth Limiter

Prevents infinite recursion in agent chains by enforcing a configurable maximum call depth. Protects against runaway agent loops consuming unbounded resources.

Event Stream

Real-time gateway event streaming for monitoring and observability. Emits structured events for every operation, enabling live dashboards and audit feeds.

Memory (5-Layer Architecture)

8 features

Perception Layer

Raw sensory input from tools, user messages, and environment. Unprocessed data that feeds into higher memory layers for interpretation.

Working Memory

Short-term session state — active goals, recent decisions, and scratchpad data. Automatically cleaned up when a session ends or the agent completes its task.

Episodic Memory

Timestamped event history that persists across sessions. Tracks what happened, when, and in what context — enabling agents to learn from past interactions.

Semantic Memory

Persistent factual knowledge stored as vector embeddings in SurrealDB. Supports HNSW-indexed similarity search for concept-level recall, not just keyword matching.

Procedural Memory

Stores learned patterns, successful strategies, and reusable workflows. Agents accumulate procedural knowledge over time, getting better at recurring tasks.

Spatial Recall

Tag-filtered memory lookup with sub-millisecond latency, flat to 50K entries. Enables instant recall of relevant memories without scanning the full store.

Cognitive Handoff

Transfers active context — goals, progress, and working memory — from one session or agent to another. Enables multi-session tasks without losing state (214 tokens vs 6,500 to rebuild).

Decay Scoring

Memories accumulate a decay score based on age, access frequency, and relevance. Older, unused memories fade naturally, keeping the active set lean and relevant.

Knowledge Plane

5 features

SurrealDB + HNSW Vectors

Hybrid graph and vector search in a single database. Combines structured graph relationships with high-dimensional similarity search for comprehensive knowledge retrieval.

Smart Chunker

Syntax-aware document splitting for Markdown, YAML, JSON, SQL, and source code. Preserves structural boundaries so chunks remain semantically meaningful.

Write Gate (WASM)

WebAssembly-sandboxed validation logic runs before any data enters the knowledge store. Enforces schema constraints, format rules, and size limits in an isolated runtime.

File Watcher

Monitors filesystem directories and automatically re-ingests changed files into the knowledge plane. Keeps stored knowledge in sync with local documentation.

Full-Text Search

BM25-ranked full-text search across all ingested knowledge. Complements vector similarity with traditional keyword relevance scoring.

Tools (MCP Proxy)

4 features

Tool Discovery (?t)

The ?t operator lists all available tools across all connected MCP backends in a single query. Agents see a unified tool catalog regardless of how many servers are running.

Schema Introspection (!t)

The !t operator retrieves full parameter schemas and return types for any tool. Agents can programmatically understand tool interfaces without documentation.

Transparent Proxy

Transparently proxies to any MCP-compatible backend server. No proprietary protocol — agents interact with standard MCP while the gateway handles routing and lifecycle.

RBAC Verification

Every tool invocation is verified against the agent's RBAC role. Agents can only call tools their role permits, enforced at the gateway level before dispatch.

Sidecar & Trust

5 features

Deterministic Compiler

Deterministic compiler — not LLM. Translates CTX into 6 target formats with zero ambiguity. Every output is reproducible and verifiable.

6 Compilation Targets

Compiles CTX statements into SurrealQL, SQL, REST, JSON-RPC, GraphQL, and human-readable English. Each target is a dedicated emitter with format-specific optimization.

Ed25519 Signing

Every sidecar translation is Ed25519-signed, creating a tamper-proof cryptographic receipt. Humans can verify that what the agent did matches what they were told.

Dual Storage (.ctx + .md)

Every operation produces both a .ctx file (machine-parseable AST) and a .md file (human-readable narrative). The sidecar signs both, guaranteeing they match.

actx verify

Run actx verify to check any translation's Ed25519 signature against its content. Confirms the sidecar output hasn't been tampered with — instant audit validation.

Security (8 Layers)

12 features

Input Validation

All input is validated at parse time before entering the system. Malformed CTX, oversized payloads, and structurally invalid operations are rejected immediately.

Auth + RBAC

JWT-based authentication with role-based access control. Scope enforcement ensures agents operate only within their assigned permissions.

Convergent Encryption

Identical content produces identical encrypted ciphertexts, enabling deduplication without exposing plaintext. Storage efficiency meets privacy by design.

Signed Translations

Ed25519 receipts on every sidecar operation. Creates an immutable audit trail connecting agent actions to human-readable translations.

Constant-Time Ops

All sensitive comparisons (tokens, signatures, keys) use constant-time algorithms. Prevents timing side-channel attacks that could leak secrets through response latency.

Parameterized Queries

All database operations use parameterized queries to prevent injection attacks. No string concatenation touches SurrealQL — ever.

Secret Redaction

Detects and masks personally identifiable information and API keys in memory operations. Part of the Sentinel monitoring pipeline with pattern-based detection.

Sentinel Monitoring

Monitors agent behavior with pre/post execution hooks, behavioral heuristics, and cross-agent correlation. Detects anomalies in real-time and triggers graduated responses.

Alert Severity Ladder

Graduated response system: low (log) → medium (log + notify) → high (log + notify + throttle) → critical (quarantine). Proportional response prevents overreaction.

Hook SDK

Custom detection patterns via @agentctx/core/sentinel. Build organization-specific security rules that plug into the Sentinel pipeline without modifying core code.

OIDC Auto-Discovery

Discovers OIDC configuration from .well-known endpoints with JWKS caching. Zero-config authentication for enterprise identity providers.

TEE Enclaves

Trusted execution environments for enterprise deployments. Sensitive operations run in hardware-isolated enclaves — planned for cloud/enterprise tiers.

Orchestration & Loop

11 features

Deterministic Dispatch

Routes operations deterministically based on type and plane. No probabilistic routing — the same operation always takes the same path through the system.

Agent Loop State Machine

Full lifecycle management: init → plan → act → observe → reflect → complete. Every agent follows a predictable state machine with well-defined transitions.

Process Groups

Three execution modes: managed (human approves each step), guided (human sets goals, agent executes), and autonomous (agent operates independently within budget).

Model Capability Recommender

Recommends the optimal LLM model for each task based on complexity, required capabilities, and remaining token budget. Avoids overspending on simple tasks.

Prompt Compiler

Compiles prompts natively in CTX format, adapted to the agent's adoption tier. Higher tiers get more compressed, efficient prompts automatically.

Context Budget Enforcer

Tracks token consumption across input, output, and response. Enforces per-session budget limits and triggers graceful degradation when budgets run low.

Dual-Mode Loop

Seamlessly switches between conversational mode (agent responds to user) and autonomous mode (agent executes a plan independently). No restart required.

Graceful Shutdown Ladder

Progressive deescalation: pause (save state) → checkpoint (persist to archive) → terminate (clean exit). Prevents data loss during forced shutdowns.

Runtime Coherence Monitoring

Four real-time detectors — output drift (D-1), scope violation (D-2), budget overrun (D-3), and repetition (D-4) — with a graduated intervention ladder from warning to shutdown.

Cognition Traces

CTX reasoning traces capture the agent's decision-making process at each step. Consumed by the gateway for observability, debugging, and alignment verification.

Process Archive

Completed agent processes are archived to SurrealDB with cryptographic integrity. Enables queryable execution history across all past sessions.

Automation & Scheduling

5 features

Event Triggers

Cron, webhook, and event-based triggers that launch agent workflows automatically. Rule-based matching with threshold and cooldown support.

Scheduler

Cron-syntax scheduling engine for recurring agent tasks. Supports timezone-aware execution with jitter to prevent thundering herds.

Webhooks

Inbound webhook endpoints that translate HTTP payloads to CTX trigger events. HMAC-verified signatures for secure external integrations.

Checkpoints

Persistent checkpoints for long-running agent workflows. Resume from last checkpoint on failure or restart without losing progress.

Lifecycle Hooks

Pre/post execution hooks for automation pipelines. Enable custom validation, logging, and notification at each stage of a workflow.

Alignment & Safety

4 features

Divergence Detector

Flags when agent output deviates from its assigned instructions or stated goals. Catches hallucinated actions and off-topic behavior before they execute.

Groundedness Enforcer

Verifies agent claims against available knowledge in the knowledge plane. Prevents fabricated citations and unsupported assertions from reaching the output.

Sandbagging Detector

Detects agents that deliberately underperform by comparing their output quality against cross-agent baselines. Prevents strategic capability concealment.

Sentinel Gateway Hook

Pluggable hook point in the gateway pipeline for custom alignment policies. Integrate organization-specific detection rules without modifying core gateway code.

Agent-to-Agent Protocol

4 features

CTX Memory Ops (15 tokens)

Agent-to-agent communication via CTX memory operations costs ~15 tokens per message — compared to ~2,000 tokens for prose-based handoff manifests. 99% reduction.

Handoff Protocol

Structured handoff protocol transfers goals, progress, and relevant memory from one agent to another. Ensures continuity without context loss during agent transitions.

Swarm Coordination

Orchestrates swarms of agents working on decomposed subtasks. Tracks progress, collects results, and coordinates completion across the swarm via NATS pub/sub.

Identity Consensus

Agents in federated multi-tenant deployments establish shared identity consensus. Prevents Sybil attacks and enables trust-weighted decisions across organizational boundaries.

Transport & Encoding

6 features

CLI (actx)

Full CLI with 11+ subcommands: init, add, start, query, verify, top, ingest, watch, decode, phase, dispatch. The primary local interface for development and operations.

MCP stdio

Standard MCP stdio transport for local process communication. The default transport for development and single-machine deployments.

MCP SSE

MCP over Server-Sent Events for remote and cloud deployments. Enables real-time streaming responses over HTTP without persistent socket connections.

CTX-B Binary

Compact binary encoding of CTX for machine-to-machine communication. Achieves over 1 million operations per second — ideal for high-throughput agent fleets.

TCP Socket

Low-latency TCP socket transport for persistent connections. Designed for high-throughput agent fleets requiring minimal per-message overhead.

HTTP API

RESTful HTTP API transport for stateless integrations. Supports webhooks, serverless functions, and standard HTTP tooling like curl.

Platform

7 features

CLI Foundation

Complete CLI toolkit: init (project setup), add (backends), start (gateway), query (CTX operations), verify (audit), top (observability), ingest (knowledge), watch (file sync), decode (CTX-B), phase (gate management), dispatch (orchestration).

VS Code Extension

VS Code extension with agent dashboard, DiffView for CTX translations, and strict mode selector for enforcing CTX-only output.

Agent Dashboard

Local web dashboard via actx dashboard. Shows agent metrics, token budgets, cost reporting, and session telemetry.

Observability

End-to-end tracing with OpenTelemetry integration and SurrealDB telemetry logging. Correlates agent actions across sessions and backends.

Interactive REPL

actx repl — interactive CTX command line with tab completion, history, and inline result formatting. Execute CTX statements directly.

Secrets Storage

Resolves secrets from external vaults via op:// URI scheme. Ships with 1Password support, extensible provider architecture, and RAM-only caching with 15-minute TTL.

Token Economy

Self-managed token budget tracking per agent and session. Monitors input, output, and response token consumption with automatic alerts at configurable thresholds.

Storage

4 features

Content-Addressable

Deduplicated content-addressable storage with convergent encryption. Identical content deduplicates automatically while maintaining privacy through encryption.

SurrealDB Backend

SurrealDB serves as the unified backend for memory, knowledge, graph relations, and telemetry. One database for all planes — no external service sprawl.

WASM Contracts

WebAssembly contracts provide client-side verifiable storage logic. Validation functions run in a sandboxed WASM runtime, ensuring tamper-proof data integrity.

SurrealKV Sync

Edge synchronization for distributed agents via SurrealKV. Enables local-first operation with eventual consistency across nodes.

Multi-Language SDK

5 features

@agentctx/core

The foundational monolith SDK in TypeScript. Contains the full gateway, parser, memory, knowledge, and orchestration stack.

@agentctx/types

Shared pure type definitions and interfaces. Zero runtime dependencies — consumed by all other packages for type safety.

@agentctx/client

Lightweight external integration client for connecting to a running AgentCTX gateway. Minimal footprint for agent-side usage.

@agentctx/sdk

High-level abstractions for agent builders. Simplifies common patterns like memory operations, tool discovery, and session management.

ctx-parser (Rust)

Rust-native CTX parser compiled to napi-rs (Node), PyO3 (Python), WASM (browser), and native binary. 1M+ ops/sec AST parsing.

Response Encoding

4 features

CTX Response Encoding

Native CTX response encoding — returns structured, typed results using CTX syntax with full semantic compression. Recommended for best overall token savings across all response types.

TOON Encoding

Token-Oriented Object Notation — an alternative response format that declares headers once and emits rows as positional values. Optimized for tabular data like search results and tool listings.

Negotiation Chain

Automatic format negotiation with graceful degradation: ctx → toon → json. CTX is recommended for best results; TOON and JSON are available as alternatives depending on the use case.

Marketplace Weighting

Tools that emit CTX-formatted responses get a +15% discovery priority boost in the marketplace. Incentivizes the ecosystem toward token-efficient responses.

Horizon Roadmap

Upcoming and in-progress capabilities for the AgentCTX ecosystem.

OS Architecture & Kernel

ID Feature Impact Status
H13 ctx-top — Agent OS Observability TUI Real-time process tree, IPC monitor, interactive SIGKILL TS MVP Promoted
H14 ISA Formalization — Core Syscall Primitives +t:action, +t:assign, +t:pipe, +t:query, +t:complete Partial Promoted
H15 ToolDispatcher — Device Driver Execution Layer RBAC-verified tool execution, driver abstraction Promoted → Phase 23l
H16 Dynamic Kernel Boot Prompts Role-scoped context injection, 10× fewer boot tokens Horizon
H17 SurrealDB Process Archive Cryptographically queryable execution history Promoted → Phase 23l
H19 Token Paging — Context Window as L1 Cache Page facts on demand instead of pre-loading, L1/L2/L3 hierarchy Promoted → Phase 23m

Parser, Spec & Validation

ID Feature Impact Status
H6 Parser Hardening — Adversarial Defense AST depth limits, prototype pollution, path traversal High Priority
H7 Semantic Schema Registry Schema-validated AST, SCHEMA_MISMATCH errors Horizon
H8 CTX Open Specification Multi-language parsers (Python, Rust, Go) Horizon
H11 Hybrid Payload Parser Mixed prose + CTX extraction, { prose, ast } split output Promoted → Phase 23j

Ecosystem & Adoption

ID Feature Impact Status
H3 CTX-Native LLM Pipeline (v2.1) Gemini caching, Anthropic prompt caching Horizon
H9 Rust FFI Boundary (R12 Migration) napi-rs bindings, 10-100× parser performance Horizon
H12 Minimum Viable Ecosystem Launch Parsers, Tree-Sitter grammar, LSP, killer apps Parser Done
H18 CTX LoRA Adapter Fine-tuned open-weight models that natively speak CTX Horizon
H21 Deleted Module Aspirations SDK adapter layer, IDE file router, chaos/fault injection Horizon
H26 IDE Integration & CTX Marketplace VS Code extension, community adapters, CI/CD Horizon
H27 Gateway Batch Endpoint (/ctx/batch) Atomic multi-statement execution, reduced overhead Near-Term

Memory & Consensus

ID Feature Impact Status
H1 Identity-Gated Consensus Bridge Identity-weighted consensus, Sybil prevention, cross-scope federation Promoted → Phase 23k
H2 Global Knowledge Tier (Layer 5) Consensus-proven facts across tenants Horizon

Security & Monitoring

ID Feature Impact Status
H4 Sidecar Proxy Role — LLM DLP Intercept calls, PII/secret redaction, token metering Horizon
H20 Continuous Behavioral Monitoring Anomaly dashboards, drift detection, quarantine Horizon

Performance & Transport

ID Feature Impact Status
H22 CTX Response Encoding Native CTX response encoding with TOON and JSON fallback support Shipped
H23 HTTP REST API Transport (/ctx) Stateless HTTP endpoint for webhooks, serverless Horizon
H24 TCP Socket Transport Low-latency persistent connections for fleets Horizon
H25 CTX Proxy for Backend MCPs One ctx tool routes to N backends, NATS bus Horizon

Benchmarking

ID Feature Impact Status
H5 Empirical Workstream Data Process learnings from 26 workstreams informing tuning Horizon
H10 Hallucination Reduction Benchmark 52,000 runs × 3 models × 2 formats — empirical proof Promoted → Phase 23y