NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Self-Guided Function Calling in Large Language Models via Stepwise Experience Recall

Sijia Cui, Aiyao He, Shuai Xu, Hongming Zhang, Yanna Wang, Qingyang Zhang, Yajing Wang, Bo Xu

Abstract

Function calling enables large language models (LLMs) to interact with external systems by leveraging tools and APIs. When faced with multi-step tool usage, LLMs still struggle with tool selection, parameter generation, and tool-chain planning. Existing methods typically rely on manually designing task-specific demonstrations or retrieving from a curated library. These approaches demand substantial expert effort, and prompt engineering becomes increasingly complex and inefficient as tool diversity and task difficulty scale. To address these challenges, we propose a self-guided method, Stepwise ExperiencE Recall (SEER), which performs fine-grained, stepwise retrieval from a continually updated experience pool. Instead of relying on a static or manually curated library, SEER incrementally augments the experience pool with past successful trajectories, enabling continuous expansion of the pool and improved model performance over time. Evaluated on the ToolQA benchmark, SEER achieves an average improvement of 6.1% on easy and 4.7% on hard questions. We further test SEER on $\tau$-bench, which includes two real-world domains. Powered by Qwen2.5-7B and Qwen2.5-72B models, SEER demonstrates substantial accuracy gains of 7.44% and 23.38%, respectively.

Introduction: The Challenge of Multi-Step Function Calling

While Large Language Models (LLMs) have shown remarkable capabilities in general reasoning, they often falter when tasks require "function calling"—the use of external tools or APIs across multiple steps. Current solutions primarily rely on In-Context Learning (ICL), where developers manually curate a few demonstrations to guide the model.

However, this approach faces three significant hurdles:

  1. Scalability: It is impossible to include examples for every potential tool combination within a limited token window.
  2. Static Nature: Manual libraries do not evolve or adapt as the model encounters novel problem types.
  3. Coarse Retrieval: Traditional retrieval methods often match examples based on the initial user query, ignoring the fact that the optimal demonstration may depend on the specific intermediate state of a multi-step tool-chain.

SEER (Stepwise ExperiencE Recall) addresses these gaps by introducing a dynamic, self-guided loop that selects the most relevant examples for each specific sub-step and allows the model to learn from its own successes without human intervention.

The SEER Framework

The SEER framework architecture, showing the stepwise recall and experience accumulation processes.

SEER consists of three core components designed to facilitate continuous learning and precise retrieval:

1. Trajectory Experience Extraction

Every interaction is converted into a structured "experience tuple." This tuple includes the embedding of the full trajectory, the initial query, the inferred user intent, and the sequence of tools used (the tool-chain). This structured format allows for more nuanced retrieval than simple text-based matching.

2. Stepwise Experience Recall

This component acts as the retrieval engine. Rather than relying solely on keyword similarity, it employs a multi-dimensional scoring function:

  • Trajectory Similarity ($s_1$): Measures how closely the current interaction history matches a past successful trajectory.
  • ToolChain Coverage ($s_2$): Evaluates if a past example utilizes the same sequence of tools the model has already initiated in the current session.
  • Intent Match ($s_3$): Ensures the high-level goal (e.g., "cancel a flight") aligns with the retrieved example.

3. Continual Experience Accumulation

SEER implements a self-improvement flywheel. Upon task completion, an "LLM-as-a-judge" evaluates the outcome. Successful trajectories are automatically added to the experience pool, allowing the model to expand its knowledge base during deployment.

Experimental Setup

The researchers evaluated SEER across two rigorous benchmarks:

  • ToolQA: A dataset covering 8 real-world domains (e.g., Flight, Yelp, Airbnb) with 1,530 questions. It specifically tests multi-step reasoning and tool interaction.
  • $\tau$-bench: A challenging benchmark simulating multi-turn interactions in Airline and Retail domains, requiring models to manage evolving user intents and complex database constraints.

Results and Analysis

Accuracy trends across batches, highlighting the self-improvement capability of the SEER model.

SEER demonstrated significant performance improvements across all tested scenarios. On the ToolQA benchmark, it outperformed the previous state-of-the-art (ExpeL) by 6.1% on easy questions and 4.7% on hard questions. On $\tau$-bench, SEER enabled open-source models like Qwen2.5-72B to narrow the gap with closed-source models like GPT-4o, achieving 51.84% accuracy compared to GPT-4o's 54.76%.

Key insights from the evaluation include:

  • The Power of the Tool-Chain: ToolChain Coverage ($s_2$) proved to be a critical signal for complex tasks, often providing more utility than query similarity alone.
  • Self-Improvement Flywheel: As shown in Figure 3, accuracy on ToolQA climbed steadily as the experience pool grew, rising from approximately 37% in the first batch to 55% by the tenth batch.
  • Optimal Context Density: Performance peaked at approximately 4 demonstrations. Increasing the number of examples beyond 6-8 led to a decline in accuracy, likely due to prompt clutter and increased model confusion.

Conclusion

SEER represents a significant step toward autonomous, self-improving LLMs for tool use. By shifting from static, manually curated prompts to a dynamic, stepwise recall system, SEER enables models to handle complex, multi-step function calling with greater precision. Future work will explore dynamic weighting for the scoring metrics and the integration of self-reflection steps to further refine the model's planning capabilities.

Summary updated

BibTeX
@misc{cui2025self,
  author = {Sijia Cui and Aiyao He and Shuai Xu and Hongming Zhang and Yanna Wang and Qingyang Zhang and Yajing Wang and Bo Xu},
  title = {{Self-Guided Function Calling in Large Language Models via Stepwise Experience Recall}},
  year = {2025},
  eprint = {2508.15214},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.15214},
}
Figure