cs.PLApr 13, 2026

λAλ_A: A Typed Lambda Calculus for LLM Agent Composition

Authors: Qin Liu

Organizations: State Key Laboratory of Novel Software Technology, Nanjing University, Nanjing, Jiangsu, China · Software Institute, Nanjing University, Nanjing, Jiangsu, China

Abstract

Existing LLM agent frameworks lack formal semantics: there is no principled way to determine whether an agent configuration is well-formed or will terminate. We present λAλ_A, a typed lambda calculus for agent composition that extends the simply-typed lambda calculus with oracle calls, bounded fixpoints (the ReAct loop), probabilistic choice, and mutable environments. We prove type safety, termination of bounded fixpoints, and soundness of derived lint rules, with full Coq mechanization (1,519 lines, 42 theorems, 0 Admitted). As a practical application, we derive a lint tool that detects structural configuration errors directly from the operational semantics. An evaluation on 835 real-world GitHub agent configurations shows that 94.1% are structurally incomplete under λAλ_A, with YAML-only lint precision at 54%, rising to 96--100% under joint YAML+Python AST analysis on 175 samples. This gap quantifies, for the first time, the degree of semantic entanglement between declarative configuration and imperative code in the agent ecosystem. We further show that five mainstream paradigms (LangGraph, CrewAI, AutoGen, OpenAI SDK, Dify) embed as typed λAλ_A fragments, establishing λAλ_A as a unifying calculus for LLM agent composition.

Figures & tables

Explore similar work

CardsList
  1. Position: A Three-Layer Probabilistic Assume-Guarantee Architecture Is Structurally Required for Safe LLM Agent Deployment

    May 18, 2026S. Bensalem, Y. Dong, M. Franzle +6AI Agent ReliabilityLLM Guardrails

  2. The LLMbda Calculus: AI Agents, Conversations, and Information Flow

    Feb 23, 2026Zac Garby, Andrew D. Gordon, David SandsPrompt Injection Attacks on AI AgentsLLM Agent Harnesses

  3. LLM-as-Code: Agentic Programming for Agent Harness

    Jun 14, 2026Junjia Qi, Zichuan Fu, Jingtong Gao +4AI Agent ReliabilityLLM Agent Orchestration