NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

InstructFlow: Adaptive Symbolic Constraint-Guided Code Generation for Long-Horizon Planning

Haotian Chi, Zeyu Feng, Yueming Lyu, Chengqi Zheng, Linbo Luo, Yew-Soon Ong, Ivor Tsang, Hechang Chen, Yi Chang, Haiyan YinNeurIPS 2025

TL;DR

InstructFlow is a multi-agent framework that helps Large Language Models (LLMs) write better robotic manipulation code by teaching them how to learn from their mistakes. Instead of blindly rewriting a failed program from scratch, it translates physical execution failures into logical "symbolic constraints" to perform targeted, localized code repairs. This approach boosts success rates by 20-40% on complex, long-horizon robotic tasks.

The Challenge: Long-Horizon Planning and Physical Constraints

Using LLMs to translate natural language instructions into executable robot code is a popular and promising paradigm. However, LLMs struggle with long-horizon planning and physical constraints. For example, if a robot is told to "put the green block in the bowl," but the green block is buried under a stack of other blocks, a naive LLM will generate code that drives the robotic arm straight through the stack, causing a collision.

When these execution failures happen in a simulator or the real world, current LLM planners usually resort to blind retries. They know the plan failed, but they lack the structured reasoning to understand why it failed or how to fix the specific root cause. As a result, they often regenerate a completely new plan that makes the exact same physical mistakes.

Methods: The InstructFlow Architecture

To solve this, the authors introduce InstructFlow, a framework that splits the code generation process into three specialized agents that communicate via a hierarchical "instruction graph".

The InstructFlow multi-agent architecture.
  1. InstructFlow Planner: Instead of writing code immediately, this agent breaks the natural language goal into a structured graph of subgoals (e.g., "pick object A" -> "place object A").
  2. Code Generator: This agent translates the graph's subgoals into executable Python code snippets and defines the safe parameter ranges (like spatial coordinates) for the robot's movements.
  3. Constraint Generator (The Core Innovation): When the code fails during execution (e.g., a collision is detected), this agent acts as a diagnostician. It analyzes the failure and induces a symbolic constraint—a logical rule like ClearOf(gripper, obstacle) or StableOn(block, table).

These symbolic constraints are fed back to the Planner, which updates the instruction graph by inserting new "reasoning nodes" (e.g., adding a step to unstack the obstacles first). The Code Generator then updates only the affected code snippets, avoiding a full rewrite.

Datasets and Evaluation

The system was evaluated in the Ravens simulation environment (using PyBullet) with a simulated 6-DoF UR5 robotic arm. The authors tested across three domains:

Example tasks across the Drawing, Arrange-Blocks, and Arrange-YCB domains.
  • Drawing: Generating 2D trajectories to draw shapes while avoiding obstacles.
  • Arrange-Blocks: Stacking and unstacking blocks and bowls (e.g., building pyramids).
  • Arrange-YCB: Packing and stacking complex, irregularly shaped objects from the standard YCB dataset.

Note on Evaluation: The authors noticed a flaw in previous benchmarks where physically valid but semantically incorrect plans (e.g., building a messy pile instead of a pyramid) were marked as successes. To fix this, they introduced a Vision-Language Model (VLM) check to verify that the final visual scene actually matches the user's prompt.

Key Insights

  • Symbolic abstraction bridges the physical-logical gap: LLMs are bad at reasoning about raw 3D coordinates but excellent at formal logic. By translating a messy physical collision into a clean symbolic rule (like "Object A must be clear of Object B"), the LLM can easily reason about how to fix the plan.
  • Graphs enable surgical repairs: Because the plan is structured as a hierarchical graph rather than a flat block of text, InstructFlow can pinpoint exactly which subgoal failed. It can insert a prerequisite step (like moving an obstacle) without throwing away the rest of the perfectly good code.
  • Failure is a feature, not a bug: Instead of treating execution failures as dead ends, InstructFlow uses them to dynamically map out the hidden constraints of the environment, turning trial-and-error into deliberate, compositional reasoning.

Results

  • Massive Success Rate Jump: InstructFlow outperformed strong baselines (PRoC3S, LLM3, Code-as-Policies) by 20–40% in task success rates across the benchmarks.
  • Higher Efficiency: Because it performs targeted repairs instead of full rewrites, InstructFlow reduced the number of feedback/retry cycles by ~37% and slightly reduced overall wall-clock latency (by ~4.7%).
  • Robustness to Noise: The researchers injected simulated sensor noise (up to 50% of object size) and corrupted the error feedback. InstructFlow maintained high performance, with success rates dropping by only 11-16% under incomplete feedback, proving it doesn't need perfect conditions to function.

Limitations and Future Work

The primary limitation is that all experiments were conducted in a simulated environment. While the authors modeled real-world uncertainties (like sensor noise), physical robotics introduces unpredictable physics and hardware quirks that simulation cannot fully capture. Additionally, the new evaluation protocol relies on a VLM (GPT-4o) as a judge, which could introduce its own biases or hallucinated success metrics.

In the future, the authors plan to deploy InstructFlow on real physical robots. They also aim to extend the framework to incorporate richer visual grounding, allowing the Constraint Generator to induce symbolic rules directly from unstructured, multi-modal feedback (like a video of a block tower falling over) rather than relying solely on simulator error logs.

Summary updated

BibTeX
@inproceedings{chi2025instructflow,
  author = {Haotian Chi and Zeyu Feng and Yueming Lyu and Chengqi Zheng and Linbo Luo and Yew-Soon Ong and Ivor Tsang and Hechang Chen and Yi Chang and Haiyan Yin},
  title = {{InstructFlow: Adaptive Symbolic Constraint-Guided Code Generation for Long-Horizon Planning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=nzwjvpCO4F},
}
Figure