Automating Thought of Search: A Journey Towards Soundness and Completeness

Daniel Yiming Cao, Michael Katz, Harsha Kokel, Kavitha Srinivas, Shirin Sohrabi · Submission to ICLR 2026 · Withdrawn

TL;DR

While large language models (LLMs) excel at generating code, using them directly as search or planning engines often leads to hallucinations and unsound reasoning. AutoToS automates Thought of Search (ToS) by using automated, test-driven feedback loops—combining generic sanity checks, domain invariants, and unit tests—to guide LLMs into writing sound, complete search components in Python without any human in the loop.

What Problem Does This Paper Address?

Using LLMs for planning typically follows one of two extremes: prompting the model to generate a full plan directly (which often hallucinates invalid moves) or using the LLM as a step-by-step world model inside heuristic search algorithms like Tree-of-Thoughts or MCTS (which is computationally expensive, slow, and unreliable).

A recent alternative, Thought of Search (ToS), proposed having the LLM write the state-space dynamics in code just once—generating a successor generator (succ) and a goal test (isgoal) to plug into standard algorithms like Breadth-First Search (BFS) or Depth-First Search (DFS). While ToS achieved 100% accuracy, it relied heavily on a human expert to iteratively debug the code. AutoToS tackles the challenge of removing the human from this interactive debugging loop while maintaining soundness and completeness guarantees.

Methods

AutoToS guides an LLM to iteratively synthesize and refine search components through structured prompt-feedback cycles:

[Prompt LLM] ──> [Goal Tests] ──> [Soundness & Invariant Checks] ──> [Completeness Checks] ──> [BFS/DFS Search]
                        │                          │                               │
                        └────── Failure feedback ──┴──────── Failure feedback ─────┘
  1. System & Initial Prompts: The LLM is instructed to output self-contained Python functions for isgoal and succ with strict input/output formatting.
  2. Goal Function Verification: Known goal and non-goal states validate isgoal. If false positives (unsoundness) or false negatives (incompleteness) occur, Chain-of-Thought (CoT) feedback prompts the LLM to explain the bug and revise the code.
  3. Successor Soundness Testing: The candidate succ is wrapped and evaluated during initial BFS expansions on sample instances:
  4. Domain-Independent Checks: A 1-second timeout catches infinite loops or bloated computations; a state mutation check detects unintended in-place modifications (shallow copy bugs).
  5. Partial Soundness Tests (PST): Domain invariants verify transition validity (e.g., verifying that taking an action decreases remaining items or maintains physical constraints).
  6. Successor Completeness Testing (Optional): Candidate transitions are compared against known valid successors from sample states to ensure the search space is sufficiently covered.

Datasets

AutoToS was evaluated on five diverse planning problems spanning multiple computational complexity classes:

  • 24 Game (NP-complete; 1,362 instances from Yao et al., 2023)
  • BlocksWorld (NP-hard; 502 PDDL instances from Valmeekam et al., 2023a, validated with the classical PDDL validator VAL)
  • Mini Crosswords (5x5 grid puzzle; 20 instances from Yao et al., 2023)
  • PrOntoQA (Polynomial logical reasoning; 4,000 instances from Saparov & He, 2023)
  • Sokoban (PSPACE-complete; 11 challenging instances from IPC 2008)

For each domain, 2–10 small seed states were used as unit tests, leaving the remainder strictly for downstream evaluation.

Key Insights and Ideas

  • LLMs Make Subtle Planning Bloopers: Without feedback, models frequently omit precondition checks. In BlocksWorld, models routinely generated unstack operations without checking if the robot arm was empty—silently overwriting held blocks. In 24 Game, models filtered lists using element value equality, accidentally deleting duplicate numbers.
  • Invariants Catch What Unit Tests Miss: Generic input/output examples are often insufficient. Partial soundness invariants (e.g., checking that Sokoban stones do not share coordinates with walls or the player) proved crucial to prevent the search space from collapsing into invalid states.
  • Completeness Drives Accuracy: Soundness guarantees that generated plans are valid, but incompleteness causes the planner to miss solutions entirely. Adding completeness feedback bridges the gap from low initial solve rates to 100%.
  • Small Models Punch Above Their Weight: While smaller models like GPT-4o-mini require more feedback turns and exhibit more diverse runtime exceptions, they reach accuracy comparable to flagship models like GPT-4o and Llama-3.1-405B.

Key Results

  • 100% Accuracy: In best-of-5 runs with partial soundness tests (+PST), almost all models (including GPT-4o, DeepSeek-CoderV2, and Llama3.1-405b) achieved 100% accuracy across all five domains.
  • Dramatic Feedback Gains: Initial zero-shot generated code (baseline without feedback) scored 0% accuracy on complex domains like BlocksWorld and Sokoban. Soundness and completeness feedback restored performance to 100%.
  • Minimal LLM Invocations: The average number of LLM calls ranged from 2.0 to 10.0 per domain across models (e.g., GPT-4o required between 2.0 and 5.8 calls; DeepSeek-CoderV2 required 2.0 to 6.6 calls), matching the interaction budget of human-in-the-loop ToS.

Limitations and Future Work

  • Lack of Convergence Guarantees: Iterative prompt feedback does not theoretically guarantee that an LLM will converge on a correct program rather than introducing regressions.
  • Test Coverage Bounds: As with traditional software testing, passing unit tests does not formally prove universal soundness or completeness over infinite state spaces.
  • Benchmark Scope: The current framework is restricted to deterministic, fully observable domains.
  • Future Directions: Automating the creation of Partial Soundness Tests and planning invariants via LLMs (removing manual test writing entirely) and exploring fine-tuning on smaller open models specifically for search component synthesis.

Summary updated

BibTeX
@misc{cao2024automating,
  author = {Daniel Yiming Cao and Michael Katz and Harsha Kokel and Kavitha Srinivas and Shirin Sohrabi},
  title = {{Automating Thought of Search: A Journey Towards Soundness and Completeness}},
  year = {2024},
  eprint = {2408.11326},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.11326},
}
Figure