Skip to main content
LatticeAG

Vis Series

Axion

Open Source
Invite Only

Agent cognitive middleware - reads what an agent believes from its own output in real time, no code changes. Inspection beats observability; belief data feeds into your existing platforms as structured metadata.

Quick start

Start with the primary command, then continue with the full workflow below.

export OPENAI_BASE_URL=https://your-axion-worker.dev

Problem

Observability tools show what an agent did - the tool calls, the tokens, the spans - but never why. Langfuse, Arize, and Braintrust answer 'what happened?', not 'what did the agent believe when it decided that?'. An agent that emails the wrong recipient, deletes the wrong resource, or rewrites the same file four times did not fail randomly: it acted on beliefs - an assumption about a schema, an overweighted piece of evidence, a forgotten constraint - that were never visible. By the time a developer sees the bad action, the belief that caused it is gone. There is no stack trace for agent reasoning, and no product that reads the agent's own output to recover what it believed. The gap is inspection, not more tracing: observability shows behavior, but nobody shows the belief substrate underneath it.

Solution

Axion is agent cognitive middleware that reads what an agent believes from its own model output, in real time, with no code changes to the agent. It deploys as a Cloudflare Worker in front of a model API; any agent that supports a base URL override (Claude Code, Codex CLI, Cursor, Hermes, LangChain) points at it and keeps working. The Worker forwards each request upstream and streams the response straight back with zero added latency via ReadableStream.tee(), then a regex lens extracts reasoning fragments from the visible assistant text - causal claims, assumptions, intentions, evidence, uncertainty, contradictions, planning, and self-corrections - each stamped with a linguistic confidence score and stored per session. Belief data feeds INTO existing observability platforms as structured metadata: a signed webhook delivers axion.belief_batch.v1 batches to any sink, with documented mappings for Langfuse (metadata.axion on a generation span) and Honeycomb/OTLP (an axion.belief_batch event). Inspection, not another trace backend.

How it works

01

An operator deploys Axion as a Cloudflare Worker (npx wrangler deploy) and sets the required secrets: AXION_READ_TOKEN, AXION_CURSOR_SECRET, and optionally UPSTREAM_API_KEY and AXION_WEBHOOK_SECRET.

02

Any agent that supports a base URL override is pointed at the Worker - export OPENAI_BASE_URL or ANTHROPIC_BASE_URL to the Worker URL, or set base_url in the agent's config. The agent itself is unchanged: no SDK, no instrumentation, no code changes.

03

The Worker proxies both OpenAI Chat Completions (POST /v1/chat/completions) and Anthropic Messages (POST /v1/messages), streaming and non-streaming, with passthrough auth: the caller's Authorization or x-api-key header is forwarded, falling back to UPSTREAM_API_KEY only when set. An x-axion-session header correlates multi-turn sessions; absent it, the Worker generates a UUID per request.

04

The response is streamed back through a ReadableStream.tee(): one branch goes to the agent untouched (zero added latency), the other accumulates for extraction. After delivery, extraction runs in waitUntil() so the agent never waits for analysis.

05

The regex lens scans the visible assistant text for reasoning fragments and classifies them into eight belief types - causal, assumption, intention, evidence, uncertainty, contradiction, planning, self-correction - each with a baseline confidence that markers like 'certain' or 'uncertain' nudge, clamped to [0.1, 1.0]. Read-time decay (0.9 ^ turnsAgo) reflects belief freshness; stored batches keep original confidence.

06

Beliefs are stored in a sharded Durable Object session store (up to 200 batches per session, 5000 sessions in the registry), with native tool-call capture: OpenAI tool_calls and Anthropic tool_use become ObservedAction records on the same batch. Raw model text is omitted from public payloads; secret regex redaction runs before persist.

07

Read APIs behind the token expose the session: GET /api/beliefs/:id returns { sessionId, beliefs, actions }, GET /api/sessions pages the registry, and JSON/Markdown export, search, usage, and live SSE are available. A local dashboard at /dashboard takes a session id and a read token to inspect beliefs.

08

After a successful store, the Worker POSTs a redacted axion.belief_batch.v1 webhook to AXION_BELIEF_WEBHOOK_URL in waitUntil - HMAC-signed when AXION_WEBHOOK_SECRET is set - so belief data lands in existing observability platforms (Langfuse, Honeycomb/OTLP) as structured metadata. A slow or down sink cannot add latency or fail the proxy.

Technical architecture

Each handoff carries structured context through the product's execution path. Hover a node to inspect its role.

01

Proxy Intercept

Step 1: Proxy Intercept receives structured context from the prior stage and prepares it for the next handoff.

02

Response Tee

Step 2: Response Tee receives structured context from the prior stage and prepares it for the next handoff.

03

Belief Extraction

Step 3: Belief Extraction receives structured context from the prior stage and prepares it for the next handoff.

04

Confidence Scoring

Step 4: Confidence Scoring receives structured context from the prior stage and prepares it for the next handoff.

05

Session Store

Step 5: Session Store receives structured context from the prior stage and prepares it for the next handoff.

06

Token-Gated Reads

