Large Language Models (LLMs) have demonstrated strong capabilities in complex reasoning tasks, while recent prompting strategies such as Chain-of-Thought (CoT) have further elevated their performance in handling complex logical problems. Despite these advances, high-quality reasoning remains heavily reliant on manual static prompts and is sensitive to decoding configurations and task distributions, leading to performance fluctuations and limited transferability. Existing automatic prompt optimization methods typically adopt single-agent local search, failing to simultaneously optimize prompts and decoding hyperparameters within a unified framework to achieve stable global improvements. To address this limitation, we propose Agent-GWO, a dynamic prompt optimization framework for complex reasoning. Specifically, we unify prompt templates and decoding hyperparameters as inheritable agent configurations. By leveraging the leader-follower mechanism of the Grey Wolf Optimizer (GWO), we automatically select three leader agents (α, β, and δ) to guide the collaborative updates of the remaining agents, enabling iterative convergence toward robust optimal reasoning configurations that can be seamlessly integrated for inference. Extensive experiments on multiple mathematical and hybrid reasoning benchmarks across diverse LLM backbones show that Agent-GWO consistently improves accuracy and stability over existing prompt optimization methods. The code will be released publicly.
Figures & tables
Figure 1: GWO abstracts each LLM agent as a “wolf” which is characterized by hyperparameters & reasoning prompt. These two guide the behavior of the LLMs during the optimization process.
Figure 2: The overall Agent-GWO framework operates by having each agent process a dataset, Prompt, and parameters to produce outputs, which are then scored. Only the top-3 agents ( α , β , and δ ) are differentiated, while the rest (i.e., ω ) are updated using the prompt and parameters from the previous round. This iterative ranking and update process continues until termination, after which the final agent is set as the top-ranked α from the last iteration. Note: The left-bottom subfigure illustrates the learning process of each agent at each iteration and the right-bottom subfigure illustrates the optimization process.
Model
Math Reasoning Tasks
Hybrid Reasoning Tasks
Avg
GSM8K
MATH
SVAMP
MultiArith
ASDiv
AQUA
MMLU
BBH
Date
CLUTRR
MATH_MIX
GPT-4o-mini
CoT
85.4%
74.8%
84.7%
89.5%
92.3%
65.3%
63.4%
66.6%
52.1%
66.2%
80.1%
74.6%
CoT-SC/n=5
89.9%
76.3%
85.8%
89.7%
93.3%
70.7%
67.1%
69.0%
54.7%
72.2%
81.6%
77.3%
Self-Refine
88.9%
75.1%
85.0%
89.9%
92.2%
67.8%
64.8%
67.5%
53.0%
68.4%
83.8%
76.0%
AFlow
93.5%
78.9%
88.7%
91.9%
93.4%
72.0%
69.5%
68.0%
66.0%
72.8%
85.3%
80.0%
Table 1: Performance comparison of Agent-GWO against baselines across math and hybrid reasoning tasks. Bold indicates the best result, and underlined indicates the second-best result.
Model / Method
Math Reasoning Tasks
Hybrid Reasoning Tasks
Avg. Increase
GSM8K
MATH
SVAMP
MultiArith
ASDiv
AQUA
MMLU
BBH
Date
CLUTRR
MATH_MIX
GPT-4o-mini
CoT
85.4%
74.8%
84.7%
89.5%
92.3%
65.3%
63.4%
66.6%
52.1%
66.2%
80.1%
-
CoT+GWO/n=5
95.1%
79.9%
92.4%
99.5%
93.8%
76.1%
73.7%
71.3%
77.1%
74.9%
85.0%
↑ 8.9%
CoT+GWO/n=6
96.5%
81.5%
92.9%
99.8%
94.5%
76.8%
74.9%
72.2%
78.3%
75.8%
95.1%
↑ 10.7%
GPT-4.1-mini
Table 2: Combined evaluation of adaptability of GWO to CoT on math and hybrid reasoning tasks.
Figure 5
Parameter
Sampling Rule
Perf.(%)
Cost ($)
tj
(0.2, 0.1)
↓ 1.0–1.5%
↓ 3–5%
(0.4, 0.1)
↓ 0.3–0.6%
↓ 1–2%
(0.6, 0.1)
baseline
baseline
(0.8, 0.1)
↓ 0.5–1.0%
↑ 4–7%
pj
(0.2, 0.1)
↓ 0.8–1.3%
↓ 2–4%
(0.4, 0.1)
↓ 0.2–0.5%
↓ 1–2%
Table 3: Sensitivity analysis of agent-level decoding hyperparameters. Entries report relative performance and cost changes compared to the baseline configuration used in our framework.
Elite Size
Elite
GSM8K
MATH
MMLU
m=1
α
92.4
76.8
72.0
m=2
α,β
94.8
79.1
74.2
m=3
α,β,δ
95.9
80.2
75.3
m=4
α,β,δ,ω1
95.0
79.4
74.6
m=5
α,β,δ,ω1,ω2
94.1
78.5
73.8
Table 4: Ablation on Elite Set Size. Results under different elite set sizes m . α , β , and δ denote the top three leaders in standard GWO, while ω1 and ω2 denote the 4th- and 5th-ranked agents by fitness, respectively.
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: Illustration of GWO algorithm.
Method
Model
GSM8K
CoMAT Leang et al. (2025)
GPT-4
93.7
CoT Wei et al. (2022)
GPT-4
94.5
FCoT Lyu et al. (2023)
GPT-4
95.0
MathPrompter Imani et al. (2023)
GPT-4
95.6
QuaSAR Radford et al. (2018)
GPT-4
96.5
MathDivide Srivastava and Gandhi (2024)
GPT-4
96.8
Appendix
Table 5: Accuracy on GSM8K comparing GPT-4 and GPT-4o-mini.
Method
Base
GSM8K
MATH
OMI2 Li et al. (2025b)
Qwen2.5
84.1
72.3
CODEI/O++ Li et al. (2025b)
Qwen2.5
85.7
72.1
PyEdu Li et al. (2025b)
Qwen2.5
85.8
71.4
CODEI/O Li et al. (2025b)
Qwen2.5
86.4
71.9
OC-SFT-1 Li et al. (2025b)
Qwen2.5
86.7
70.9
WI Li et al. (2025b)
Qwen2.5
87.0
71.4
Appendix
Table 6: Accuracy (%) on GSM8K and MATH using Qwen2.5-Coder-7B.
Large language models (LLMs) have become increasingly capable of following instructions and complex reasoning, making prompting a flexible interface for adapting models without parameter updates. Yet prompt design remains labor-intensive and highly sensitive to formatting, phrasing, and instruction order, motivating automated prompt optimization methods that reduce manual effort while preserving inference-time flexibility. However, existing methods often search over prompt candidates or use fixed critique-refine pipelines driven by individual examples or small batches, limiting their ability to capture systematic error patterns and make targeted edits grounded in failure history. We propose Reflective Prompt Tuning (RPT), a framework that uses LLM function calling to simulate the iterative workflow of human prompt engineers. An LLM optimizer calls a diagnostic function that evaluates the target model over an entire optimization set, summarizes recurring failure modes, and returns a structured diagnostic report. The optimizer uses this report, together with an accumulated memory of prior reports, to revise the prompt for the next iteration. RPT further supports confidence-aware optimization by using calibration signals in diagnostic feedback and final prompt selection. Across three reasoning tasks, RPT improves over initial prompts by up to 12.9 points, remains competitive with state of the art, and improves confidence calibration. Our analyses show that RPT is especially effective on multi-hop and mathematical reasoning, producing targeted prompt revisions that align with diagnosed failure patterns and lead to gains in task performance and calibration.
As Large Language Models (LLMs) achieve increasingly sophisticated performance on complex reasoning tasks, current architectures serve as critical proxies for the internal heuristics of frontier models. Characterizing emergent reasoning is vital for long-term interpretability and safety. Furthermore, understanding how prompting modulates these processes is essential, as natural language will likely be the primary interface for interacting with AGI systems. In this work, we use a custom variant of Genetic Pareto (GEPA) to systematically optimize prompts for scientific reasoning tasks, and analyze how prompting can affect reasoning behavior. We investigate the structural patterns and logical heuristics inherent in GEPA-optimized prompts, and evaluate their transferability and brittleness. Our findings reveal that gains in scientific reasoning often correspond to model-specific heuristics that fail to generalize across systems, which we call "local" logic. By framing prompt optimization as a tool for model interpretability, we argue that mapping these preferred reasoning structures for LLMs is an important prerequisite for effectively collaborating with superhuman intelligence.
Recent reasoning-focused language models such as DeepSeek R1 and OpenAI o1 have demonstrated strong performance on structured reasoning benchmarks including GSM8K, MATH, and multi-hop question answering tasks. However, their performance remains highly sensitive to prompt formulation, and designing effective prompts is typically a manual and iterative process that does not scale well across tasks or domains. To address this limitation, we introduce Retrieval-Augmented Self-Supervised Prompt Refinement (RASPRef), a framework that improves prompts without requiring human annotations or task-specific supervision. The approach retrieves relevant examples and previously generated reasoning trajectories, and leverages signals such as multi-sample consistency, verifier feedback, and model-generated critiques to iteratively refine the prompt. Unlike prior approaches that focus primarily on improving model outputs, RASPRef directly treats the prompt as the optimization target and improves it through an iterative retrieval-guided refinement process. Experiments on GSM8K-style mathematical reasoning tasks show that retrieval-guided prompting improves performance compared with a static prompting baseline. We further discuss how retrieval quality, trajectory selection, and self-supervised feedback signals may influence the effectiveness of prompt refinement. These findings suggest that prompt design remains a critical factor for reasoning-oriented language models, and that self-improving prompts offer a practical and scalable strategy for improving reasoning performance.