Organizations: School of Computer Science, Peking University · School of Electronics Engineering and Computer Science, Peking University · China Southern Power Grid · SKLCCSE, School of Computer Science and Engineering, Beihang University · Tsinghua University · University of Electronic Science and Technology of China · Key Laboratory of High Confidence Software Technologies(PKU), MOE · Institute of Software, Chinese Academy of Sciences · National Engineering Research Center for Software Engineering, Peking University
Autonomous agents are increasingly entrusted with complex, long-horizon tasks, ranging from mathematical reasoning to software generation. While agentic workflows facilitate these tasks by decomposing them into multi-step reasoning chains, reliability degrades significantly as the sequence lengthens. Specifically, minor interpretation errors in natural-language instructions tend to compound silently across steps. We term this failure mode accumulated semantic ambiguity. Existing approaches to mitigate this often lack runtime adaptivity, relying instead on static exploration budgets, reactive error recovery, or single-path execution that ignores uncertainty entirely. We formalize the multi-step reasoning process as a Noisy MDP and propose DenoiseFlow, a closed-loop framework that performs progressive denoising through three coordinated stages: (1)Sensing estimates per-step semantic uncertainty; (2)Regulating adaptively allocates computation by routing between fast single-path execution and parallel exploration based on estimated risk; and (3)Correcting performs targeted recovery via influence-based root-cause localization. Online self-calibration continuously aligns decision boundaries with verifier feedback, requiring no ground-truth labels. Experiments on six benchmarks spanning mathematical reasoning, code generation, and multi-hop QA show that DenoiseFlow achieves the highest accuracy on every benchmark (83.3% average, +1.3% over the strongest baseline) while reducing cost by 40--56% through adaptive branching. Detailed ablation studies further confirm framework-level's robustness and generality. Code is available at https://anonymous.4open.science/r/DenoiseFlow-21D3/.
Figures & tables
Figure 1. DenoiseFlow architecture overview. Given a problem, Stage 1 (Sensing) generates N Monte Carlo samples to estimate semantic uncertainty ut via clustering-based entropy, then propagates risk through the dependency graph to obtain u~t . Stage 2 (Regulating) computes execution confidence ct=1−rt and routes to one of three modes: Direct (high confidence, single path), Branch (medium confidence, K parallel paths with consensus selection), or Refine (low confidence, trigger Stage 3). Stage 3 (Correcting) performs influence-based tracing to localize the root cause k∗ , applies asymmetric calibration to boost uncertainty at k∗ , and re-executes from the corrected state. The online calibration module continuously adjusts temperature T based on verifier feedback. DenoiseFlow framework diagram showing three stages: Stage 1 (Sensing) with Monte Carlo sampling and uncertainty estimation, Stage 2 (Regulating) with Direct/Branch/Refine routing based on confidence, and Stage 3 (Correcting) with influence-based tracing for root cause localization.
Single-agent
Hand-crafted Multi-agent
Autonomous Multi-agent
Category
Benchmark
IO
CoT
CoT SC
Self-Ref.
Debate
Blender
DyLAN
GPTSwarm
ADAS
AFlow
MaAS
Mermaid.
Judge.
Ours
Math Reason.
GSM8K
87.8
87.0
86.9
85.5
89.5
88.4
90.0
89.1
88.4
90.1
91.5
92.4
93.0
93.9
MATH
48.6
48.8
50.4
46.1
48.6
46.9
48.5
47.9
43.2
52.8
52.2
55.4
58.5
61.4
Code Gen.
MBPP
73.9
74.2
73.3
71.8
70.3
77.1
77.3
77.4
77.1
81.7
82.2
82.3
83.8
84.9
HumanEval
87.0
88.6
91.6
87.8
88.8
88.7
90.4
89.3
84.2
90.1
91.6
92.9
93.4
93.9
Multi-hop QA (F1)
HotpotQA
68.1
67.9
68.9
60.8
70.2
72.3
74.1
73.2
64.5
73.5
75.3
77.2
77.4
77.5
Table 1. Performance comparison on six benchmarks. All methods use GPT-4o-mini as the backbone LLM. All results are reproduced under our unified evaluation protocol. DenoiseFlow results are averaged over three independent runs (std < 0.5%). Best in bold , second best underlined . Self-Ref. = Self-Refine; Debate = LLM-Debate; Blender = LLM-Blender; Mermaid. = MermaidFlow; Judge. = JudgeFlow.
Component Ablations
Strategy Variants
Metric
w/o SA
w/o AB
w/o CLR
w/o OC
Fixed K=7
Full Rest.
Local Ret.
Full
GSM8K (%)
91.67
93.94
93.94
93.18
93.18
94.70
94.32
93.94
MBPP (%)
81.40
79.07
84.88
80.23
84.88
84.88
84.88
84.88
HotpotQA (F1)
77.89
71.71
77.75
76.32
77.25
74.86
74.39
76.48
Avg.
83.65
81.57
85.52
83.24
85.10
84.81
84.53
85.10
Cost
0.43 ×
0.05 ×
1.13 ×
1.03 ×
2.25 ×
1.15 ×
1.12 ×
1.00 ×
Table 2. Ablation study on three representative benchmarks. Columns show ablation variants; rows show metrics. Bold marks the full DenoiseFlow (proposed method). Cost is normalized relative to the full model. SA = Semantic Anchoring, AB = Adaptive Branching, CLR = Closed-Loop Refinement, OC = Online Calibration, Full Rest. = Full Restart (Reflexion-style), Local Ret. = Local Retry.
Figure 2. Hyperparameter sensitivity analysis across six benchmarks. The dark solid line shows average accuracy; red ⋆ marks the optimal value. Individual benchmarks shown as dashed lines. (a) N=5 achieves the best average; (b) τsim=0.85 balances sensitivity; (c) Kmax significantly impacts QA tasks; (d) R is relatively insensitive. Four subplots showing hyperparameter sensitivity: (a) accuracy vs sample size N, (b) accuracy vs similarity threshold, (c) accuracy vs max branches, (d) accuracy vs max retries. The dark solid line with star markers shows the average across all benchmarks, with red stars indicating optimal values. Individual benchmarks are shown as dashed lines.
Dataset
Acc/F1
Avg Cost
Avg Calls
Retry %
GSM8K
93.9
$0.194
7.87
3.4
MATH
61.4
$1.012
9.82
0.8
MBPP
84.9
$0.195
9.76
0.0
HumanEval
93.9
$0.049
9.22
0.0
HotpotQA
77.5
$0.490
7.58
3.5
DROP
87.9
$0.298
7.73
3.0
Table 3. Efficiency metrics with default settings ( N=5 , Kmax=7 ). Avg Calls: average LLM calls per problem, including Monte Carlo samples for uncertainty estimation plus Kt execution branches. Retry %: percentage of problems triggering Stage 3 refinement.
Figure 3. Uncertainty calibration: risk score r vs. success rate on GSM8K and MATH. The negative correlation confirms rank consistency. Error bars: std over three runs. Similar trends on other benchmarks (Appendix H.5 ). Calibration curve showing a negative relationship between estimated uncertainty (risk score) and success rate on GSM8K and MATH. Error bars indicate standard deviation across three runs.
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
Dataset
Size
Task Type
Metric
GSM8K
1,319
Math (grade school)
Accuracy
MATH
5,000
Math (competition)
Accuracy
MBPP
500
Code generation
Pass@1
HumanEval
164
Code generation
Pass@1
HotpotQA
7,405
Multi-hop QA
F1
DROP
9,536
Discrete reasoning
F1
Appendix
Table 4. Benchmark datasets used in experiments.
Method
Key Parameters
LLM
Source
Single-agent Systems
IO
-
GPT-4o-mini
Our impl.
CoT
zero-shot
GPT-4o-mini
Our impl.
CoT SC
K=5 samples
GPT-4o-mini
Our impl.
Hand-crafted Multi-agent Systems
Self-Refine
max_iter=3
GPT-4o-mini
( Madaan et al., 2024 )
Appendix
Table 5. Baseline configurations. All methods are reproduced under the same backbone (GPT-4o-mini) using our unified evaluation protocol.
Parameter
Default
Description
Stage 1: Semantic Anchoring
N
5
Monte Carlo sample size
τsim
0.85
Base similarity threshold (adapted per problem; see § 3.3 )
τslot
0.4
Slot-level high-uncertainty threshold
Stage 1: Risk Propagation
λ
0.5
Bottleneck channel weight
Appendix
Table 6. Hyperparameter settings for DenoiseFlow .
Operator
Description
Stage 1: Semantic Anchoring
Sample ( N )
Generate N diverse LLM responses via Monte Carlo sampling with temperature >0
Embed
Compute semantic embeddings using sentence encoder
Cluster ( τ )
Group responses by similarity threshold τ ; extract clusters
Entropy
Compute normalized semantic entropy from cluster distribution
Propagate
Propagate slot-level uncertainty through dependency graph
Appendix
Table 7. Core operators in DenoiseFlow . Operators are composable building blocks that implement the three-stage denoising pipeline.
Model
Method
GSM8K
MATH
GPT-4o-mini
CoT
87.0
48.8
DenoiseFlow
93.9
61.4
GPT-4o
CoT
98.0
62.0
DenoiseFlow
99.5
68.5
DeepSeek-V2.5
CoT
82.0
43.0
DenoiseFlow
88.8
55.5
Appendix
Table 8. Cross-model generalization on GSM8K and MATH. DenoiseFlow consistently outperforms CoT across all three backbone LLMs, demonstrating framework-level generality. All experiments use the same evaluation protocol.
Dataset
Direct (%)
Branch (%)
Refine (%)
Avg K
Total
GSM8K
0.8
99.2
3.4
3.98
120
MATH
14.3
85.7
12.6
2.53
119
MBPP
40.7
59.3
0.0
2.02
86
HumanEval
12.1
87.9
0.0
2.82
33
HotpotQA
11.0
89.0
2.0
2.62
200
DROP
13.0
87.0
11.5
2.50
200
Appendix
Table 9. Strategy distribution and adaptive branching (based on a representative analysis subset; see “Total” column for subset sizes). Direct and Branch show the initial routing decision based on confidence thresholds (Eq. 9 ); they are mutually exclusive and sum to 100%. Refine (%) shows the fraction of problems that ultimately trigger Stage 3 refinement—either due to very low initial confidence or after Branch execution fails verification—and is therefore a (non-exclusive) subset of Branch. Note that Refine (%) here may differ from the full-dataset Retry % in Table 3 due to sampling variation. Avg K shows the average branch count within Branch mode.
Dataset
Triggered
Recovered
Rate (%)
Avg Retries
GSM8K
9
4
44.4
1.0
MATH
1
0
0.0
1.0
HotpotQA
7
3
42.9
1.0
DROP
6
2
33.3
1.0
Appendix
Table 10. Stage 3 refinement recovery analysis. Triggered: number of problems entering refinement. Recovered: problems successfully corrected after refinement.
N
GSM8K
MATH
HotpotQA
DROP
HumanEval
MBPP
Avg
3
90.2
51.3
65.8
82.4
87.9
80.2
76.3
5 ⋆
93.2
55.5
73.8
87.9
90.9
84.9
81.0
7
91.8
52.1
70.2
85.3
90.9
82.6
78.8
10
92.4
53.8
69.1
84.2
90.9
80.2
78.4
Appendix
Table 11. Sensitivity to Monte Carlo sample size N . Accuracy/F1 (%) reported. ⋆ denotes the optimal value. Contrary to the intuition that more samples improve estimation, N=5 achieves the best performance (81.0% avg), suggesting moderate sampling provides sufficient semantic diversity without introducing redundant noise.
τsim
GSM8K
MATH
HotpotQA
DROP
HumanEval
MBPP
Avg
0.7
91.3
52.9
68.5
82.1
90.9
81.4
77.9
0.8
92.4
53.8
70.8
84.8
90.9
82.6
79.2
0.85 ⋆
93.2
55.5
73.8
87.9
90.9
84.9
81.0
0.9
92.0
54.6
71.2
85.6
90.9
83.7
79.7
Appendix
Table 12. Sensitivity to similarity threshold τsim . ⋆ denotes the optimal value. τ=0.85 achieves the best balance: lower values may merge semantically distinct answers, while higher values may over-fragment similar responses, both leading to suboptimal uncertainty estimates.
Kmax
GSM8K
MATH
HotpotQA
DROP
HumanEval
MBPP
Avg
3
92.4
53.8
61.6
79.7
90.9
77.9
76.1
5
92.8
54.6
68.9
84.2
90.9
82.6
79.0
7 ⋆
93.2
55.5
73.8
87.9
90.9
84.9
81.0
Appendix
Table 13. Sensitivity to maximum branches Kmax . Larger Kmax significantly benefits multi-hop reasoning tasks: HotpotQA improves by 12.2 F1 points and DROP by 8.2 F1 points from K=3 to K=7 . This demonstrates that complex reasoning requires sufficient exploration capacity. We use Kmax=7 ( ⋆ ) as the default; the adaptive mechanism ensures efficient routing on simpler tasks.
R
GSM8K
MATH
HotpotQA
DROP
HumanEval
MBPP
Avg
1
92.8
54.6
72.1
86.5
90.9
83.7
80.1
2 ⋆
93.2
55.5
73.8
87.9
90.9
84.9
81.0
4
92.4
54.6
73.2
87.1
90.9
84.9
80.5
Appendix
Table 14. Sensitivity to maximum retries R . All values perform similarly ( ≈ 80–81%), indicating that root-cause-guided refinement is effective even with minimal retries. We use R=2 ( ⋆ ) as a cost-effective default.
Method
Uncertainty
Adaptive
Root Cause
Online
Targeted
Sensing
Branching
Tracing
Calibration
Correction
CoT-SC ( Wang et al., 2022 )
✗
Fixed K
✗
✗
✗
ToT ( Yao et al., 2024 )
✗
Fixed K
✗
✗
✗
Reflexion ( Shinn et al., 2024 )
✗
✗
✗
✗
Restart
Self-Refine ( Madaan et al., 2024 )
✗
✗
✗
✗
Local
AFlow ( Zhang et al., 2024 )
✗
Offline
✗
✗
✗
Appendix
Table 15. Capability comparison with related methods. Each column represents a key requirement for reliable workflow execution (§ 2 ). DenoiseFlow is the only method that addresses all five within a unified closed-loop architecture.
Large language model (LLM) agent reliability concerns dependable, safe, and verifiable behavior across tools, multi-step tasks, and changing environments.
Every major LLM agent framework gives the LLM the role of orchestrator; the model decides what to do next, when to call tools, and when to stop. We argue that token explosion, control-flow hallucination, and unreliable completion are not implementation bugs but architectural consequences of assigning the deterministic work of looping, branching, and sequencing to a probabilistic system. A better prompt or a stronger model cannot guarantee the reliability of the LLM agent. We therefore propose Agentic Programming, in which the program governs all control flow, and the LLM is itself part of it, an adaptive component we call LLM-as-Code and invoke only where a task calls for reasoning or generation. Within each call the model keeps full flexibility, but it cannot alter the program's execution path. With control in the program, the LLM's context is built from the execution history's call tree and forms a directed acyclic graph (DAG). Each call's context length is then determined by its call depth rather than by accumulation over steps. A case study of computer-use agents shows that the design is practical, not just a theoretical stance, substantially improving the stability of long visual operation sequences.
Large language model (LLM) agents frequently fail on multi-step tasks involving reasoning, tool use, and environment interaction. While such failures are typically logged or retried heuristically, they contain structured signals about where execution broke down. We introduce CausalFlow, an interventional framework that converts failed agent traces into minimal counterfactual repairs and reusable supervision. CausalFlow models execution traces as sequential chains of dependent steps and computes Causal Responsibility Scores(CRS) via step-level counterfactual intervention to identify failure-inducing steps. For these steps, we generate minimally edited repairs that flip the final outcome to success, producing validated contrastive pairs of the form (wrong step, corrected step). CausalFlow supports two complementary uses: targeted test-time repair that recovers from failures with minimal behavioral drift, and training-time supervision suitable for offline preference optimization or reward modeling. Across four benchmarks spanning mathematical reasoning, code generation, question answering, and medical browsing, CausalFlow converts failed executions into validated minimal repairs with high minimality and causal-consensus scores, and demonstrates that causal attribution is necessary for reliable improvement across diverse agent tasks, outperforming heuristic refinement in complex retrieval settings while producing more localized repairs throughout. These results demonstrate that interventional analysis over structured execution traces provides a principled and scalable mechanism for transforming agent failures into reliability gains and learning-ready supervision.
Multi-agent systems often rely on predefined collaboration structures, limiting their ability to adapt to diverse task requirements. We introduce DynaFlow, a framework that integrates free-form executable workflow synthesis into the action space of the main agent. The agent decides when collaboration is needed and generates task-specific programs that coordinate sub-agents through sequential or parallel execution, structured information exchange, and verification. Execution results and traces inform subsequent actions, enabling the agent to adapt collaboration as reasoning progresses. We train only the main agent through supervised fine-tuning on distilled trajectories, followed by refinement on examples filtered for unsupported premises, biased verification, and information-flow defects. All sub-agents remain fixed, separating orchestration learning from executor capability improvement. Across six benchmarks spanning mathematical reasoning, scientific question answering, and multi-hop retrieval, DynaFlow achieves 88.08% overall accuracy in Forced mode, outperforming the strongest evaluated baseline by 10.90 percentage points with the same Qwen3.5-27B backbone. Workflow analysis finds more explicit use, verification, and refinement of upstream outputs after training, highlighting cross-stage information flow as a key dimension of multi-agent orchestration.