NESTFUL: A Benchmark for Evaluating LLMs on Nested Sequences of API Calls

Kinjal Basu, Ibrahim Abdelaziz, Kiran Kate, Mayank Agarwal, Maxwell Crouse, Yara Rizk, Kelsey Bradford, Asim Munawar, Sadhana Kumaravel, Saurabh Goyal, Xin Wang, Luis A. Lastras, Pavan Kapanipathi

TL;DR

This paper introduces NESTFUL, a new benchmark designed to evaluate Large Language Models (LLMs) on their ability to handle nested sequences of API calls, a crucial capability for autonomous agents. Existing benchmarks fall short in evaluating this complex dependency, and NESTFUL aims to fill this gap with over 1800 executable nested API call sequences.

What Problem Does This Paper Address?

Autonomous agents powered by LLMs are increasingly being used to tackle complex real-world tasks. A core component of these agents is their ability to interact with external environments through tool, function, or API calls. While LLMs have shown promise in this area, current evaluation benchmarks and datasets lag behind in representing the complexity of these interactions. Specifically, the ability to chain API calls where the output of one call serves as the input for another (nested sequencing) is a critical but underexplored aspect. Existing benchmarks often treat API calls as isolated events, failing to capture the data dependencies inherent in real-world applications. This gap hinders the development of more sophisticated and reliable autonomous agents.

Methods

The paper introduces NESTFUL, a benchmark that provides a comprehensive framework for evaluating LLMs on nested API call sequences. The NESTFUL framework includes:

  • User Queries: Natural language prompts that require API calls to answer.
  • Tool Library: A catalog of APIs with their specifications (name, description, parameters, output parameters).
  • Gold Function Sequence: The correct sequence of API calls and their arguments to answer the query.
  • Executable Implementations: Python code for each API, allowing for actual execution of the predicted sequences.
  • Evaluation Pipeline: A system to run LLM-generated sequences, execute them, and compare the results against the gold standard.

NESTFUL utilizes a data schema that explicitly supports tool referencing, where a variable name is assigned to the output of a tool call, allowing subsequent calls to use this output as an argument. This is crucial for representing nested dependencies. The benchmark was curated from two primary sources: the MathQA dataset for mathematical reasoning and the StarCoder2-Instruct dataset for generic Python functions.

Datasets

  • MathQA: A dataset for mathematical reasoning, adapted to create nested tool call sequences. The original "annotated formula" was parsed into sequences of tool calls.
  • StarCoder2-Instruct: A dataset of Python functions used to curate test examples for coding-related API calls.
  • NESTFUL: The newly introduced benchmark, comprising over 1800 nested API call sequences. It is built upon the aforementioned datasets and includes executable Python implementations for all tools. The dataset is publicly released under the Apache 2.0 license.

Key Insights and Ideas

  • Nestedness is Hard: The core finding is that LLMs struggle significantly with nested API call sequences, especially as the depth of nesting increases. This highlights a fundamental limitation in their ability to manage complex data dependencies.
  • Model Size Isn't Everything: While larger models generally perform better, architectural complexity or size alone doesn't guarantee success. Effective instruction following and leveraging in-context learning examples appear to be more critical factors. Some smaller models achieved exceptional results, outperforming larger ones.
  • ReAct Shows Promise: Agentic approaches like ReAct, which allow for step-by-step reasoning and interaction, show improved performance over direct prompting on NESTFUL, especially for larger models. This suggests that iterative reasoning and planning are beneficial for complex API call scenarios.
  • Data Dependencies Matter: The performance of LLMs is strongly correlated with the complexity of data dependencies. Simple, linear sequences are handled well, but branching or deeply nested dependencies pose significant challenges.
  • Implicit API Calling is a Hurdle: LLMs often struggle with implicit API calling, where they must infer and invoke appropriate APIs without explicit mentions in the user query.

Key Results

  • GPT-4o achieved the best performance on NESTFUL, with a 28% full sequence match accuracy and a 60% win rate in the three-shot setting.
  • Despite being state-of-the-art, these results are considered significantly below acceptable numbers for real-world applications, indicating substantial room for improvement.
  • Models generally perform better with three in-context learning (ICL) examples compared to one-shot settings.
  • Partial Sequence Match scores are consistently higher than Full Sequence Match scores, as expected due to the stricter requirements of the latter.
  • The Win Rate metric, which focuses on the correctness of the final output, is often higher than accuracy metrics, suggesting that models can sometimes reach the correct answer through alternative reasoning paths.
  • For ReAct-based evaluation, Mixtral-8x22B-Instruct-v0.1 showed the highest win-rate gain of 30% compared to direct prompting.

Limitations and Future Work

  • No Environment Interaction: NESTFUL currently does not involve environment interactions for AI agents or the execution of real-world APIs.
  • Future Work: The authors plan to expand NESTFUL with real-world API integrations (e.g., via RapidAPI) and explore embodied agents where API calls produce changes in a grounded environment. They also aim to improve the dataset with more complex scenarios and potentially explore agentic approaches further.

Summary updated

BibTeX
@inproceedings{basu2025nestful,
  author = {Kinjal Basu and Ibrahim Abdelaziz and Kiran Kate and Mayank Agarwal and Maxwell Crouse and Yara Rizk and Kelsey Bradford and Asim Munawar and Sadhana Kumaravel and Saurabh Goyal and Xin Wang and Luis A. Lastras and Pavan Kapanipathi},
  title = {{NESTFUL: A Benchmark for Evaluating LLMs on Nested Sequences of API Calls}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure