When a language model codes interview transcripts for a qualitative study, two different things go wrong at once. The interpretation changes from run to run: the same transcript yields different codes and themes. The paper trail also breaks: a theme cites a quote that was never said, a merge silently drops the segments that supported a code, or a participant's identifying detail leaks into a theme summary. Current automated pipelines treat both as one blurry "reliability" problem and attack it with more sampling, larger ensembles, or stronger closed models. We argue these should be split. Thematic analysis (the qualitative method of labeling text segments with short descriptive codes and grouping codes into themes) legitimately admits many valid interpretations, so demanding identical codebooks across runs is the wrong target. The paper trail has no such excuse. Whether every theme traces back to real, attributed, de-identified quotes is a yes-or-no property, and it can be guaranteed no matter what the model says.
The proposal is to run multi-agent thematic coding with open-weight models inside a small, explicit message protocol. Every code proposal and every edit (add, split, combine, delete) is a typed message checked at the moment it is sent by a deterministic monitor. The design of that monitor is verified once, with a model checker, against the worst case in which the language model is treated as an adversary that may emit any message at all. Output variability then stops being something to suppress and becomes the threat model. The guarantees hold for any sampled output, and the variability left over is confined to the interpretive layer, where it can be measured and reported honestly. Open weights matter here for a concrete reason rather than an ideological one: only a locally run model gives an audit log that a third party can replay against the same weights.
Core Claim
Our main claim is that enforcing provenance invariants at every step of an open-model coding pipeline has two effects. It drives invariant violations to zero, which is expected by construction. More importantly, it measurably reduces run-to-run variance in the interpretive layer. Checking only the finished codebook after the fact cannot do this. The mechanism comes from Evaluating Stochasticity in Deep Research Agents, which treats research agents as a multi-stage decision process. That paper found that early noise cascades into divergent downstream trajectories, that the reasoning stage contributes most of the variance, and that higher stochasticity does not buy accuracy. In a coding pipeline, an early fabricated or orphaned code seeds later merges and theme names. Rejecting it at the step where it appears should cut the cascade. If the variance reduction does not appear, the protocol is still a useful audit tool, and we will report it as nothing more than that.
The invariants are deliberately few and concrete. Grounding requires that every code attach to at least one verbatim span, identified by character offsets that exist in the corpus. Conservation requires that edits move support rather than lose it. A split must partition its parent's segments, a combine must take their union, and a delete must either reassign its segments or explicitly release them with a logged reason. Support requires that a theme rest on codes drawn from at least a configurable number of distinct participants. Isolation requires that agents naming themes see only de-identified segments, and that identity fields never flow into any output. Attribution requires that every edit carry its issuing agent, its step, and a hash-chained link to the previous state, so that replaying the log reconstructs the codebook exactly. Everything else is interpretive and allowed to vary: label wording, which codes are grouped together, and how themes are named.
Relation to Prior Work
Three systems motivate the gap. Auto-TA builds a GPT-4o multi-agent pipeline in which persona-conditioned coders, theme generators, and critics issue add, split, combine, and delete instructions. It reports roughly 99% time savings, and it also reports prompt sensitivity and a one-way critic loop with no checks on what edits do to the evidence. Measuring What Matters fine-tunes open 7–8B models with low-rank adapters, ensembles them under a moderator, and merges near-duplicate labels by sentence-embedding similarity. Its fine-tuned Mixtral 8x7B ensemble reaches a Composite Score of 0.99, against 0.44 for GPT-4 alone and 0.74 for a GPT-4 ensemble. Its threshold merging, however, is exactly the kind of edit that can collapse distinct codes or strand their quotes unnoticed. HICode separates label generation from recursive LLM clustering and reaches 0.72 precision and 0.74 recall against human judges on Astro Queries. All three optimize the interpretation. None states or enforces what the pipeline must never do to the evidence, and we add that layer on top of any of them.
Two lines of work supply the method. A Framework for Formalizing LLM Agent Security recasts agent safety as contextual authorization, expressed through properties such as source authorization and data isolation. It leaves the required attribution functions as intractable oracles. Our observation is that in a coding pipeline these oracles become trivial: source attribution is a character offset, and instruction attribution is the sender field of a typed message. The pipeline is therefore an unusually clean place to instantiate that framework. MCIP logs tool calls as contextual-integrity tuples (sender, recipient, data subject, information type, transmission principle), which we reuse for our isolation invariant. MCIP enforces those tuples with a learned guardian model, and it documents that tool-tuned models over-approve requests. That finding constrains our design: our monitor is rule-based and deterministic, not a second model. For verification we use MCMAS, a model checker for multi-agent systems that can express knowledge properties such as "the theme agent never comes to know a participant identifier." Its knowledge-based logic descends from the epistemic treatment of authentication in An Epistemic Foundation for Authentication Logics. We borrow from the symbolic Dolev-Yao tradition the move of giving the adversary full control of message content. The difference is that our adversary is the model's own sampler, not a network attacker.
Two lines of work set our measurement stance. An Empirical Study of the Non-Determinism of ChatGPT in Code Generation found that 43.64% of CodeContests tasks gave no identical test outputs across five requests even at temperature 0. Stability Analysis of ChatGPT-based Sentiment Analysis documents silent behavior shifts in a commercial API between June and December 2023. Together they argue that closed endpoints cannot support replayable audits. On the parity side, HerO and AGORA show that pipelines of open models reach near-frontier results on fact-checking and reasoning. AGORA also finds that simple strategies often beat elaborate agent algorithms on stability, a warning we heed by keeping the protocol minimal.
Research Program
The first component is a protocol specification. It fixes a small set of typed messages (propose-code, add, split, combine, delete, name-theme, release), a codebook state made of codes, segment assignments, themes, and a de-identification map, and the five invariants written as predicates over state transitions. We abstract this specification into a finite multi-agent model: a bounded corpus of a few participants and segments, with coder, critic, moderator, and theme-namer agents whose message content is left unconstrained. We then check it in MCMAS. The expected payoff is a set of counterexamples found at design time. One candidate is a combine followed by a delete that orphans segments. Another is a theme renamed after its supporting codes were deleted. A third is identity leaking through a quote the namer was given as context. We will fix the monitor rules until the checker certifies them. The limits of this guarantee should be stated plainly. The checker verifies the monitor's rules over a bounded abstraction, not the language model and not the unbounded corpus. The runtime monitor then enforces those same rules on real runs.
The second component is the runtime. It is a thin, deterministic monitor wrapped around an existing pipeline. The monitor rejects any violating message and returns a structured error to the sending agent for at most a fixed number of retries. It also appends each accepted edit to a hash-chained log. We instantiate the monitor around three pipelines: a HICode-style two-stage pipeline, a moderated ensemble in the style of Measuring What Matters, and a critic-loop pipeline in the style of Auto-TA. All three run on Llama-3.1 8B and 70B and on Qwen2.5 7B and 72B, served locally with pinned weights, pinned kernels, and logged seeds.
The third component is a variance decomposition. Following the multi-run vectorization idea of the deep-research stochasticity study, we run each configuration many times per corpus and embed codes and themes. We compute total variance separately for the interpretive layer, using theme-set dispersion under embedding matching, and for the invariant layer, using violation counts. We vary three conditions: seeds only, paraphrased prompts, and model family.
Baselines
The naive reference point is a single-pass open model that codes and themes each corpus with no ensemble, no critic, and no monitor. It sets the floor for quality, violation rate, and variance. We run it on the same corpora, models, and seeds as every other condition.
The strongest existing open method is the moderated, fine-tuned ensemble with embedding-threshold refinement from Measuring What Matters, which reports a Composite Score of 0.99 on its code-quote benchmark. We reproduce it on that benchmark first. Only if we recover a score near the reported one do we use it elsewhere, and we then run it with and without our monitor. For theme-level quality, the strongest reported number is HICode's 0.72 precision and 0.74 recall on Astro Queries, from HICode. We reimplement it on our open models and apply the same monitored and unmonitored comparison. For the critic-loop design we reimplement the Auto-TA agent roles on open models. No reported result was found on Lacuna for Auto-TA on any public benchmark, since its AAOCA transcripts are clinical, so this comparison relies on our own runs. Where budget allows, we also run a GPT-4o version as the closed reference. All baselines get the same token budget per corpus, including the retries our monitor triggers, so that our system cannot win simply by spending more.
Beating a baseline means four things together: equal or better theme precision and recall or Composite Score, zero invariant violations against a nonzero rate for the baseline, lower interpretive-layer variance across seeds and paraphrases, and token cost within the same budget.
Two ablations isolate the key ingredient. The post-hoc validator checks the same five invariants only on the final codebook and discards or repairs failing runs. This separates the value of step-level enforcement from the value of simply having the invariants. The unverified monitor enforces rules written by hand without the model-checking pass. This separates the value of formal verification from runtime checking alone.
Why not just…?
Why not just check the final codebook against the transcripts after the run? This is the most serious alternative, and it is a real threat. A post-hoc checker catches fabricated quotes and coverage loss in the end state as reliably as our monitor does. It differs in two ways. It can only reject or patch whole runs, and it cannot stop an early bad code from shaping later merges and theme names. The post-hoc ablation settles the question directly. If it matches our system on quality and interpretive variance at similar cost, the step-level protocol adds nothing beyond audit convenience, and we will say so.
Why not just make inference deterministic with greedy decoding on pinned hardware? Local open models can indeed be made bit-reproducible, and we use this for log replay. Determinism, though, reproduces one arbitrary interpretation. It does not bound how that interpretation shifts under a paraphrased prompt or a different model. It also does nothing about fabricated quotes, which a greedy run produces just as repeatably as a sampled one. The code-generation study's temperature-0 results show that greedy settings alone are not even reliable determinism on commercial stacks. Our paraphrase and cross-model conditions, run under greedy decoding, will show how much interpretive variance determinism merely hides.
Why not just use a frontier closed model with a critic loop, as Auto-TA does? A closed model may produce better themes. It cannot provide a replayable audit, because backend weights change silently, as the sentiment stability study documents. Protected transcripts also often cannot leave the institution at all. Our parity comparison against a GPT-4o critic loop measures the quality cost, if any, of staying open. That comparison is honest only if we report it even when the open pipeline loses.
Why not just use a learned guard model, as MCIP does? A learned guard is itself stochastic and, per MCIP's own results, prone to approving whatever it is asked to approve. The invariants here are decidable string and set predicates, so a model adds error without adding coverage.
Proposed Experiments
We use the public corpora from the file. Astro Queries, Media Frames, and ML Values from the HICode evaluation serve for theme precision and recall against their human annotations. The social-science code-quote pairs, SemEval-2014, and ChatGPT reviews from Measuring What Matters serve for Composite Score, whose 0.73 Spearman correlation with experts makes it a usable automatic proxy. The Opioid Industry Documents Archive serves as a long, messy real corpus for violation rates and cost. The AAOCA transcripts will be used only if access is granted. To test isolation we inject synthetic identifiers into participant segments and measure leakage into theme outputs, using the contextual-integrity framing of Contextual Integrity in LLMs via Reasoning and Reinforcement Learning to define what counts as a leak.
The decisive check is the comparison of the monitored pipeline against the post-hoc validator ablation on interpretive-layer variance across 20 seeds and five prompt paraphrases per corpus. We need to establish how often unmonitored pipelines violate the invariants and how much interpretive variance each condition shows. The core claim survives only if step-level enforcement lowers that variance at matched token budget without lowering theme precision and recall or Composite Score. A second check tests whether the model-checked monitor catches violation types in real runs that the hand-written monitor misses. A third, the parity test, asks whether monitored 8B and 70B open pipelines come within the variance-derived confidence interval of the GPT-4o reference on theme quality. Finally, an external auditor replays a sample of logs on the pinned weights and confirms that the codebooks are reconstructed bit-for-bit, the one property no closed-model pipeline can offer.
References
- Evaluating Stochasticity in Deep Research Agents
- Auto-TA: Towards Scalable Automated Thematic Analysis (TA) via Multi-Agent Large Language Models with Reinforcement Learning
- Measuring What Matters: Evaluating Ensemble LLMs with Label Refinement in Inductive Coding
- HICode: Hierarchical Inductive Coding with LLMs
- A Framework for Formalizing LLM Agent Security
- MCIP: Protecting MCP Safety via Model Contextual Integrity Protocol
- MCMAS: an open-source model checker for the verification of multi-agent systems
- An Epistemic Foundation for Authentication Logics (Extended Abstract)
- An Empirical Study of the Non-Determinism of ChatGPT in Code Generation
- Stability Analysis of ChatGPT-Based Sentiment Analysis in AI Quality Assurance
- HerO at AVeriTeC: The Herd of Open Large Language Models for Verifying Real-World Claims
- Unifying Language Agent Algorithms with Graph-based Orchestration Engine for Reproducible Agent Research
- Contextual Integrity in LLMs via Reasoning and Reinforcement Learning