arXiv:2507.09481cs.SEcs.AI2025-07被引 4

用自动化生成测试用例,评估大模型调用API的顺序能力。

Evaluating LLMs on Sequential API Call Through Automated Test Generation

  • 通过状态机和采样生成包含多步API调用的代码任务。
  • 构建120个验证过的测试用例,覆盖3类真实场景。
  • 适合研究大模型工具使用与评估的学者使用。

大型语言模型(LLMs)通过集成外部API,拓展了在复杂现实任务中的能力。然而,对LLM工具使用的测试、评估与分析仍处于初级阶段。现有基准大多依赖人工收集的测试用例,许多无法自动验证语义正确性,仅依赖字符串匹配等静态方法。此外,这些基准常忽略真实应用中常见的多步API调用间复杂交互。为此,本文提出StateGen,一个自动化框架,用于生成涉及多步API交互的多样化编程任务。StateGen结合基于状态机的API约束求解与验证、基于能量的采样及控制流注入,生成可执行程序,并通过两个LLM代理协作将其转化为类人自然语言任务描述。基于StateGen,我们构建了StateEval基准,包含120个经验证的测试用例,覆盖会话服务、张量操作和ElevenLabs MCP三种典型场景。实验结果表明,StateGen能有效生成具有挑战性且真实的面向API的任务,揭示了当前集成API的LLMs的改进空间。框架与基准已公开,以支持未来研究。

原文摘要 · Abstract (English)

By integrating tools from external APIs, Large Language Models (LLMs) have expanded their promising capabilities in a diverse spectrum of complex real-world tasks. However, testing, evaluation, and analysis of LLM tool use remain in their early stages. Most existing benchmarks rely on manually collected test cases, many of which cannot be automatically checked for semantic correctness and instead depend on static methods such as string matching. Additionally, these benchmarks often overlook the complex interactions that occur between sequential API calls, which are common in real-world applications. To fill the gap, in this paper, we introduce StateGen, an automated framework designed to generate diverse coding tasks involving sequential API interactions. StateGen combines state-machine-based API constraint solving and validation, energy-based sampling, and control-flow injection to generate executable programs. These programs are then translated into human-like natural language task descriptions through a collaboration of two LLM agents. Utilizing StateGen, we construct StateEval, a benchmark encompassing 120 verified test cases spanning across three representative scenarios: Session Service, Tensor Operation, and ElevenLabs MCP. Experimental results confirm that StateGen can effectively generate challenging and realistic API-oriented tasks, highlighting areas for improvement in current LLMs incorporating APIs.We make our framework and benchmark publicly available to support future research.

大模型评估API调用自动化测试

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。