← Lab /Software

Prompt injection can corrupt LLM agents, but a formal calculus can guarantee safety

The introduced lambda calculus provides integrity and confidentiality guarantees for LLM agent conversations

Software arXiv 23 Feb 2026 Theory Theory

Published as “The LLMbda Calculus: AI Agents, Conversations, and Information Flow”

Why it matters

Provides a rigorous foundation for designing AI agents that are provably resistant to prompt-injection attacks, informing safer deployment of LLM-driven automation.

Summary

The paper proves a termination-insensitive noninterference theorem that guarantees integrity and confidentiality for AI agents built with LLM calls, and shows via a prototype interpreter that the dual-LLM (privileged/quarantined) pattern blocks prompt-injection attacks. The evidence consists of a formal calculus, a theorem proof, and small example implementations, but no large-scale empirical evaluation.

What they found 2

  1. A termination-insensitive noninterference theorem guarantees that information at a lower label cannot affect higher-label observations.

    “Section IV presents our main technical result, Theorem 1, is a termination-insensitive noninterference theorem. Ignoring termination behaviour, information labelled at level m cannot affect observations at level n unless m ⊑n.”

  2. The dual-LLM (privileged/quarantined) pattern prevents the demonstrated prompt-injection attack.

    “Moreover, we demonstrate that the dual LLM pattern defeats this attack, and that label tracking and testing in our lambda calculus model CaMeL’s use of capabilities.”

Caveats 5

  • The calculus assumes deterministic LLM responses, which limits applicability to real stochastic models.
  • The liberal design of label testing is incompatible with noninterference in the general case, requiring restrictive constraints.
  • One limitation of our formalisation is an assumption of LLM determinism.
  • Another limitation of our approach is our modelling of tool calls, and in particular how we model data sources.
  • Our development in Section VI centres on different versions of a single example, and we have not presented a full model of the CaMeL system.

What’s new here 4

  • Introduces a lambda calculus extended with primitives (@, fork, clear) to model prompt-response conversations and tool-calling agents.
  • Provides a formal termination-insensitive noninterference theorem for dynamic label checks in agentic programs.
  • Models prompt-injection attacks and demonstrates that the dual-LLM (privileged/quarantined) pattern mitigates them within the calculus.
  • Implements an executable interpreter that ties the abstract semantics to real LLM API calls.