The Dual-State Architecture for Reliable LLM Agents
Matthew Thompson

TL;DR
This paper introduces the Dual-State Architecture and DSAP primitive to enhance the reliability of LLM code generation agents by combining stochastic outputs with deterministic verification, improving success rates.
Contribution
It formalizes the DSAP primitive, proposes a three-level recovery hierarchy, and demonstrates significant reliability improvements across multiple LLMs and diagnostic benchmarks.
Findings
Reliability gains of up to 66 percentage points at 1.2-2.1x baseline cost.
100% context injection effectiveness in recovery scenarios.
Step-specific recovery effectiveness varies, with 37.5% for test generation.
Abstract
Large Language Models deployed as code generation agents exhibit stochastic behavior incompatible with the deterministic guarantees required by software engineering. We formalize the Dual-State Action Pair (DSAP), an execution primitive that couples stochastic generation with deterministic post-condition verification. Guard functions act as sensing actions that project opaque LLM outputs onto observable workflow state, enabling a dual-state decomposition: finite, deterministic S_workflow paired with infinite, stochastic S_env. We prove that for epsilon-capable generators, failure probability P(fail) <= (1-epsilon)^R_max -> 0. To prevent naive O(R^K) retry explosion across multi-step workflows, we introduce a three-level recovery hierarchy: context refinement (retry within step), informed backtracking (stagnation detection with cascade invalidation and context injection to upstream…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
