Enhancing the agentic capabilities of Large Language Models (LLMs) to tackle complex software engineering (SWE) and general terminal-usage problems is a pressing challenge. Current state-of-the-art LLMs often go through large-scale agentic Reinforcement Learning (RL). However, they mostly rely on high-level outcome rewards, with minimal consideration of low-level toolcall and mid-level workflow-stage rewards, which makes the training less effective. To overcome this limitation, we propose Lean4AgenticRL, which, to the best of our knowledge, is the first framework that grounds multi-level process rewards in the unified Lean4 formalization schema for open-ended agentic RL. Lean4AgenticRL first builds a problem-specific workflow system that balances the agent's own capability and controllability during execution, laying the foundation for further verification. Subsequently, our workflow formalization and multi-level reward annotation methods enable agent behavior verification within a general harness system. It provides multi-level rewards to support more effective agentic RL with the workflow-stage-normalized GRPO algorithm. Using Lean4AgenticRL, we train LAR-9B/27B, a family of models with enhanced agentic capability. Extensive experiments indicate that our model outperforms the leading model of similar size. LAR-27B achieves 77.3% on TerminalBench-2.1. On average, our models outperform the base model by 9.89% and surpass the second-best model of comparable size we know by 5.07%. These results indicate the potential of integrating formal methods in enhancing open-ended agentic RL.
Figures & tables
Figure 1: Overview of Lean4AgenticRL framework: The Lean4AgenticRL framework contains three major steps: (a) Problem-specific workflow agent system : A plan-then-execute process that first explores and produces the problem-specific workflow (PSWF). Then execute the PSWF to solve the task. (b) Workflow Formalization and Multi-level Reward Annotation : An annotation process that formalizes the PSWF into our generalized Lean4Agent framework. Then segment the agent trajectory into workflow stages, and assign mid-level workflow-stage rewards and low-level toolcall rewards. (c) Lean4AgenticRL training : We apply the workflow-stage-normalized GRPO algorithms to train the LLM agent with multi-level rewards.
Models
Size
SWE-Bench-Verified
TB-2.0
TB-2.1
OpenThinker-Agent-V1 ( Team, 2025a )
8B
15.7%
1.9%
-
Qwen-3.5-9B ( Qwen Team, 2026a )
9B
44.0%
19.3%
16.1%
TMax-9B ( Ivison et al., 2026 )
9B
53.5%
27.2%
27.6%
Gemma-4-12B ( Farabet & Lacombe, 2026 )
12B
23.2%
15.3%
27.0%
Qwen-3.6-27B ( Qwen Team, 2026b )
27B
70.0%
45.6%
40.5%
TMax-27B ( Ivison et al., 2026 )
27B
70.0%
49.9%
44.9%
Table 1: Main experimental results of LAR-9B/27B compared to recent works using SWE-Bench-Verified, TerminalBench(TB)-2.0, and TB-2.1. The best performance models are bolded and the second-best performance models of a similar size are underlined .
Figure 2: Lean4AgenticRL compared with GRPO in SWE by SWE-Bench-Verified and terminal usage tasks by TerminalBench-2.0.
Method
SWE-Bench-Verified
w/o γ
49.4%
w/ γ
56.0%
w/o PSWF
42.4%
w/ PSWF
44.0%
Table 2: Ablation Studies Result
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Faithfulness Type
Failure Rate
Predicate annotation
8.03%
Workflow segmentation
6.21%
Trajectory verification
4.84%
Appendix
Table 3: LLM-based evaluation of workflow annotation faithfulness
Step
TB-2.1 Test cases
α
Stages with β=+1 / total stages
0 (base)
1/4 passes
-1
2/8
40
1/4 passes
-1
4/7
80
2/4 passes
-1
5/6
120
4/4 passes
+1
5/5
Appendix
Table 4: Overall α and β rewards change as model training progresses
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.
Ruida Wang, Jerry Huang, Pengcheng Wang +3
University of Illinois Urbana-Champaign · Independent researcher
Reinforcement learning from verifiable rewards (RLVR) has improved the reasoning capabilities of large language models (LLMs), yet existing approaches predominantly rely on sparse outcome-level feedback, posing a substantial credit-assignment challenge in long-horizon agentic tasks. In this work, we study structured agentic reasoning problems that admit symbolic or algorithmic task-solving oracles. We propose Verifiable Process Rewards (VPR), a training framework that repurposes such task oracles as action-level process verifiers, providing dense rewards for intermediate actions and enabling fine-grained credit assignment. We instantiate VPR in three distinct settings: a search-based oracle for Sokoban, a constraint-based oracle for Sudoku, and a posterior-based oracle for Minesweeper. To optimize policies with these rewards, we introduce oracle-guided state-group rollout and locally normalized optimization. Empirically, VPR-trained Qwen3-4B outperforms outcome-reward GRPO and VinePPO across all three training environments. When jointly trained on math data and all three game environments, VPR achieves the highest average general-reasoning performance and strongest agentic results among the compared training configurations. To further assess its applicability to more general agentic tool-use settings, we apply VPR-style action-level supervision to τ2-bench using an expert LLM as a reference policy and observe improved performance over outcome-reward GRPO on held-out tasks. Together, these results position VPR as a promising approach for leveraging reliable task oracles to improve agentic reasoning, while highlighting its dependence on the availability and reliability of task oracles and the challenge of extending intermediate verification to less structured, open-ended environments.
Reinforcement Learning (RL) has traditionally focused on training specialized agents to optimize predefined reward functions within narrowly defined environments. However, the advent of powerful Large Language Models (LLMs) and increasingly complex, open-ended tasks has catalyzed a paradigm shift towards agentic paradigms within RL. This emerging framework extends beyond traditional RL by emphasizing the development of autonomous agents capable of goal-setting, long-term planning, dynamic strategy adaptation, and interactive reasoning in uncertain, real-world environments. Unlike conventional approaches that rely heavily on static objectives and episodic interactions, LLM-based Agentic RL incorporates cognitive-like capabilities such as meta-reasoning, self-reflection, and multi-step decision-making directly into the learning loop. In this paper, we provide a deep insight for looking the conceptual foundations, methodological innovations, and effective designs underlying this trend. Furthermore, we identify critical challenges and outline promising future directions for building LLM-based Agentic RL.