Step 6: Token-Gated Reads receives structured context from the prior stage and prepares it for the next handoff.

07

Belief Webhook

Step 7: Belief Webhook receives structured context from the prior stage and prepares it for the next handoff.

When to use

  • Debugging agents that silently change their mind or repeat themselves across a long session - the belief timeline shows what flipped and when.
  • Auditing agent decisions after a failed deployment - trace which assumption or overweighted evidence produced the wrong action.
  • Inspecting live reasoning in long-running agent sessions (Claude Code, Codex, Cursor) without adding instrumentation to the agent.
  • Feeding belief metadata into existing observability platforms - attach axion.belief_batch to Langfuse or Honeycomb spans instead of building a new dashboard.
  • Building trust in agent workflows by making the reasoning substrate visible and explainable to reviewers.

Not for

  • Hidden chain-of-thought recovery - the lens reads visible assistant text only; it does not and cannot recover private reasoning.
  • Replacing observability platforms - Axion supplements them with belief-level metadata; it is not a LangSmith replacement.
  • Loop detection or tool-call blocking - Axion Loop and Axion Gate are explicitly not built; use LexShield for pre-execution policy.
  • Full semantic verification - the PolyVerdict enforce mode is schema validation and coercion only, not second-model hallucination checks.

Features

Reads beliefs from the agent's own output - no code changes, no SDK, just a base URL override

Zero-latency observe path - ReadableStream.tee() delivers the response untouched, extraction runs in waitUntil()

Eight belief types - causal, assumption, intention, evidence, uncertainty, contradiction, planning, self-correction

Linguistic confidence scoring - baselines per type, markers nudge, clamped to [0.1, 1.0], decayed by turn age at read time

Dual provider support - OpenAI Chat Completions and Anthropic Messages, streaming and non-streaming

Passthrough auth - caller's Authorization or x-api-key forwarded, UPSTREAM_API_KEY only as fallback

Sharded session store - up to 200 belief batches per session, 5000 sessions in the registry

Native tool-call capture - OpenAI tool_calls and Anthropic tool_use stored as ObservedAction records on the same batch

Signed belief-batch webhook - axion.belief_batch.v1 to any sink, HMAC-SHA256 when a secret is set

Documented observability mappings - Langfuse (metadata.axion on a generation span) and Honeycomb/OTLP (axion.belief_batch event)

Token-gated read APIs - sessions registry, beliefs, search, JSON/Markdown export, usage, live SSE

Local dashboard - paste a session id and read token to inspect beliefs per session

Secret redaction before persist - bounded regex redaction, raw text stripped from public payloads

Rate limits on reads via Cache API windows - 30 search, 6 export-all, 120 other reads per token per minute

MIT licensed - deploy your own instance on the Cloudflare Workers free plan

Install and usage

usage.sh
# Point any agent at Axion - zero code changes
export OPENAI_BASE_URL=https://your-axion-worker.dev
export ANTHROPIC_BASE_URL=https://your-axion-worker.dev

# Send a session header on your agent's requests
# x-axion-session: my-session

# Deploy your own instance
git clone https://github.com/LatticeAG/Axion.git
cd Axion
npm ci
cp .dev.vars.example .dev.vars
npm run dev

# Local demo: send the read token on dashboard / API reads
# dashboard: http://localhost:8787/dashboard/?session=my-session

# Read beliefs for a session (token-gated)
curl http://localhost:8787/api/beliefs/<session-id> \
  -H "x-axion-read-token: <token>"
# -> { "sessionId": "...", "beliefs": [...], "actions": [...] }

Architecture explorer

Problem

Observability tools show what an agent did - the tool calls, the tokens, the spans - but never why. Langfuse, Arize, and Braintrust answer 'what happened?', not 'what did the agent believe when it decided that?'. An agent that emails the wrong recipient, deletes the wrong resource, or rewrites the same file four times did not fail randomly: it acted on beliefs - an assumption about a schema, an overweighted piece of evidence, a forgotten constraint - that were never visible. By the time a developer sees the bad action, the belief that caused it is gone. There is no stack trace for agent reasoning, and no product that reads the agent's own output to recover what it believed. The gap is inspection, not more tracing: observability shows behavior, but nobody shows the belief substrate underneath it.

Solution

Axion is agent cognitive middleware that reads what an agent believes from its own model output, in real time, with no code changes to the agent. It deploys as a Cloudflare Worker in front of a model API; any agent that supports a base URL override (Claude Code, Codex CLI, Cursor, Hermes, LangChain) points at it and keeps working. The Worker forwards each request upstream and streams the response straight back with zero added latency via ReadableStream.tee(), then a regex lens extracts reasoning fragments from the visible assistant text - causal claims, assumptions, intentions, evidence, uncertainty, contradictions, planning, and self-corrections - each stamped with a linguistic confidence score and stored per session. Belief data feeds INTO existing observability platforms as structured metadata: a signed webhook delivers axion.belief_batch.v1 batches to any sink, with documented mappings for Langfuse (metadata.axion on a generation span) and Honeycomb/OTLP (an axion.belief_batch event). Inspection, not another trace backend.