When an AI agent formulates a plan, it's rarely operating in a vacuum. Real-world tasks come with boundaries, limitations, and desired characteristics for the outcome. Simply instructing an agent to "plan a marketing campaign" is too open-ended. Does it have a budget? A deadline? Are there specific channels to use or avoid? This is where incorporating constraints and preferences into your prompts becomes essential for guiding the agent towards a useful and acceptable plan. Prompts are your primary tool for communicating these important details, shaping the agent's decision-making process from the outset.
It's helpful to distinguish between two main categories:
Hard constraints define the boundaries of the problem space for the agent. Clear, unambiguous constraints are fundamental for effective planning.
Use clear, imperative language. Keywords like MUST
, MUST NOT
, REQUIRED
, SHALL
, SHALL NOT
can effectively signal a hard constraint.
System: You are a project planning assistant.
User: Plan the software development project.
Constraints:
1. MUST deliver the alpha version by 2023-10-30.
2. MUST NOT exceed a development team size of 5 engineers.
3. REQUIRED: The plan must include weekly progress reports.
These often involve quantifiable limits such as budget, time, or computational resources.
Time Constraints: "The entire research phase MUST be completed within 7 working days."
Budget Constraints: "The proposed solution MUST have an estimated implementation cost below $10,000."
API Call Limits: "When using external APIs, the agent MUST NOT make more than 100 calls per hour to the GeoLocationAPI
."
Example Prompt Snippet:
"Hard Constraint: The total allocated budget for acquiring necessary software licenses is $1,200. The plan must not exceed this amount for licenses."
These dictate how the agent should operate, including tool usage, output formats, or specific procedures.
Tool Usage: "MUST use the InternalKnowledgeBaseSearchTool
before attempting any external web searches." or "MUST NOT use DeprecatedAnalysisTool
."
Output Format: "The final plan MUST be presented as a JSON object with the following keys: project_name
, phases
, timeline
, resource_allocation
."
Procedural Steps: "Before finalizing the plan, REQUIRED: verify all supplier availabilities."
Example Prompt Snippet:
"Operational Constraint: All Python code generated as part of this plan MUST adhere to PEP 8 styling guidelines and include docstrings for every function."
For agents interacting with sensitive information or making impactful decisions, prompts must include safety and ethical guidelines.
Data Handling: "MUST NOT include any Personally Identifiable Information (PII) in the generated summaries."
Tone and Content: "The agent's proposed communication plan MUST maintain a professional and neutral tone. AVOID generating speculative or unverified claims."
Prohibited Actions: "Under no circumstances should the agent attempt to modify system configuration files directly."
Example Prompt Snippet:
"Safety Constraint: The agent MUST NOT suggest any actions that involve circumventing security protocols or sharing confidential data outside the designated secure channels."
Preferences guide the agent toward more desirable solutions when multiple valid options exist within the defined constraints. They add a layer of qualitative guidance.
Use softer language than for constraints. Words like PREFER
, IDEALLY
, SHOULD AIM TO
, CONSIDER
, or IF POSSIBLE
indicate a preference.
User: Plan a team-building event.
Constraints:
1. MUST be held on a weekday.
2. Budget MUST NOT exceed $50 per person.
Preferences:
1. PREFER outdoor activities, weather permitting.
2. IDEALLY, the location should be accessible via public transport.
3. CONSIDER activities that promote collaboration over competition.
Help the agent make trade-offs when preferences might conflict or resources are limited.
"When selecting technologies, PREFER open-source solutions over proprietary ones, unless a proprietary tool offers a significant performance advantage (at least 2x faster processing) for this specific task."
"If multiple article summaries are generated, prioritize conciseness and clarity for the executive brief."
These guide the qualitative aspects of the agent's output, distinct from strict format constraints.
"For the introductory section of the report, PREFER a narrative style that engages the reader. For the technical specifications, a more formal and itemized list is desirable."
"While a detailed plan is needed, SHOULD AIM TO present the summary in a way that a non-technical stakeholder can easily understand the main objectives and timelines."
How you structure your prompt can significantly affect the agent's ability to understand and adhere to constraints and preferences.
## Constraints
, ## Preferences
, or ## Rules of Engagement
within your prompt can improve readability for both humans and the LLM.When an agent processes a prompt containing constraints and preferences, it influences its planning process in several ways:
The following diagram illustrates how constraints and preferences progressively refine the planning process:
This diagram shows an agent's goal leading to a wide range of initial plans. Hard constraints then filter these down to a set of feasible plans. Finally, soft preferences guide the selection or refinement towards an optimal plan from within that feasible set.
Let's craft a prompt for an agent designed to plan a weekend trip, incorporating both constraints and preferences.
Goal: Plan a 2-day weekend trip from San Francisco.
Prompt:
You are a Travel Planning Agent. Your task is to create a detailed itinerary for a 2-day weekend trip originating from San Francisco.
## Task Details:
Destination: A city or national park within a 4-hour drive from San Francisco.
Travel Dates: Next weekend (assume current date is Monday, October 16th, 2023; so, the trip is for October 21-22, 2023).
Number of Travelers: 2 adults.
## Hard Constraints:
1. Total budget for the trip (accommodation, food, activities, gas/transport) MUST NOT exceed $400.
2. Accommodation MUST be a private room (e.g., hotel, Airbnb private room). No shared hostel dorms.
3. The plan MUST include at least one significant hike (minimum 2 hours).
4. Travel method MUST be by car (assume user has their own).
## Preferences:
1. PREFER destinations known for natural beauty over purely urban experiences.
2. If possible, include a visit to a local farmers' market or a unique local eatery.
3. AIM for a balance between planned activities and free time. Avoid an overly packed schedule.
4. CONSIDER destinations with good reviews for stargazing if feasible.
## Output Format:
Provide the itinerary as a day-by-day breakdown, including estimated costs for each major item, and a brief justification for destination choice based on constraints and preferences.
In this example, the agent has clear boundaries (budget, accommodation type, driving distance, mandatory hike) and guiding preferences (nature focus, local experiences, balanced schedule, stargazing) to help it generate a relevant and desirable plan.
As you build more sophisticated agentic workflows, you'll encounter more complex situations involving constraints and preferences:
Mastering the art of embedding constraints and preferences into your prompts is a significant step towards creating AI agents that not only plan but plan effectively and appropriately for the task at hand. It transforms the agent from a general-purpose planner into a tailored problem-solver that aligns with specific operational needs and desired outcomes. Remember that prompt engineering is often an iterative process; you may need to refine your constraint and preference specifications based on the agent's performance and the quality of the plans it generates.
Was this section helpful?
© 2025 ApX Machine Learning