arXiv:2610.28116cs.SEOct 2026

Manuscript Offprint

arXiv:2610.28116

AgenTest: Mining Business Rules to Test LLM Agents for Business Logic Bugs

Lili Quan, Longtian Wang, Yuelin Wang, Mingfei Cheng, Chao Shen, Sen Chen, Xiaofei Xie

LILI QUAN, Singapore Management University, Singapore

LONGTIAN WANG, Xi'an Jiaotong University, China

YUELIN WANG, Tianjin University, China

MINGFEI CHENG ∗^{*}, Singapore Management University, Singapore

CHAO SHEN, Xi'an Jiaotong University, China

SEN CHEN, Nankai University, China

XIAOFEI XIE, Singapore Management University, Singapore

Large language model (LLM) agents increasingly execute business operations through tools and interact directly with application data and services. Beyond completing user requests, these agents must obey domain-specific business rules that constrain when actions are permitted and what data or resources may be affected. Violating such rules can lead to business logic bugs, even when a task appears successful. Detecting these bugs is difficult because the rules are rarely available as explicit, testable specifications. They are distributed across system prompts and tool definitions, while others remain implicit in domain knowledge. Existing agent testing approaches typically evaluate task success, predefined policies, or known attack scenarios. This limits their ability to systematically uncover previously unspecified business-rule violations.

We present AGENTEST, which mines business rules from system prompts, tool definitions, and domain knowledge, refines them into Given-When-Then specifications, and systematically tests each specification. For each extracted specification, AGENTEST instantiates its Given conditions by constructing a satisfying environment state and simulated user, exercises the agent through multi-turn interactions, and checks its Then conditions over messages, tool calls, and state changes using a hybrid oracle. On the airline, retail, and telecom agents of τ2\tau^{2}-bench with two underlying models, AGENTEST produces 551 refined specifications, and detects violations of 89 and 121 distinct specifications, respectively—3.4× and 2.5× as many as all baselines combined. Only AGENTEST detects cases where an agent improperly accesses or modifies another user's data. Moreover, about 60% of bug-triggering runs cannot be detected from the final state alone, highlighting the need to check the full interaction against explicit business rules.

CCS Concepts: • Software and its engineering → Software testing and debugging.

Additional Key Words and Phrases: LLM agents, business logic bugs, specification-driven testing

1 Introduction

Large language model (LLM) agents increasingly execute business operations through external tools. Customer-service agents, for example, can modify orders, issue refunds, cancel subscriptions, and update information through backend APIs [16][16]. Such agents are becoming part of the business software they serve: they must not only complete user requests, but also obey the business rules that govern when and how those requests may be carried out. We study these tool-using agents [5,24,31][5, 24, 31], which act by selecting and invoking tools such as database queries and application APIs.

LLM agents are different from conventional software. In conventional systems, business logic is typically encoded explicitly in program code through deterministic control flow, authorization checks, validation conditions, and data constraints. These mechanisms precisely define which

∗^{*}Corresponding Author

Authors' Contact Information: Lili Quan, liliquan@smu.edu.sg, Singapore Management University, Singapore; Longtian Wang, w976625943@stu.xjtu.edu.cn, Xi'an Jiaotong University, China; Yuelin Wang, Tianjin University, China, 3020001251@tju.edu.cn; Mingfei Cheng, Singapore Management University, Singapore, snowbirds.mf@gmail.com; Chao Shen, Xi'an Jiaotong University, China, chaoshen@mail.xjtu.edu.cn; Sen Chen, Nankai University, China, senchen@nankai.edu.cn; Xiaofei Xie, Singapore Management University, Singapore, xfxie@smu.edu.sg.

Lili Quan et al.

operations are allowed under which conditions. In LLM agents, however, part of this logic is delegated to the model: behavioral requirements are expressed in natural-language prompts, shaped by tool definitions, and interpreted dynamically during interaction. As a result, the agent often lacks the explicit and deterministic business-logic constraints provided by conventional code. A rule may be followed in one conversation but violated in another depending on how the request is phrased, what context is available, or how the interaction unfolds. When such agents directly operate on business data and services, this uncertainty can translate into concrete business risks, such as unauthorized operations, incorrect transactions, or violations of required workflows.

