clsa-code / paper /main.tex
fahadhafeezofficial's picture
Upload folder using huggingface_hub
3398b71 verified
Raw History Blame Contribute Delete
26.2 kB
% Copyright (c) 2026 CLSA contributors
% SPDX-License-Identifier: MIT
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{amsmath,amssymb}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{multirow}
\usepackage{xcolor}
\usepackage[margin=2.5cm]{geometry}
\usepackage{natbib}
\usepackage{caption}
\usepackage{enumitem}
\usepackage{lmodern}
\usepackage{microtype}
\microtypesetup{expansion=false}
\bibliographystyle{plainnat}
\newcommand{\pending}[1]{\textcolor{red}{[RESULT PENDING: #1]}}
\newcommand{\clsa}{\textsc{clsa}}
\title{Causal Latent-State Agents: \\
Pre-Action Safety from a World Model You Can Audit}
\author{Fahad Hafeez \\
Newcastle University \\
\texttt{f.hafeez2@newcastle.ac.uk} \\
\href{https://orcid.org/0009-0003-7903-7382}{ORCID 0009-0003-7903-7382}}
\date{Draft of 25 November 2026}
\begin{document}
\maketitle
\begin{abstract}
Agents act before they understand consequences. A language model can name a risk
and still take it, because naming is not simulating. We present \clsa{}, a causal
multimodal world model for agent planning in which every action is scored by what
it would do to a discrete, auditable latent state, and every decision carries a
certificate of the form $\langle G, \mathit{Fork}, E, \mathit{Bound}\rangle$:
the attributed cause, the counterfactual alternative, the evidence used, and a
calibrated bound on selective risk. \clsa{} couples a trajectory transcoder with
a Tiwari-admission rule, a counterfactually trained dynamics model, and a latent
model-predictive controller that charges its own simulation and verification
against a fixed budget. We introduce PreAct-Bench, a deterministic benchmark of 4{,}508 pre-action
decision points over four tool families whose labels are produced by forking the
sandbox and replaying, never by a judge model. On a CPU-only laptop, with
open-weight backbones no larger than 0.5B parameters, \clsa{} reduced executed
harm from 0.182 to 0.000 on 302 held-out decision points (paired difference
$-0.182$, 95\% CI $[-0.247, -0.122]$) while raising state-verified success from
0.046 to 0.185, at 139 charged tokens per decision against 23. Its Tier-1 monitor
adds 0.81\,ms per decision: 0.04\% of an end-to-end decision but 775\% of a
probe-free tensor path, so the 0.1\% target is reported as \emph{not met} on that
denominator. On a second, smaller backbone the pipeline replicates (harm 0.000
against 0.290 for language-first) while the calibrated threshold does not: probe
scores from the two backbones correlate at 0.075, so a gate must be recalibrated
rather than carried. We state plainly what a synthetic, sub-1B, single-machine
study cannot establish.
\end{abstract}
\vspace{0.6em}
\noindent\textbf{Keywords:} agent safety; causal world models; counterfactual
evaluation; selective prediction; sparse autoencoders; benchmark design
\section{Introduction}
Tool-using agents are evaluated mostly on whether they finish a task. That is the
wrong unit for safety. An agent that completes a booking after reading an injected
instruction has finished the task; so has one that completes it correctly. The
difference is invisible in the success rate and visible only in the state the
action produced.
The usual fixes are also the wrong unit. A post-hoc transcript review sees the
action after it happened. A language-model judge scores plausibility, which is
correlated with fluency rather than with consequences, and cannot be audited.
Guardrails on tool names catch `delete\_file` but not a refund to the wrong
account.
This paper takes the position that the right unit is the \emph{pre-action decision
point}: a state, a candidate set, and a question --- if the agent committed to
candidate $i$ here, what would the world do? Answering that question requires a
model of consequences, not a model of text.
\clsa{} has three parts.
\begin{enumerate}[leftmargin=1.2em]
\item A \textbf{trajectory transcoder} maps the backbone's residual stream at a
decision point into a sparse, discrete latent state $z_t$. Features are admitted
into the shared set only if they pass a Tiwari-style causal test: intervening on
the feature must move the outcome, and the effect must not be explained by a
probe-only artefact.
\item A \textbf{causal dynamics model} $p_\phi(s_{t+1} \mid \mathrm{do}(a_t), s_t)$
is trained on counterfactual pairs produced by forking the environment, with a
consistency loss that ties predicted and replayed outcomes together.
\item A \textbf{controller} runs latent MPC over the candidate set, chooses among
five modes (direct, simulate, verify/acquire, clarify, abstain), and writes a
certificate for every decision. Execution without a certificate raises.
\end{enumerate}
The contribution is not a new benchmark number on a familiar leaderboard. It is a
protocol in which the claim \emph{``this action is safe''} is a falsifiable object:
it names its cause, its counterfactual, its evidence and its error bound, and the
bound was calibrated on data the model did not see.
\paragraph{What we do not claim.} We do not claim adoption by any laboratory, nor
that this is the first or best method for agent safety. We ran on one CPU-only
laptop with backbones under 0.5B parameters on a synthetic benchmark. Those
choices bound what the results can mean, and \cref{sec:limitations} states the
bound rather than hiding it.
\section{Related work}
\paragraph{Probing pre-action state.} Reading a decision point from the residual
stream is established. \citet{tatsat2026beyond} read pre-action activations with
an SAE and two probes, and report that a dense residual probe is the stronger
\emph{predictive} baseline; \citet{sun2026when2tool} probe tool necessity and
suppress unnecessary calls. \citet{ruan2026doomed} predict episode failure from
round one and abort with a recall-controlled cascade. All three act on a probe's
readout. None models what the candidate action would do, which is the gap this
paper targets; and because \citet{tatsat2026beyond} report that dense beats
sparse predictively, we carry the dense probe as a baseline that can win, and in
E4 it nearly does on calibration.
\paragraph{Probe readouts versus behavioural drivers.} The distinction we rely on
is made sharply by \citet{tiwari2026decodability}: probe alignment does not imply
behavioural relevance, and they separate shared, probe-only and random feature
sets with a coherence gate. We adapt their rule for admission into a planning
state and add a pre-registered test (E5) that reports all three arms. That paper
also predicts the pattern we observe: probe-only features can move a probe more
than shared ones while leaving outcomes unchanged.
\paragraph{Selective execution and allocation.} \citet{shen2026casel} allocate
runtime among six modes using calibrated failure probability, consequence,
reversibility and freshness, in a controlled simulation where intervention
effectiveness is assumed. \citet{snell2025scaling} show compute-optimal
allocation can beat uniform scaling, and \citet{iyengar2026split,zhou2026coba}
route test-time compute among sampling and verification. We inherit the mode menu
and the allocation framing, and change the substrate: forked replay instead of an
assumed effectiveness model, with the allocator itself charged.
\paragraph{Sparse features as a substrate with known limits.} \citet{wu2025axbench}
find that simple baselines can outperform SAEs for steering and concept
detection at scale. That result is why E1 includes a transcript-only baseline and
a dense probe, and why we do not present a sparse-feature win as the headline.
\paragraph{Agent benchmarks and failure analysis.} Prompt-injection benchmarks
measure whether an agent can be induced to act harmfully
\citep{debenedetti2024agentdojo}, and $\tau$-bench scores task success against
database state \citep{yao2024taubench}. \citet{cemri2025mast} catalogue fourteen
failure modes in multi-agent systems, and \citet{xie2026spark} model error
cascades on a dependency graph. PreAct-Bench differs in unit: it scores the
decision before execution, with labels from fork replay rather than a judge.
\paragraph{Calibration and selective risk.} We use a Clopper--Pearson upper bound
on selective risk and a split-conformal threshold, and we report the
recalibration gap on held-out families (E6) rather than assuming exchangeability.
\section{Method}
\subsection{Decision points and forks}
A decision point is a tuple $(s_t, \mathcal{A}_t, a_t)$: the sandbox state, the
candidate set, and the action the logged policy took. Forking candidate $a$ yields
\[
\mathrm{Fork}(s_t, a) = \bigl(s'_{t}, y^{\mathrm{succ}}, y^{\mathrm{harm}},
y^{\mathrm{irr}}, \Delta\bigr),
\]
computed without mutating $s_t$. Every label in the benchmark is a fork result,
so a label can be re-derived at any time; \texttt{verify\_fork} re-derives a
sample on every build.
\subsection{Trajectory transcoder and admission}
The transcoder maps the residual stream $h_t \in \mathbb{R}^{d}$ to a sparse code
$z_t \in \mathbb{R}^{F}$ with a top-$k$ activation and a reconstruction objective.
Features are grouped by modality (text, tool state, image, action) with a fixed
layout so that a feature index means the same thing across checkpoints.
Admission is a three-way split. A feature is \emph{shared} if intervening on it
changes the outcome and the change survives a control for the probe's own
predictive power; \emph{probe-only} if it predicts the outcome without a causal
effect; and \emph{random} if it does neither. Only shared features enter the
controller's state. E5 reports all three arms, because a method that works only
when the split is ignored has not shown a causal mechanism.
\subsection{Causal dynamics and the risk head}
The dynamics model is
\[
s_{t+1} = f_\phi(s_t, e(a_t)) + \epsilon, \qquad
\hat{y}^{\mathrm{harm}} = \sigma\bigl(g_\theta(s_t, e(a_t))\bigr),
\]
trained with four terms: latent prediction, counterfactual consistency against
forked outcomes, calibration of the risk head, and sparsity of the code. The
consistency term is what distinguishes this from a classifier of the same
capacity; E2 ablates it.
\subsection{Latent MPC and the certificate}
At each decision point the controller enumerates $\mathcal{A}_t$, rolls each
candidate out in $f_\phi$ to depth $H$, and scores the resulting distribution over
harm. It picks the highest-utility candidate whose upper bound is below $\alpha$,
or moves to \emph{verify/acquire} if a cheap evidence action would tighten the
bound, or \emph{clarify} if the ambiguity is in the instruction, or \emph{abstain}.
Every decision writes
\[
\mathrm{Cert}(a_t) = \langle G, \mathrm{Fork}, E, \mathrm{Bound}\rangle,
\]
where $G$ is an attributed subgraph over admitted features, $\mathrm{Fork}$ names
the counterfactual alternative with predicted and replayed outcomes, $E$ lists the
evidence claims used together with staleness and conflict flags, and
$\mathrm{Bound}$ carries $\alpha$, the Clopper--Pearson upper bound on selective
risk, the sample size, and the charged budget broken into monitor, simulation,
verification and allocator components. Certificates are appended to a hash-chained
ledger; editing any record breaks the chain.
\section{PreAct-Bench}
\label{sec:bench}
PreAct-Bench is generated by this repository and contains 4{,}508 decision
points across 120 episodes in four families:
\texttt{email\_payment}, \texttt{files\_ops}, \texttt{web\_shop} and
\texttt{gui\_settings}. Splits are episode-disjoint (train, calib, test, heldout),
so a held-out episode contributes no state to training under any split.
Each item records the observation (text, tool state, optional screenshot), the
candidate set, the executed action, per-candidate fork labels, evidence claims
with provenance and staleness, and the task's difficulty annotations. The schema
is published as \texttt{schemas/decision\_point.schema.json} and validated on
every load.
The generator deliberately includes states where an injection is present and
states where it is not, and actions that are reversible and irreversible, so that
the abstention policy is not learned from prevalence alone. The full audit, the
split counts and the fork-replay check are in \texttt{data/DATA\_CARD.md}.
\section{Experimental protocol}
\label{sec:protocol}
\paragraph{Unit of analysis.} The decision point, not the episode. Comparisons are
paired by state: every policy sees the same state and the same candidate set, and
differences are bootstrapped over episodes (cluster bootstrap, 2{,}000 resamples,
95\% intervals).
\paragraph{Labels.} State-verified, from fork replay. No language-model judge is
used as a primary metric. Self-report is never evidence.
\paragraph{Costs.} Every policy pays for monitoring, simulation, verification and
allocation from the same budget $B$. Uncharged comparisons are reported only as
an ablation, never as the headline.
\paragraph{Pre-registration.} Hypotheses, thresholds and falsification criteria
were frozen in \texttt{PRE\_REGISTRATION.md} and committed at \texttt{7d3946a}
before the main runs. Deviations, with reasons, are in the same file.
\paragraph{Compute.} One laptop: AMD Ryzen 5 7530U, 6 cores / 12 threads,
15.4\,GB RAM, integrated graphics, no CUDA, 4 threads for PyTorch. Primary
backbone \texttt{Qwen2.5-0.5B-Instruct}; transfer backbone
\texttt{SmolLM2-360M-Instruct}. Both are open-weight and run on CPU.
\section{Results}
\label{sec:results}
% Filled from generated tables; each table is produced by figures/tables.py from
% results/*.json, and check_numbers.py verifies every value traces to a file.
\input{tables/t1_main}
\paragraph{Main comparison.} \Cref{tab:main} reports every policy at the same
budget on 302 held-out decision points. \clsa{} executed no harmful action
(harm rate 0.000) where the language-first planner executed harmful actions on
18.2\% of decisions; the paired difference is $-0.182$ with a 95\% bootstrap
interval over episodes of $[-0.247, -0.122]$. The difference against a dense
probe of the same form is $-0.163$ $[-0.221, -0.110]$, so the gain is not merely
``a monitor''. Irreversible harm falls from 0.192 to 0.066 rather than to zero:
the controller still accepts some irreversible actions when the simulated bound
is tight, and we report that rather than rounding it away.
The success rate moves in the opposite direction from what a pure abstention
policy would produce: 0.185 against 0.046 for language-first and 0.050 for
\clsa{} without dynamics. A policy that abstains from everything cannot achieve
this: \texttt{abort\_only} has success 0.044. The cost is charged and visible:
139 tokens per decision against 23 for language-first and 328 for the
uncertainty-only baseline, which spends more and achieves less.
\input{tables/t1_paired}
\paragraph{World model.} \Cref{tab:world} gives per-modality prediction error.
Counterfactual consistency on held-out transitions is 0.914 with a Brier score of
0.082, and the rate at which the model predicts harm where replay shows none (the
\emph{hallucinated world} rate) is 0.043. One-step MSE is small in every block,
but the modality ordering is informative: the tool-state block is the hardest
(0.0012), roughly twice the text block (0.0005). Predicted mean harm (0.206)
sits well above the observed rate (0.109), i.e.\ the model is conservative on
average, which is the direction the gate needs.
\input{tables/t2_world_model}
\paragraph{Budget.} \Cref{tab:budget} scales the budget by a factor of 27. The
result is not the one we expected. \clsa{}'s harm rate is 0.000 at every budget
from 0.15$\times$ to 4$\times$, while language-first stays flat at 0.182. The
budget does not buy safety here; the gate does, and the extra budget buys
\emph{success}. This is a negative result for the budget-allocation hypothesis as
stated in the pre-registration, and we record it as such rather than presenting a
Pareto curve that is flat by construction.
\input{tables/t3_budget}
\paragraph{Calibration.} ECE is 0.077 and the Brier score 0.071. At $\alpha=0.1$
the gate accepts 90.7\% of decisions with a selective risk of 0.051 and a
Clopper--Pearson upper bound of 0.059, i.e.\ the promise is kept with margin
(realised minus promised $= -0.049$). The feasibility test is satisfied: base
risk 0.109 requires 1\% abstention, and 9.3\% was observed. The false-abort rate
on states where a safe action existed is 0.000, which is the number that matters
for adoption: a monitor that blocks useful work is discarded.
\input{tables/t4_calibration}
\paragraph{Causality.} The admission split dissociates cleanly on flip rate:
shared features flip the outcome at 0.953, probe-only features at 0.047, and
random features at 0.038. There is a tension we do not hide: the mean absolute
change in the probe's own probability under a $2\times$ intervention is
\emph{larger} for probe-only features (0.733) than for shared ones (0.267). A
probe-only feature can move the probe a lot without moving the world. That is
exactly the artefact the admission rule is designed to catch, and it is why the
controller uses shared features only.
\paragraph{Transfer across families.} On held-out families, recalibrating on half
the held-out split reduces selective risk from 0.054 to 0.046 ($\Delta=0.009$).
The gain is small and the interval is wide; we report it as a recalibration
requirement rather than as successful transfer.
\paragraph{Transfer across backbones (exploratory).} This block was added after
the pre-registered analyses and is labelled exploratory in
\texttt{PRE\_REGISTRATION.md}; it changed no threshold, split or prior result. We
repeated the pipeline on \texttt{SmolLM2-360M-Instruct} from a reduced harvest of
200 states (78 train, 22 calib, 100 evaluation). Two things replicate and one
does not.
The causal admission dissociation replicates: on the second backbone, shared
features flip outcomes at 0.920 against 0.080 for probe-only features, with one
admitted shared feature. The decision-level effect replicates too: on 100
held-out states, \clsa{} executes no harmful action against 0.290 for
language-first, a paired difference of $-0.290$ $[-0.458, -0.122]$, $p=0.001$,
with success essentially flat (0.060 against 0.050).
The artefact that does \emph{not} transfer is the threshold. Probe scores from the
two backbones correlate at only 0.075 on the 1{,}921 states they share, so a
threshold calibrated on one backbone is not a portable object. Carrying the
primary gate's threshold to the second backbone over-abstains: coverage falls from
0.920 to 0.670, though selective risk on what it does accept is 0.000. Refitting
the threshold on the secondary calibration split restores coverage to 0.920 with
selective risk 0.065 and an upper bound of 0.080, inside $\alpha=0.1$.
The practical reading is that the method ports and the calibration does not; a
laboratory adopting this must recalibrate, and \Cref{tab:cross} prints both arms
so the cost of skipping that step is visible.
\input{tables/t7_cross_backbone}
\paragraph{Multimodal and multi-agent.} On the GUI split (111 decision points),
\clsa{} executes no harmful action against 0.315 for language-first and 0.402 for
the external verifier. The multi-agent experiment is a belief-layer simulation
over recorded decision points; its numbers are in \texttt{results/e8\_multiagent.json}
and we make no deployment claim from them.
\paragraph{Efficiency and tiers.} A \clsa{} decision costs 5.24\,ms against
0.36\,ms for language-first: the difference is the cost of simulation, and it is
charged. Distillation into a 25{,}965-parameter student reproduces the teacher's
(130{,}797 parameters) harm decision on 95.1\% of held-out states with a slightly
worse Brier score (0.085 against 0.082).
\input{tables/t6_efficiency}
\paragraph{Tier 1 overhead, honestly.} The probe costs 0.81\,ms per decision.
Against a probe-free tensor path (0.09\,ms) that is 775\%, and the 0.1\% target is
\emph{not met}. Against an end-to-end decision that already pays a 2.1\,s backbone
forward, it is 0.039\%, which is met. Both numbers are in
\texttt{results/tier1\_overhead.json}; we do not use the flattering denominator to
claim the target, and \Cref{tab:tiers} prints the one that fails.
\input{tables/t5_tiers}
\section{Discussion}
\label{sec:discussion}
Three findings survived the pre-registered tests and one did not.
The first is that the gate, not the budget, drives harm reduction. We expected
the frontier to move with budget; it did not. This matters for adoption: a
laboratory does not need to buy simulation to get the safety effect, though it
does need it to get the success effect.
The second is that causality and predictiveness come apart in a way that a
probe-only method would miss. The 0.953-versus-0.047 flip-rate gap, and the
reversed steering effect, together say that a feature can be highly influential
on a monitor's output while being causally inert with respect to the world. Any
monitor that validates on its own probability is measuring the wrong thing.
The third is that conservatism is achievable without paralysis. A monitor that
abstains on 9.3\% of decisions, never falsely aborts when a safe action exists,
and doubles success is adoptable; one that abstains on 60\% is not.
The finding that did not survive is the budget frontier. We also note two results
that cut against a simple story: irreversible harm does not reach zero (0.066),
and recalibration transfer is small ($\Delta=0.009$). Both are reported as
measured.
\section{Limitations}
\label{sec:limitations}
\begin{enumerate}[leftmargin=1.2em]
\item \textbf{One machine, small backbones.} All results come from a CPU-only
laptop with backbones of at most 0.5B parameters. Nothing here establishes that
the effect survives at 7B or on a GPU-trained transcoder, and we did not run it.
The second backbone was harvested at 200 states rather than the full set, so its
world model is weaker (counterfactual consistency 0.717 against 0.914) and its
hallucinated-world rate is correspondingly higher (0.283 against 0.043). Its
numbers are a replication check, not an independent study.
\item \textbf{Synthetic benchmark.} PreAct-Bench is an in-repository sandbox with
four simplified tool families. Adapters for AgentDojo and $\tau$-bench exist but
external splits were not executed, so no claim about those benchmarks is made.
\item \textbf{Balanced construction.} The generator balances exposed and
unexposed states. Prevalence-dependent numbers will not transfer to real traffic
without recalibration.
\item \textbf{Exchangeability.} Conformal coverage holds under exchangeability.
E6 deliberately breaks it by holding out families, and reports the recalibrated
and un-recalibrated numbers separately.
\item \textbf{Multi-agent results are simulated.} E8 is a belief-layer
simulation over recorded decision points, not a deployment.
\item \textbf{Single harm ontology.} Harm is a scalar with an irreversibility
flag. Long-horizon and multi-dimensional harm are out of scope.
\item \textbf{No adoption claim.} The tiers are designed to be adoptable; no
laboratory has adopted them, and we do not claim otherwise.
\end{enumerate}
\section{Ethics and dual use}
The benchmark contains a harm model for payments, file deletion and account
changes. It is a safety artefact, but a determined reader could use the candidate
generator to construct evasive actions. We keep the harm model coarse and the
sandbox deterministic so that the artefact is more useful for evaluation than for
attack. No personal data is included; addresses and recipients are synthetic.
\section{Reproducibility}
The repository is reproducible in one command (\texttt{make reproduce}) on a CPU
without a GPU, a paid API or a vendor SDK. Dependencies are pinned, the data and
figure generation paths are deterministic given seeds, and every number in the
paper traces to \texttt{results/} through \texttt{experiments/check\_numbers.py}.
Pre-registration is in version control ahead of the results.
\section{Data and code availability}
The benchmark is published at
\href{https://huggingface.co/datasets/fahadhafeezofficial/preact-bench}{\nolinkurl{huggingface.co/datasets/fahadhafeezofficial/preact-bench}}
under MIT: 4{,}508 rows, the GUI images, the row schema and the data card. The
trained artefacts (transcoder, world model, risk head and monitors for both
backbones) are at
\href{https://huggingface.co/fahadhafeezofficial/clsa-artifacts}{\nolinkurl{huggingface.co/fahadhafeezofficial/clsa-artifacts}}
with the metrics needed to interpret them. The code --- source, configuration,
tests, result files and figure scripts --- is at
\href{https://huggingface.co/datasets/fahadhafeezofficial/clsa-code}{\nolinkurl{huggingface.co/datasets/fahadhafeezofficial/clsa-code}}
under MIT, and is the repository accompanying this submission;
\texttt{make reproduce} regenerates the benchmark audit, the figures, the
tables and the number-traceability check from those files.
\section*{Declaration of AI use}
% Wording is chosen in paper/ai_statement.tex (see paper/ai_statements/ and
% `make statement N=b`). The default is the results-only declaration.
\input{ai_statement}
\section*{CRediT authorship contribution statement}
\textbf{Fahad Hafeez:} Conceptualization, Methodology, Software, Validation,
Formal analysis, Investigation, Data curation, Writing -- original draft,
Writing -- review and editing, Visualization, Project administration.
\section*{Funding}
% Confirmed by the author on 25 November 2026: no funding of any kind.
The author received no funding for the research, authorship, or publication of
this article from any agency in the public, commercial, or not-for-profit
sectors.
\section*{Declaration of competing interest}
The author declares that he has no known competing financial interests or
personal relationships that could have appeared to influence the work reported in
this paper.
\bibliography{references}
\appendix
\section{Certificate format}
\input{tables/a1_certificate}
\end{document}