Lean4Agent: Formal Modeling and Verification for Agent Workflow and Trajectory
Ruida WANG, Jerry Huang, Pengcheng Wang, Xuanqing Liu, Luyang Kong, Tong Zhang
NeurIPS 2026
TL;DR. This paper presents Lean4gent, to the best of our knowledge, the first framework that applies dependent-type formal language to model and verify LLM agent workflow and trajectory in a unified manner.
Abstract. Equipping Large Language Models (LLMs) to execute reliable multi-step workflows has become a central challenge in artificial intelligence. Despite recent advances in LLMs' agentic capabilities, most agent systems still lack formal methods for specifying, verifying, and debugging their workflow and execution trajectories. This challenge mirrors a long-standing problem in mathematics, where the ambiguity of natural languages (NLs) motivates the development of formal languages (FLs). Inspired by this paradigm, we propose Lean4Agent, to the best of our knowledge, the first framework that uses Lean4, a dependent-type FL to model and verify agent behavior. Lean4Agent launches FormalAgentLib, an extensible Lean4 library for formally modeling and verifying agent workflows' semantic consistency under explicit assumptions, and enabling localization of execution-time failures revealed by trajectories. Building on FormalAgentLib, we further develop LeanEvolve, which applies results in FormalAgentLib to revise workflows to enhance its capability. Extensive experiments on a hard problem subset of SWE-Bench-Verified and a subset of ELAIP-Bench across 5 leading LLMs indicate that the verification-passing workflows outperform the failing ones by an average of 11.94%, and LeanEvolve further improves SWE performance by 7.47% on average. Furthermore, Lean4Agent establishes a foundation for a new field of using expressive dependent-type FL to formally model and verify agent behavior.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:44 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
Summary of claims and findings The paper proposes Lean4Agent, which the authors claim is the first framework to use Lean4, a dependent-type formal language, to model and verify LLM-agent workflows and execution trajectories. It comprises FormalAgentLib, a Lean4 library with a three-layer verification stack, and LeanEvolve, which uses verification feedback to revise workflows. Verification-passing workflows outperform failing ones by 11.94% on average.
Main strengths Reviewers agree the direction of bringing formal specification/verification to increasingly complex agent workflows is meaningful. The three-layer architecture is well-designed as it cleanly transfers a program-verification decomposition to the agent setting, and dependent types offer expressiveness beyond temporal-logic or SMT approaches. The empirical results are solid with the improvements most pronounced on weaker models.
Main weaknesses First, the "formal verification" framing may be overstated. The semantic layer rests on the LLMExec assumption (if a step's preconditions hold, the LLM produces postconditions), a strong assumption for black-box agents. Lean thus verifies the consistency of a workflow abstraction under assumptions, not that the LLM actually follows the intended semantics. The trajectory layer partially compensates but then falls back on external tools and an LLM-as-judge. PKw6 asks that the paper cleanly separate "verification of a workflow abstraction under assumptions" from "verification of actual agent behavior" and tone down guarantee language.
Second, the semantic predicates are LLM-generated. If predicates are wrong, weak, or incomplete, Lean will certify the wrong abstraction. No quantitative analysis of predicate quality or LLMExec violation rates is provided.
Third, the evaluation focuses on comparison between passing vs. failing workflows, but these groups may differ in general quality for reasons unrelated to Lean verification. The paper lacks the controlled experiment that would isolate the verification signal e.g. repairing the specific failed predicates and measure before/after.
Other points: contribution differentiation from prior structured-workflow and tool-verification work (LangChain graphs, PDL, AgentSPEX, ToolGate, VeriGuard) and what dependent types uniquely provide is underdeveloped.
What could shift the recommendation
- Reframe the guarantees. Explicitly state what is proved in Lean vs. assumed.
- Isolate the verification signal. Add a causal experiment to show the 11.94% is not just selecting better workflows.
- Quantify predicate reliability. Report an error rate for LLM-generated predicates and an ablation to show whether the framework detects misspecification or propagates it.
- Sharpen positioning and scope: differentiate from prior workflow/tool-verification work and state what dependent types uniquely enable; clarify when Lean suffices vs. when the LLM-as-judge is invoked and how often they disagree.
Final justification
I read the authors' response and the full discussion. The authors clarified that Lean verifies the workflow abstraction under explicit assumptions, rather than guaranteeing the behavior of the black-box LLM, and agreed to revise the framing accordingly. They added controlled repair experiments in which fixing the diagnosed workflow defects improved performance on both SWE-Bench and ELAIP-Bench, providing stronger evidence that the verification signal is useful rather than merely selecting better workflows. They also manually audited the predicate annotations, and correcting the identified errors did not change any verification outcome. The response further clarified the advantages of dependent types, the distinction from prior workflow and tool-verification systems, and the roles of formal checks, external tools, and LLM-based judgments. The main remaining limitation is that the guarantees still depend on the quality and completeness of the predicates and on the LLMExec assumption.
Overall, Lean4Agent presents a well-designed use of formal methods for agent workflows. Although the framework does not verify the behavior of the underlying LLM itself, this boundary is now clearly stated and does not undermine the value of verifying workflow structure, information flow, and execution trajectories.
Read meta-review
Meta-review
Summary of claims and findings The paper proposes Lean4Agent, which the authors claim is the first framework to use Lean4, a dependent-type formal language, to model and verify LLM-agent workflows and execution trajectories. It comprises FormalAgentLib, a Lean4 library with a three-layer verification stack, and LeanEvolve, which uses verification feedback to revise workflows. Verification-passing workflows outperform failing ones by 11.94% on average.
Main strengths Reviewers agree the direction of bringing formal specification/verification to increasingly complex agent workflows is meaningful. The three-layer architecture is well-designed as it cleanly transfers a program-verification decomposition to the agent setting, and dependent types offer expressiveness beyond temporal-logic or SMT approaches. The empirical results are solid with the improvements most pronounced on weaker models.
Main weaknesses First, the "formal verification" framing may be overstated. The semantic layer rests on the LLMExec assumption (if a step's preconditions hold, the LLM produces postconditions), a strong assumption for black-box agents. Lean thus verifies the consistency of a workflow abstraction under assumptions, not that the LLM actually follows the intended semantics. The trajectory layer partially compensates but then falls back on external tools and an LLM-as-judge. PKw6 asks that the paper cleanly separate "verification of a workflow abstraction under assumptions" from "verification of actual agent behavior" and tone down guarantee language.
Second, the semantic predicates are LLM-generated. If predicates are wrong, weak, or incomplete, Lean will certify the wrong abstraction. No quantitative analysis of predicate quality or LLMExec violation rates is provided.
Third, the evaluation focuses on comparison between passing vs. failing workflows, but these groups may differ in general quality for reasons unrelated to Lean verification. The paper lacks the controlled experiment that would isolate the verification signal e.g. repairing the specific failed predicates and measure before/after.
Other points: contribution differentiation from prior structured-workflow and tool-verification work (LangChain graphs, PDL, AgentSPEX, ToolGate, VeriGuard) and what dependent types uniquely provide is underdeveloped.
What could shift the recommendation
- Reframe the guarantees. Explicitly state what is proved in Lean vs. assumed.
- Isolate the verification signal. Add a causal experiment to show the 11.94% is not just selecting better workflows.
- Quantify predicate reliability. Report an error rate for LLM-generated predicates and an ablation to show whether the framework detects misspecification or propagates it.
- Sharpen positioning and scope: differentiate from prior workflow/tool-verification work and state what dependent types uniquely enable; clarify when Lean suffices vs. when the LLM-as-judge is invoked and how often they disagree.
Final justification
I read the authors' response and the full discussion. The authors clarified that Lean verifies the workflow abstraction under explicit assumptions, rather than guaranteeing the behavior of the black-box LLM, and agreed to revise the framing accordingly. They added controlled repair experiments in which fixing the diagnosed workflow defects improved performance on both SWE-Bench and ELAIP-Bench, providing stronger evidence that the verification signal is useful rather than merely selecting better workflows. They also manually audited the predicate annotations, and correcting the identified errors did not change any verification outcome. The response further clarified the advantages of dependent types, the distinction from prior workflow and tool-verification systems, and the roles of formal checks, external tools, and LLM-based judgments. The main remaining limitation is that the guarantees still depend on the quality and completeness of the predicates and on the LLMExec assumption.
Overall, Lean4Agent presents a well-designed use of formal methods for agent workflows. Although the framework does not verify the behavior of the underlying LLM itself, this boundary is now clearly stated and does not undermine the value of verifying workflow structure, information flow, and execution trajectories.
- Rating
- 4/6
- Confidence
- 5/5
- Quality
- 2/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 2/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
So they introduce Lean4Agent, a framework for modeling and checking LLM-agent workflows using Lean 4. The framework has three layers: structural workflow checks, predicate-based static semantic checks, and trajectory-level failure localization. The authors also propose LeanEvolve, which uses verification feedback and optional environment feedback to revise workflows. The evaluation uses subsets of SWE-Bench-Verified and ELAIP-Bench across five LLMs, comparing verification-passing workflows against verification-failing ones and measuring whether workflow evolution improves task performance:)!
Strengths and weaknesses
I liked the direction. Agent workflows are getting more complex, and it is reasonable to ask whether formal methods can help specify and debug them. The paper tries to make this concrete instead of just saying “use formal verification for agents.” The layered design is also sensible: first check graph/type/read-write structure, then check semantic pre/postconditions, then inspect trajectories for runtime failures. That organization is pretty neat and gives the framework a clear shape. The case studies are also useful. The examples around missing JSON fields, context-isolated steps, and bad verification behavior in SWE agents are the kinds of errors that really do show up in agent workflows. I appreciated that the paper gives concrete workflow snippets and Lean-style diagnostic outputs, rather than only reporting aggregate numbers. The empirical results are also encouraging: verification-passing workflows do better than failing workflows on both SWE and paper-understanding tasks, and LeanEvolve seems to add further gains.
However, I have a major concern about the strength of the “formal verification” framing. A lot of the semantic layer depends on the LLMExec assumption: roughly, if a step’s preconditions hold, then the LLM can produce outputs satisfying the postconditions. That is a very strong assumption for black-box LLM agents. The Lean checks may verify consistency of the workflow specification under this assumption, but they do not verify that the LLM actually follows the intended semantics. The trajectory layer helps, but then the system partly falls back to external tools and LLM-as-judge. So the formal part is useful, but it is not as strong as the framing sometimes suggests. I also worry about the automatic predicate annotation step. The semantic predicates are generated from natural-language workflow instructions by an LLM. If the predicates are incomplete, too weak, or simply wrong, then the Lean verification can certify the wrong abstraction. This is not just a small implementation detail; it is central to whether the framework is checking meaningful properties. The authors mention this limitation, but I think it deserves much more emphasis in the main discussion.
The evaluation is promising but not fully causal. The main comparison is between workflows that pass verification and workflows that fail verification. But these groups may differ in overall quality for reasons unrelated to Lean verification. In other words, passing workflows may simply be better-written workflows. I would have liked a stronger causal experiment: take the same failing workflow, repair the exact failed predicates, and compare before/after across many tasks; or perturb passing workflows to introduce controlled semantic violations and check whether the verifier predicts the performance drop.
Another issue is reproducibility. The code is not released at submission time, and the experiments rely on expensive closed/commercial LLMs. Given that this is a tooling/framework paper, the lack of a submission-time artifact makes it hard to inspect how much of the Lean library is actually general, how predicates are generated, and how robust the checking pipeline is. So my take is mixed. The idea is timely and the results are interesting, but the current version overstates what is formally verified and does not yet convince me that the verification signal is isolated from general workflow quality. I would be more positive if the authors toned down the formal-guarantee language, released the artifact, and added stronger causal ablations.
Questions
-
Can the authors clarify exactly what is proved in Lean versus what is assumed? In particular, how should readers interpret the guarantee under the LLMExec axiom?
-
Can the authors include a clearer, compact example of what is actually encoded and checked in Lean? For example, it would help to show one full workflow step, its generated predicates, the corresponding Lean statement, and the final theorem/check that passes or fails.
-
How reliable are the LLM-generated predicates? Can the authors evaluate predicate quality manually or with an ablation where predicates are weakened, strengthened, or corrupted?
-
Can the authors provide a more causal evaluation of verification? For example, repair the specific verification failures in a workflow and compare before/after performance across many tasks.
-
How much of the improvement comes from selecting generally better workflows rather than from formal verification itself? A comparison with human/LLM workflow-quality scoring or random workflow filtering would help.
-
What kinds of agent failures are out of scope? For example, does the approach handle hallucinated reasoning, wrong code edits, incomplete exploration, hidden tool failures, or only failures expressible through the chosen predicates?
Limitations
Partially. The appendix discusses important limitations, including black-box LLM behavior, semantic ambiguity, LLM-generated predicate annotations, and difficulty evaluating some components. However, I think these issues should be much more central in the main text. In particular, the paper should more clearly separate “formal verification of a workflow abstraction under assumptions” from “verification of actual LLM-agent behavior.”
Final justification
They clarified all my concerns!
Formatting concerns
N/A
3 comments
Response to the Authors
Thanks for the detailed rebuttal. The predicate audit and the new before/after repair results address most of my concerns and make the causal story much stronger. I also appreciate the clearer explanation that Lean verifies the workflow abstraction under explicit assumptions, rather than the behavior of the black-box LLM itself.
Some limitations remain around predicate completeness and the LLMExec assumption, but the response is convincing overall. I am updating my rating from 3 to 4!:)
Thank you for your review
Thank you so much for your review and for recognizing our work. We are pleased that the rebuttal has resolved most of your concerns and welcome the increase in rating. We are also glad to address any further questions you may have.
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 2/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This work addresses the central challenge of equipping Large Language Models (LLMs) with mathematically provable properties for reliable multi-step workflow execution. The claims of the paper are: (1) FormalAgentLib is an extensible Lean4 library for formally modeling and verifying agent workflows' semantic consistency under explicit assumptions; (2) LeanEvolve uses verification feedback to refine workflows and improve performance; (3) Verification-passing workflows outperform failing ones by an average of 11.94%, and LeanEvolve further improves SWE performance by 7.47% on average.
Strengths and weaknesses
Strengths:
- This paper tackles a clear and important problem: improving the reliability of LLM-based agent systems through formal methods. The need for formal specification, verification, and debugging of agent workflows and execution trajectories is well-motivated, especially given the deployment of complex LLM-agent workflows in high-stakes domains.
- The three-layer verification architecture is well-designed and technically sound. The separation into structural verification (Layer 1), predicate-based static semantic verification (Layer 2), and execution trajectory verification (Layer 3) provides a principled decomposition of the verification problem. The use of dependent-type theory (Lean4) as the underlying formal language is appropriate and offers strong expressiveness advantages over temporal logic or SMT-based approaches.
- The empirical results are strong and statistically significant. Verification-passing workflows consistently outperform failing ones across 5 models and 2 benchmarks (SWE-Bench-Verified and ELAIP-Bench), with 95% bootstrap confidence intervals provided. The improvements are particularly pronounced for smaller models (e.g., Gemma-4-31B shows 27.33% improvement on SWE), suggesting the framework is especially valuable for less capable agents.
Weaknesses
- The contribution is not sufficiently differentiated from existing approaches in formal verification for agents. While the paper claims to be "the first framework that uses dependent-type FL to uniformly model, verify, and refine agent systems," the relationship to prior work on structured workflow verification (e.g., LangChain's graph-based workflows, PDL, AgentSPEX) and formal methods for tool verification (ToolGate, VeriGuard) is not articulated with sufficient depth. The paper should more clearly explain what is uniquely enabled by using a dependent-type language like Lean4, as opposed to simpler type systems or contract-based approaches.
- The benchmark may not be sufficiently challenging for some claims. While the SWE-Bench hard subset is appropriately difficult, the ELAIP-Bench subset (100 randomly selected problems from 403) may be too small to draw strong conclusions. The paper notes that Qwen-3.5-27B on ELAIP-Bench has a 95% CI that includes zero, suggesting the workflow-quality gain is less pronounced. Evaluating on the full ELAIP-Bench or additional challenging datasets would strengthen the evidence.
Questions
- The method uses both backend formal verification (Lean4) and an additional LLM-as-judge module in Layer 3 for predicates outside Lean's decidable core. Could the authors clarify the distinct roles and failure modes of these two verification mechanisms? Specifically, when does Lean4 verification suffice, and when is the LLM-as-judge necessary? What is the empirical frequency of each case, and how often do they disagree?
- The LLMExec assumption states that if an LLM step is executed in a predicate context satisfying its preconditions, then the execution can produce a context satisfying its postconditions. How robust is this assumption in practice? The paper notes that LLMs can typically perform short-horizon tasks well, but does the framework detect or handle cases where this assumption is violated during actual execution? Is there any quantitative analysis of LLMExec violation rates?
- The predicate annotations are generated by LLMs (Claude-Opus-4.6). What is the error rate of these annotations, and how does annotation quality affect verification outcomes? If the LLM mis-specifies a predicate, does the framework detect this, or does it propagate the error?
- The paper evaluates on 5 models but generates workflows using Claude-Opus-4.6. How sensitive are the results to the workflow generator? Would using a different model to generate workflows change the distribution of verification-passing vs. failing workflows?
Limitations
yes
Formatting concerns
None.
2 comments
Rebuttal
Dear Reviewer KYu6,
We sincerely thank you for your thoughtful review and constructive suggestions. We appreciate your recognition of the importance of the problem we identified, the technical soundness of our architecture, and the strength of our empirical results. We summarize and respond to your concerns as follows:
W1. Differences between Lean4Agent and existing frameworks
We appreciate your suggestion to clarify the differences between Lean4Agent and prior agent-verification approaches, as well as the capabilities uniquely established by the dependent-type (DT) formal language. The explicit clarifications are as follows:
- Compared with structural verifications: The most significant difference lies in the rich semantic verification that Lean4Agent contains through our predicate system. Systems such as LangChain, PDL, and AgentSPEX primarily support workflow representation, typing, and structural verification. These capabilities are mostly a subset of our layer-1 verification. In our experiments, all evaluated workflows passed the original AgentSPEX linter, yet they exhibited substantial differences in downstream performance. Lean4Agent can distinguish this difference at layer-2 by verifying that its step-level pre-/post-conditions, information flows, and graph-level predicates are semantically self-consistent.
- Compared with formal methods for tool-use verification: The most significant difference is that Lean4Agent provides a unified and extensible verification framework for both pre-execution workflows and execution trajectories. In particular, ToolGate verifies individual tool-mediated state transitions through contracts, while VeriGuard checks agent actions against safety policies. In contrast, Lean4Agent models workflow-wide contracts before execution and verifies them at the trajectory level after execution. It therefore provides a unified framework for pre-hoc workflow analysis, runtime failure localization, and verification-guided refinement. Additionally, unlike the fixed set of rules in previous work, we can easily extend to new domains through our extensible predicate system.
- Advantage of a dependent-type language: DT is generally a more expressive language compared to traditional SMT-based languages used in agent verification. Lean4, as a DT language, allows specifications to directly represent recursive and nested data structures, higher-order logic relations, and compositional workflow properties. For example, our framework can model recursively nested JSON schemas and specify that every element of a list satisfies a common structured schema. Lean4Agent can also quantify over semantic environments and abstract black-box agent executions through reusable contracts. Moreover, its extensible predicate system allows domain-specific predicates to be easily implemented and supports judgments without requiring a redesign of the entire verification framework. All the above points are hard to implement in the SMT systems
We will expand the related-work discussion and explicitly articulate these distinctions in the next version of our paper.
W2. Potentially limited difficulty of the 100-problem ELAIP-Bench subset
We thank the reviewer for noting that the randomly selected 100-problem ELAIP-Bench subset may be insufficient to clearly distinguish workflow quality for Qwen-3.5-27 B. To address this concern, we conducted an additional evaluation on all 403 problems in ELAIP-Bench. The results are as follows:
| Model | Qwen-3.5-27B |
|---|---|
| Avg. Passed | 42.10% |
| Avg. Failed | 32.84% |
| Diff. | 9.26% |
| 95% C.I. | [5.79%, 12.74%] |
The result resolves the uncertainty observed on the smaller subset and provides stronger evidence that layer-2 verification distinguishes workflow quality on the ELAIP-Bench. We will include these results in the revision of our paper.
Q1. Roles of Lean4 and LLM-as-judge in layer-3
We thank you for raising this important question, and we would like to clarify it in the following points:
- When each mechanism is applied: Lean4 and external tool verifications directly verify predicates that can be clearly defined by code, such as whether the agent writes specified content to the designed filepath. LLM-as-judge is reserved for predicates whose intended semantics remain primarily in natural language, such as whether a trajectory contains sufficient evidence that program fix is comprehensive or not.
- Distinct failure modes: Formal and external verifications may produce false negatives when the specifications are overly strict or do not fully capture equivalent valid outputs, but their evaluation is deterministic once the predicate is defined. On the other hand, LLM-based judgments can represent more open-ended semantic requirements but may introduce uncertainty. We therefore use them only when the requirement cannot be adequately represented through Lean or an external executable verifier. Across the 1,460 predicate annotations in the evaluated workflows, 1,302 are formally or externally checkable, while 158 require LLM-based semantic assessment.
- Potential disagreement: These mechanisms are primarily assigned to different predicates according to their semantics. Therefore, no predicates receive two independent judgments, and a direct disagreement rate is not defined.
We will include these detailed explanations in the next version of our paper.
Q2. The role of the LLMExec assumption
Thank you for raising this concern. The LLMExec assumption is only used in layer-2, where no concrete execution trajectory is yet available. It abstracts the individual LLM step by assuming that, when its preconditions hold, executing the agent can establish the specified postconditions. This abstraction enables static reasoning about whether the workflow is semantically self-contained before deployment. We would also like to clarify that the violation rate for such an assumption is undefined at the layer-2 level, because it is a modeling assumption rather than an empirically evaluated event. We will clarify this distinction in the next version of our paper.
Q3. Predicate annotation accuracy
We thank the reviewer for raising this important concern regarding the accuracy of the LLM-generated annotations used in Layer-2. To examine this issue, we manually evaluated all 12 workflows used in our experiments. It covers 165 semantic nodes and 1,460 predicate annotations. We assess both the correctness of the annotated predicates and whether any predicates are omitted.
We identified 36 mis-specified predicates, corresponding to an annotation error rate of 2.47%. After manually correcting all 36 annotations, none of the verification results flipped. Among these errors, 34 were overly permissive variable-level predicates, primarily in preconditions. Tightening them did not alter whether the corresponding workflow passed or failed the verification. The remaining two were overly weak graph-level predicates annotated in a single verification-failing ELAIP-Bench workflow. It continued to fail after the correction because the failures stemmed from information-flow defects. We also found no serious predicate omissions in the evaluated workflows.
These results provide evidence that the local LLM-based annotation and global formal propagation procedure is reliable for the workflow examined in our experiments. We will add these manual evaluation results to the next version of our paper.
Q4. Different model for generating workflows
We appreciate this question. To evaluate whether our findings depend on Opus-4.6 as the workflow generator and layer-2 annotater, we conducted an additional experiment using GPT-5.4. We generate 40 workflows for ELAIP-Bench using GPT-5.4 under the same workflow-generation instructions and layer-2 annotation pipeline. 24 passed verification, and 16 failed, which is similar to our original results. We then randomly sampled 3 passing and 3 failing workflows for verification and evaluated them using GLM-5. The results are as follows:
| Model | GLM-5 |
|---|---|
| Avg. Passed | 40.67% |
| Avg. Failed | 29.00% |
| Diff. | 11.67% |
| 95% C.I. | [4.33%, 19.00%] |
From the result, we can see that verification-passing workflows significantly outperform the failing workflows. It provides evidence that Lean4Agent’s capability to distinguish workflow quality is not specific to a single workflow generation and annotation model. We will include this cross-generator experiment in the next version of our paper.
We hope the above responses address your concerns. We are grateful for your thoughtful questions and constructive suggestions, which have helped us to improve the clarity and completeness of our work.
Best regards,
Submission #11044 Author Team
Looking forward for your post-rebuttal feedback
Dear Reviewer KYu6,
Thank you so much for recognizing our work and for your constructive comments.
We understand you may have a busy schedule, but as the discussion deadline approaches, we would like to hear your response to our rebuttal. We would greatly appreciate it if you could read our rebuttal and let us know if you have any further questions or concerns.
Thank you again for your work!
Best regards,
Submission #11044 Author Team
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper introduces a frame (Lean4Agent) for formally modeling and verifying agent workflows. The authors build FormalAgentLib which is an extensible Lean4 library for formally modeling and verifying agent workflows' semantic consistency under explicit assumptions for this purpose. The authors also proposed a runtime workflow-refinement framework which leverages trajectory verification and optional environment feedback to improve the workflows. Experiments on two benchmarks, SWE-Bench-Verified and ELAIP-Bench show that verified workflows do help improve accuracy.
Strengths and weaknesses
Strenghth
-
To my knowledge, this is indeed the first framework that uses Lean4 to model and verify agent behavior. And apparently the first Lean4 library for formally modeling and verifying agent workflows. I do appreciate the originality.
-
The three layers of correctness verfication are well designed and make sense: structural correctness captures wll-formedness of workflow definitions, much like compiler-level checks for programs. Static semantic correctness enables uniform modeling of branching, looping and compositional behaviors, and is carried out in a Hoare-logic style. Finally, runtime trajectory correctness tries to capture the dynamic part of the verifcation process with the help of a LLM to determine whether step-level conditions are satisfied. The three layers very well "transferred" modern program verification framwork to the problem of agent workflow verification.
-
The experiments in the appendix do look extensive and detailed. I enjoyed reading the examples and figuring out how each layer is helping with the broader verification.
Weakness:
- My impression is that the specifications are currently largely written by an LLM. In this case, there could be potential issues regarding the correctness of the specifications themselves rather than the subsequent verification with Lean. This is much like when one formalizes mathematical statements in Lean (or any other theorem provers), if the formal statements themselves are wrong or trivial, then the proofs won't give us much.
Questions
At some point you have to define the errors of the workflows you wanted to capture. How many kinds of errors does the current system capture? I am not talking about the difference between the structural ones and semantic ones, but rather the different sub-errors in each category. I can see for example, for layer 2, some of them are defined in PredicateType. Are these all for layer 2?
Limitations
Yes.
Final justification
Given that the authors addressed the reliability of LLM-based predicate annotations in the rebuttal, I am keeping my rating and recommend acceptance.
Formatting concerns
Seems proper.
3 comments
Rebuttal
Dear Reviewer MuLx,
We sincerely thank you for your positive assessment and for recognizing the novelty of the idea and the completeness of the experiments of our work. We also appreciate your constructive comments, which have helped us improve the paper's clarity and rigor. We summarize and respond to your concerns as follows:
W1. Reliability of LLM-based predicate annotations
We appreciate this concern regarding whether LLM-generated specifications faithfully represent the intended workflow semantics. To examine this issue, we manually evaluated all 12 workflows used in our experiments. It covers 165 semantic nodes and 1,460 predicate annotations. We assess both the correctness of the annotated predicates and whether any predicates were omitted.
We identified 36 mis-specified predicates, corresponding to an annotation error rate of 2.47%. After manually correcting all 36 annotations, none of the verification results flipped. Among these errors, 34 were overly permissive variable-level conditions, primarily in preconditions. Tightening them did not alter whether the corresponding workflow passed or failed the verification. The remaining two were overly weak graph-level predicates annotated in a single verification-failing ELAIP-Bench workflow. It continued to fail after the correction because the failures stemmed from information-flow defects. We also found no serious predicate omissions in the evaluated workflows.
These results provide evidence that the local LLM-based annotation and global formal propagation procedure is reliable for the workflow examined in our experiments. It further shows that our framework is robust enough to handle a small fraction of LLM-predicate annotation failures and does not allow them to propagate and affect the workflow-level judgment. We will add these manual evaluation results to the next version of our paper.
Q1. Types of errors detected by Lean4Agent
We appreciate this question. Lean4Agent does not define a fixed, closed list of all possible workflow errors. Instead, it detects error families through the layer-1’s structural verification and the extensible predicate verification in layer-2 and 3.
The layer-1 captures structural well-formedness errors, including incompatible variable types, unresolved reads, inconsistent writes, invalid edges, etc. For layer-2 and 3, the semantic predicates in our system can be organized into three categories:
- Variable-level predicates: These predicates detect invalid properties of explicit workflow variables. For example,
matchJsonSchemaverifies whether the value in the variable satisfies the JSON schema specified in the predicates. - Information-level predicates: These predicates capture whether a step receives and generates the information of the required type for execution, either through explicit variables or the available context. For example, in the SWE task, if a repository exploration step discovers information required by a later testing step but that information is neither stored in a propagated variable nor available in context, the workflow violates this requirement.
- Graph-level predicates: These express global behavioral requirements that cannot be determined from a single variable or node. For example,
verificationCoverageverifies whether an SWE workflow includes an appropriate stage to validate the fix before submission, and that this validation can span multiple steps.
Thanks to our highly extensible predicate system, users may register additional domain-specific predicates rather than being restricted to the predicates currently included in our library. Thus, the list is non-exhaustive. We will include such clarification and error families in the next version of our paper.
Q2. Whether all predicates are represented by PredicateType
Thank you for highlighting this potentially unclear point. Yes, all predicates are presented through the unified PredicateType interface. As detailed in Appendix B.2.1, built-in predicates, task-specific extensions, and further extensions are all induced by PredicateType. We design this to handle all predicates within the same framework for workflow- and trajectory-level verification. We will clarify this relation more explicitly in the revised paper.
We hope the above responses address your concerns. We are sincerely grateful for your thoughtful questions and encouraging assessment, which have helped us improve the clarity and completeness of our work. Your feedback encourages us to continue refining and extending this line of research.
Best regards,
Submission #11044 Author Team
Thanks for the rebuttal! Please do remember to include the manual evaluation results and the clarification of error families in the next version of the paper. I am happy with the response and I'll keep my rating.
Thank you for your response
We sincerely appreciate your constructive review and recognition of our work. We are glad you are happy with the response, and we will certainly include the results of the additional experiments and clarification of error families in the next version of our paper.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Rebuttal
Dear Reviewer PKw6,
Thank you for your detailed review and constructive suggestions. We appreciate your recognition of the importance of our research direction, our framework design, the concrete case studies, and the encouraging empirical results. We summarize and respond to your concerns as follows:
W1. Strength of the formal verification’s framing
Thank you for raising this important question. We would like to clarify the scope and boundary of Lean4Agent through the following points:
Scope of our claim: We would like to clarify that the main framing of our paper is to provide a framework for formally modeling and verifying the agent workflows and trajectories under explicit assumptions, rather than unconditionally proving the correctness of black-box LLM agents. We will make this scope more explicit in the main paper and do our best to avoid wording that could be interpreted as an unconditional guarantee of LLM behavior.
Boundary of the formal components: Similar to formalized mathematics, Lean4Agent first abstracts the system's basic semantic requirements and then formally reasons about their relations. We use predicates as the atomic semantic facts of the workflow. Once the workflow structure and predicate annotations are obtained, Lean formally verifies the structural properties, predicate propagation, pre-/post-condition entailment, and workflow-level semantic consistency.
Because manually annotating all workflows is impractical in real-world use cases, we apply LLMs to extract local predicates from step-wise natural language instructions. These predicates are designed to capture a small fraction of facts that can be modeled through program or local LLM judgments. The formal component then composes these local predicates to derive global workflow properties. Therefore, the formal boundary begins after the workflow abstraction and predicate specification. This is analogous to theorem proving in formal mathematics, where the formal part only happens after the statement has been formalized. On the other hand, the quality of the predicate annotation process is evaluated below.
Quantitative evaluation of LLM-based predicate annotations: We agree that the quality of predicate annotation is central to the meaningfulness of our verification. We therefore manually evaluated all 12 workflows used in our experiments. It covers 165 semantic nodes and 1,460 predicate annotations. We assess both the correctness of the annotated predicates and whether any predicates are omitted.
We identified 36 mis-specified predicates, corresponding to an annotation error rate of 2.47%. After manually correcting all 36 annotations, none of the verification results flipped. Among these errors, 34 were overly permissive variable-level predicates, primarily in preconditions. Tightening them did not alter whether the corresponding workflow passed or failed the verification. The remaining two were overly weak graph-level predicates annotated in a single verification-failing ELAIP-Bench workflow. It continued to fail after the correction because the failures stemmed from information-flow defects. We also found no serious predicate omissions in the evaluated workflows.
These results provide evidence that the local LLM-based annotation and global formal propagation procedure is reliable for the workflow examined in our experiments. We will add these manual evaluation results to the next version of our paper.
Role of the
LLMExecassumption: This assumption is used only in later-2, where no concrete execution trajectory is yet available. It abstracts an individual LLM step by assuming that, when its precondition holds, executing the agent can establish the specified postconditions. This abstraction enables static reasoning about whether the workflow is semantically self-contained before deployment. We would like to emphasize thatLLMExecis only a modeling assumption at layer-2 and cannot be directly evaluated; its violation is undefined.We will include the above points to more clearly demonstrate our framework's positioning and further soften the “formal verification” guarantees if you think it necessary in the next version of our paper.
W2. Casual evaluation through targeted workflow repair guided by Lean4Agent
We thank the reviewer for requesting a more casual evaluation and would like to clarify that we have already partially done such an experiment in Appendix A.4, where we repaired the
failed-1workflow for the SWE agent based on the layer-2 results. Re-evaluating the same workflow using GPT-5.2 improves its accuracy from 52.00% to 62.00%.To strengthen this experiment, we further evaluated the repaired SWE workflow using GLM-5, where its accuracy increased from 48.00% to 60.00%. We also repaired the
failed-1ELAIP-Bench workflow and evaluated it using GLM-5; the performance improved from 22.00% to 43.00%. For the ELAIP-Bench workflow, layer-2 identified the violations of theverdictEnumValidandnegation_flagpredicates. The original workflow generated option-level positive or negative judgments, but failed to pass the supporting rathinales to the final-answer aggregation step. We repaired the exact information-flow defect by propagating these reasons to the downstream step. After the repair, both workflows reached the performance range of the passing workflows.These controlled before-and-after results provide more distinct evidence that the Lean4Agent does not merely select generally better workflows. Its diagnostics can identify specific defects and guide targeted workflow repair. We will add this experiment to the next version of our paper.
W3. Release of the code
Thank you for raising this concern. The code was still being organized at the time of submission, but this process is now complete. Because the rebuttal policy does not permit us to attach the link directly, we have submitted the anonymized code package to the AC. We will also release the complete code upon publication and maintain the repository continuously.
Q1. Lean boundary and the `LLMExec axiom
We have answered this question in W1; please kindly refer to that section for details.
Q2. Compact end-to-end Lean verification example
We thank the reviewer for raising this point and would like to clarify that such example has been provided in Appendices D.1 and D.2, where D.1 presents the original YAML workflow and D.2 shows the corresponding Lean4Agent encoding, including the workflow nodes, generated pre- and post-conditions, semantic graph, structural verifications, and the final semantic-soundness theorem proved based on
native_decidewith the help of our implemented lemmas. Additionally, in Appendix B.2.5, we provide a failing example in which Lean4Agent identifies a missing JSON Schema predicate for the downstream step. We will add a compact overview to the main paper and explicitly direct readers to the complete passing and failing examples in the appendix of the next version of our paper.Q3. Reliability of LLM-annotated predicates
Please kindly refer to W1.3, where we report the manual evaluation of all 1,460 predicate annotations.
Q4. Casual evaluation of verification
Please kindly refer to W2 for the answer to this question.
Q5. Lean4Agent compared with general workflow-quality selection
We are grateful for this question and would like to clarify that we have already conducted this comparison in Appendix A.3 using GPT-5.5 as the LLM workflow-quality judge. For the paper-understanding task, where workflow requirements are more explicit and easier to inspect from the surface description, the LLM judge largely agrees with Lean4Agent’s judgment. However, for the SWE task, where workflows involve more implicit semantics, context, and information-flow requirements, the LLM scores show weak alignment with both Lean4Agent results and empirical workflow performance. A closer analysis shows that the LLM judge often captures explicit workflow behaviors but misses the implicit factors. This comparison suggests that Lean4Agent provides information beyond general workflow-quality scoring, particularly for workflows whose correctness depends on non-local semantic relations. We will reference this experiment more explicitly in the main paper.
Q6. Agent failures outside the current predicate scope
Thank you for the question. We would like to clarify that Lean4Agent provides a highly extensible predicate system and is intended to be maintained as a long-term project. Although some of the capabilities mentioned by the reviewer were not yet supported by the repository version available at the time of submission and extensibility alone does not verify properties that have not been explicitly modeled. We would like to share that, in the current internal version of the Lean4Agent repository, most of the failure types raised by the reviewer are already supported. In particular, we have extended Lean4Agent to a general Claude-Code setting and introduced predicates for incorrect code edits and incomplete exploration through Lean4-based checks. We also leverage LLM-as-judge predicates to detect hidden tool-calling failures. We plan to maintain Lean4Agent over the long term, with the predicate family evolving as new agent behaviors and failure modes emerge. We will clarify both the scope of the submitted version and our maintenance plan in the next version of the paper.
We hope the above rebuttal addresses your concerns. We are grateful for your comprehensive questions and constructive suggestions, which have helped us to improve the clarity, completeness, and scope of guarantees presented in our work.
Best regards,
Submission #11044 Author Team