Existing approaches to testing LLM agents largely fall into two categories. The first focuses on general security threats, such as jailbreaks, prompt injection, malicious tool use, and other adversarial behaviors [3, 11, 27, 32]. These approaches are important for security, but they do not target the domain-specific business rules that govern legitimate operations. The second evaluates business functionality through predefined tasks and manually specified expected outcomes, as in benchmarks such as τ2\tau^{2}-bench [6]. Such tests can check whether an agent behaves correctly on known scenarios, but they require developers or benchmark designers to specify in advance what behavior to exercise and how to judge the result.

This leaves a fundamental gap for business logic testing: the rules to be tested may not be explicitly available. They can be distributed across the system prompt and tool definitions, or remain implicit in domain semantics. Figure 1 illustrates this problem. Alice asks the airline agent to add a checked bag to a reservation owned by Bob. The agent performs the update without establishing that Alice owns the reservation, charges Bob's credit card, and reports success. The run satisfies the requested functionality and ends in a valid state, yet violates the business rule that a reservation may be modified only at the request of its owner. This rule is not explicitly stated in any single artifact: the prompt requires user identification, and the tool accepts a reservation identifier, but neither states that the requester must match the reservation owner. A predefined functional test will detect this bug only if a human has already anticipated this rule, constructed the corresponding scenario, and provided an oracle for it.

Even after such a rule is discovered, automatically testing it remains challenging. Business rules are typically abstract constraints rather than executable test cases: they do not directly specify what state should be created, how the interaction should unfold, or what observations constitute a violation. A tester must therefore operationalize each rule into a concrete scenario that can exercise the relevant behavior and provide a reliable oracle for judging the execution. This is particularly difficult for LLM agents because violations may depend on the conversation trajectory and may only be observable in intermediate messages or tool calls rather than in the final state.

Figure

Fig. 1. The agent modifies another user's reservation without verifying the requester.

Our key insight is to make each business rule an explicit test target and use it to drive the entire testing process. We present AGENTEST, a specification-driven approach that mines business rules from the system prompt, tool definitions, and domain knowledge, and refines them into Given-When-Then specifications. The system prompt is a primary source of explicit behavioral requirements, while tool definitions characterize the business operations the agent can perform and the data and arguments on which those operations depend. Considering both is therefore necessary to recover rules that govern not only what the agent is instructed to do, but also how those instructions constrain concrete actions in the environment.

Specifically, AGENTEST combines three techniques. It first mines candidate rules from prompts and tool definitions and augments them with domain knowledge, then refines them into precise Given-When-Then specifications. For each specification, AGENTEST constructs an environment state and simulated user that satisfy its Given preconditions, drives multi-turn interactions to exercise the relevant behavior, and checks whether the resulting messages, tool calls, and state changes satisfy its Then postconditions. The specification serves not only as an oracle, but also as a driver for generating the scenario and interaction needed to expose a violation. Finally, it checks the resulting execution with a hybrid oracle that combines deterministic checks over structured behaviors with LLM judgments for natural-language conditions.

We evaluate AGENTEST on the airline, retail, and telecom agents of τ2\tau^{2}-bench with two underlying models, DeepSeek-V4-Flash and Qwen-3.8-Flash, and compare it with the benchmark's task suite, IntellAgent, and MANTRA. AGENTEST produces 551 refined specifications. It detects violations of 89 and 121 distinct specifications, 3.4 and 2.5 times as many as all baselines combined, and no baseline finds 83 and 97 of them. Only AGENTEST exposes agents acting on another user's object, a situation that a test must construct deliberately, and about 60% of the runs with a bug leave no visible trace in the final state. Interaction strategies account for most of the bugs: on DeepSeek-V4-Flash, testing each specification without them yields only 6 bugs, against 89 with them.

Our main contributions are as follows:

• Business-rule-driven testing for LLM agents. We formulate business logic testing as the problem of discovering the rules that should govern an agent and making each rule an explicit test target, including rules that are distributed across agent artifacts or implicit in domain knowledge.

• Automated rule-to-test operationalization. We present AGENTEST, which refines mined rules into Given-When-Then specifications and uses them to drive test construction, multi-turn interaction, and violation checking. We further introduce interaction strategies with bug-guided adaptation and a hybrid oracle that checks both structured execution behavior and natural-language conditions.

• Large-scale empirical evaluation. Across three τ2\tau^{2}-bench domains and two underlying models, AGENTEST produces 551 refined specifications and detects violations of 89 and 121 distinct specifications, respectively, 3.4×3.4\times and 2.5×2.5\times as many as all baselines combined. It also uncovers cross-user data violations and shows that about 60% of bug-triggering runs cannot be detected from the final state alone.

References (15)