Table of Contents
Fetching ...

CP-Agent: Agentic Constraint Programming

Stefan Szeider

TL;DR

CP-Agent addresses the bottleneck of translating natural language problem descriptions into constraint programs by using an agentic, tool-using loop guided by a concise domain prompt within a persistent IPython kernel. It iteratively tests, observes solver feedback, and refines CPMpy constraints using a ReAct-based workflow; on CP-Bench 101 problems with clarified specifications, it achieves perfect coverage. Ablation shows that minimal guidance outperforms heavy scaffolding, and explicit task-management tools can hinder performance in focused, single-file tasks. The work demonstrates a general, domain-adaptable architecture for declarative problem solving, extendable to other domains via domain prompts and an MCP-based interactive interface.

Abstract

Translating natural language into formal constraint models requires expertise in the problem domain and modeling frameworks. To investigate whether constraint modeling benefits from agentic workflows, we introduce CP-Agent, a Python coding agent using the ReAct framework with a persistent IPython kernel. Domain knowledge is provided through a project prompt of under 50 lines. The agent iteratively executes code, observes the solver's feedback, and refines models based on the execution results. We evaluate CP-Agent on CP-Bench's 101 constraint programming problems. We clarified the benchmark to address systematic ambiguities in problem specifications and errors in ground-truth models. On the clarified benchmark, CP-Agent solves all 101 problems. Ablation studies indicate that minimal guidance outperforms detailed procedural scaffolding, and that explicit task management tools have mixed effects on focused modeling tasks.

CP-Agent: Agentic Constraint Programming

TL;DR

CP-Agent addresses the bottleneck of translating natural language problem descriptions into constraint programs by using an agentic, tool-using loop guided by a concise domain prompt within a persistent IPython kernel. It iteratively tests, observes solver feedback, and refines CPMpy constraints using a ReAct-based workflow; on CP-Bench 101 problems with clarified specifications, it achieves perfect coverage. Ablation shows that minimal guidance outperforms heavy scaffolding, and explicit task-management tools can hinder performance in focused, single-file tasks. The work demonstrates a general, domain-adaptable architecture for declarative problem solving, extendable to other domains via domain prompts and an MCP-based interactive interface.

Abstract

Translating natural language into formal constraint models requires expertise in the problem domain and modeling frameworks. To investigate whether constraint modeling benefits from agentic workflows, we introduce CP-Agent, a Python coding agent using the ReAct framework with a persistent IPython kernel. Domain knowledge is provided through a project prompt of under 50 lines. The agent iteratively executes code, observes the solver's feedback, and refines models based on the execution results. We evaluate CP-Agent on CP-Bench's 101 constraint programming problems. We clarified the benchmark to address systematic ambiguities in problem specifications and errors in ground-truth models. On the clarified benchmark, CP-Agent solves all 101 problems. Ablation studies indicate that minimal guidance outperforms detailed procedural scaffolding, and that explicit task management tools have mixed effects on focused modeling tasks.

Paper Structure

This paper contains 28 sections, 1 figure, 3 tables.

Figures (1)

  • Figure 1: The ReAct (Reason and Act) framework employed by the agent.