Introduction
Large Language Models (LLMs) have emerged as powerful general-purpose reasoners, making them popular choices for task planning in autonomous agents. However, deploying LLMs in specific sequential decision-making environments reveals two major hurdles:
- The Knowledge Gap: LLMs often "hallucinate" actions or objects that violate a specific environment's rules because their broad pre-training does not perfectly align with niche simulation dynamics.
- The Efficiency Crisis: Current state-of-the-art methods (like ReAct or Reflexion) rely on "chatty" loops—querying the massive LLM for every single action based on immediate environmental feedback. This step-by-step refinement is computationally expensive, slow, and often biases the agent toward short-term gains rather than long-term rewards.
To address these issues, researchers introduce CoPiC (Code Driven Planning with Domain-Adaptive Selector). CoPiC shifts LLM-based planning away from expensive, step-by-step text generation toward generating reusable "planning programs" (Python code), drastically reducing query costs while improving task success rates.
How CoPiC Works
CoPiC splits the planning process into two distinct roles: generating the logic and evaluating the execution path.
- The LLM Planner (The Architect): Instead of generating a single immediate action, the LLM generates a diverse set of high-level planning programs (Python scripts). These programs encapsulate the logic needed to interact with the environment, handle loops, and check preconditions locally. By generating code, the LLM "compresses" its reasoning—a single Python script can execute hundreds of environment steps without requiring further LLM queries.
- The Domain-Adaptive Selector (The Judge): Because different programs might suggest different strategies (a Mixture-of-Experts approach), a "Selector" evaluates the candidate plans. Crucially, this is not a massive LLM. It is a lightweight model (e.g., TinyLlama-1.1B) fine-tuned using Reinforcement Learning (PPO). It learns to score plans based on actual long-term environment rewards, bridging the gap between the LLM's general knowledge and the specific "physics" of the task.
- Iterative Evolution: CoPiC employs a "Learning Phase" that analyzes failed trajectories. It feeds this historical data back to the LLM to debug and refine the planning programs, effectively evolving the code to be more robust over time.
Key Insights
- Code as Logic, Not Just Text: Executable code allows agents to handle repetitive tasks and local checks autonomously, bypassing the need for constant LLM intervention.
- Small Models for Big Decisions: You do not need a frontier model (like GPT-4) to evaluate a plan. A 1.1B parameter model, when specifically tuned on domain rewards, can outperform a giant generalist model at picking the winning path.
- Closing the Loop with RL: The Selector dynamically learns from the environment's "ground truth" rewards, ensuring the agent prioritizes long-term success over immediate, short-sighted actions.
Evaluation and Results
The framework was evaluated across three diverse and challenging environments: ALFWorld (text-based household tasks), NetHack (a complex roguelike game requiring resource management), and StarCraft II Unit Building (navigating complex tech trees).
The results demonstrate a massive leap in both performance and efficiency:
- Performance Boost: CoPiC achieved an average 19.14% improvement in success rate over advanced baselines like AdaPlanner and Reflexion.
- Massive Cost Savings: By relying on generated programs rather than step-by-step queries, the approach resulted in a 79.39% reduction in token costs. In some NetHack tasks, query reduction reached as high as 96%.
- Efficiency: The agents required 30.43% fewer interaction steps to complete tasks, indicating that the selected plans were more direct and effective.
Limitations and Future Directions
While highly effective, CoPiC relies heavily on the underlying LLM's ability to write functional Python code. While frontier models excel at this, smaller or older models might struggle to generate the initial planning programs. Furthermore, CoPiC currently operates at the high-level planning stage; real-world robotics would still require lower-level controllers to translate commands into motor actions.
Future work aims to scale CoPiC to even more complex, long-horizon games like Civilization and full-scale StarCraft II matches, where strategic planning over thousands of steps is paramount.
Summary updated