Testing and Understanding Erroneous Planning in LLM Agents through Synthesized User Inputs

Zhenlan Ji, Daoyuan Wu, Pingchuan Ma, Zongjie Li, Shuai WangarXiv 2024 · DOI

TL;DR

Researchers have introduced PDoctor, an automated testing framework that treats LLM agent planning as a constraint satisfiability problem. By synthesizing complex user queries and using "mock tools" to track execution, PDoctor reveals that even state-of-the-art models like GPT-4 frequently fail at long-term planning, particularly when faced with temporal constraints.

What Problem Does This Paper Address?

Large Language Model (LLM) agents are increasingly deployed in high-stakes environments like chemical synthesis and financial services. While LLMs are great at "text-in, text-out" tasks, their ability to act as agents—decomposing a goal into a sequence of tool calls (planning)—is notoriously brittle.

Example of an LLM agent's action chain in response to a network speed query.

Existing evaluations often fail to isolate the "planning" module from other failures, such as poor tool design or bad natural language understanding. Furthermore, most benchmarks are static. In the real world, an agent must often adjust its plan based on tool feedback or manage global resources like time. The authors address the lack of a systematic, automated way to detect and understand these planning failures.

Methods

The authors propose PDoctor, which operates on the principle that a plan is "erroneous" if it violates constraints derived from the user's request. Its workflow consists of three main pillars:

  1. Constraint-Based Synthesis: PDoctor uses a specialized Domain-Specific Language (DSL) to generate "skeletons" of user queries. It then uses the Z3 constraint solver to ensure these skeletons are logically satisfiable before filling them with natural language. This allows the system to generate thousands of unique, complex test cases with known "ground truth" constraints.
  2. The "Mock Tool" Approach: To isolate the planning module, PDoctor creates "mock tools" that don't actually perform complex tasks. Instead, they simply record their execution order and parameters to a log file. This ensures that if a test fails, it’s because the agent planned the wrong sequence, not because a tool crashed.
  3. Error Dissection: When an agent fails, PDoctor automatically mutates the query (changing specific words, topics, or the entire structure) to pinpoint the root cause. Is the error a fluke of randomness (Probability), a reaction to specific words (Terminal), or a fundamental inability to handle the logical complexity (Constraint)?
The PDoctor workflow for synthesizing queries and checking agent plans against constraints.

The researchers also created an Extended Testing Framework that introduces time and duration constraints, forcing agents to manage a "schedule" and re-plan if a tool takes longer than expected.

Key Insights and Ideas

  • The "Planning Wall": LLM agents have a clear "upper bound" for planning. GPT-3.5’s success rate plummets once a task requires more than 3 actions. GPT-4 is much more robust but begins to struggle significantly after 8 actions.
  • Order Errors Dominate: The most common failure isn't forgetting a task or failing to call a tool; it’s Order Error—executing steps in a sequence that violates the user's logic.
  • Frameworks Matter: Frameworks that use fine-tuned function calling (OpenAI Tools and Assistant) significantly outperform the "prompt-only" ReAct framework, especially as tasks get more complex. ReAct’s long prompt templates often cause the model to "forget" earlier instructions.
  • The Fragility of Time: Adding temporal constraints (e.g., "Task A must happen after 10:00") makes the problem exponentially harder. Under these conditions, GPT-3.5 becomes almost entirely unusable for planning, and even GPT-4's success rate drops below 50% for relatively simple 5-step tasks.

Key Results

  • Effectiveness: PDoctor successfully detected thousands of planning errors across all tested models and frameworks.
  • Model Comparison: GPT-4 reduced the error rate by an average of 48.53% compared to GPT-3.5.
  • Efficiency: Despite using a formal constraint solver (Z3), the synthesis process is fast, averaging only 0.07 seconds to generate a test case. The bottleneck remains the LLM's own inference speed.
  • Root Causes: Through dissection, the authors found that Terminal (specific word choice) and Probability (randomness) are major factors in failures, suggesting that agent behavior is still highly sensitive to "prompt engineering" nuances.

Limitations and Future Work

  • Common Sense Conflicts: The framework assumes that the only constraints are the ones provided in the query. It doesn't yet account for "common sense" dependencies (e.g., you must open a door before walking through it) unless explicitly stated.
  • Self-Correction: While the paper notes that agents struggle to re-plan, it doesn't deeply explore how to fix these errors automatically.
  • Future Directions: The authors suggest using PDoctor's "error-driven" feedback to fine-tune models specifically for planning, potentially using the Z3 solver's "unsat core" feature to tell the LLM exactly which constraint it violated.

Summary updated

Abstract

Agents based on large language models (LLMs) have demonstrated effectiveness in solving a wide range of tasks by integrating LLMs with key modules such as planning, memory, and tool usage. Increasingly, customers are adopting LLM agents across a variety of commercial applications critical to reliability, including support for mental well-being, chemical synthesis, and software development. Nevertheless, our observations and daily use of LLM agents indicate that they are prone to making erroneous plans, especially when the tasks are complex and require long-term planning. In this paper, we propose PDoctor, a novel and automated approach to testing LLM agents and understanding their erroneous planning. As the first work in this direction, we formulate the detection of erroneous planning as a constraint satisfiability problem: an LLM agent's plan is considered erroneous if its execution violates the constraints derived from the user inputs. To this end, PDoctor first defines a domain-specific language (DSL) for user queries and synthesizes varying inputs with the assistance of the Z3 constraint solver. These synthesized inputs are natural language paragraphs that specify the requirements for completing a series of tasks. Then, PDoctor derives constraints from these requirements to form a testing oracle. We evaluate PDoctor with three mainstream agent frameworks and two powerful LLMs (GPT-3.5 and GPT-4). The results show that PDoctor can effectively detect diverse errors in agent planning and provide insights and error characteristics that are valuable to both agent developers and users. We conclude by discussing potential alternative designs and directions to extend PDoctor.
BibTeX
@misc{ji2024testing,
  author = {Zhenlan Ji and Daoyuan Wu and Pingchuan Ma and Zongjie Li and Shuai Wang},
  title = {{Testing and Understanding Erroneous Planning in LLM Agents through Synthesized User Inputs}},
  year = {2024},
  eprint = {2404.17833},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.17833},
}
Figure