Skip to main content

Chapter 2: Context and Constraints

🎯 Learning Objectives​

After completing this chapter, you will be able to:

  • Provide effective context that improves response relevance
  • Set appropriate constraints without over-restricting
  • Understand the role of context window limitations
  • Balance context depth with token efficiency

📚 Introduction​

Context transforms a generic response into a relevant one. Constraints prevent the AI from going off-track. Together, they're essential for professional-quality outputs.

The Power of Context​

Without vs. With Context​

Without Context:

Write an email about the project delay.

Result: Generic email that might not fit your situation

With Context:

Context:
- You are: Senior Project Manager at a tech startup
- Recipient: The client (CEO of a partner company)
- Relationship: Long-term client, good relationship
- Project: Mobile app development, 3-month project
- Delay reason: Key developer had medical emergency
- New timeline: 2 weeks additional
- Impact: Minor, doesn't affect their launch date
- Tone needed: Professional but warm, apologetic but confident

Write an email about the project delay.

Result: Tailored email appropriate for the specific situation

Types of Context​

1. Role Context (Who)​

Define who the AI should be:

"You are a senior financial analyst with 15 years of
experience in the retail sector..."

"You are a patient kindergarten teacher explaining
concepts to 5-year-olds..."

"You are a formal legal advisor writing for
court documentation..."

2. Audience Context (For Whom)​

Define who will receive the output:

"The audience is: C-level executives with limited
technical knowledge..."

"Write for: Software developers familiar with Python
but new to machine learning..."

"Target reader: Health-conscious millennials interested
in meal prep..."

3. Purpose Context (Why)​

Define the goal of the output:

"Purpose: To convince the board to approve
a $500K investment..."

"Goal: To educate first-time homebuyers about
the mortgage process..."

"Objective: To troubleshoot and fix a bug in
existing code..."

4. Situational Context (Background)​

Provide relevant background information:

"Background: Our company just acquired a competitor
and we need to communicate changes to employees..."

"Situation: The user has already tried restarting
the device without success..."

"History: This is the third follow-up email after
no response to previous two..."

Setting Effective Constraints​

Types of Constraints​

Constraint TypeExample
Length"Maximum 200 words"
Format"Use bullet points only"
Tone"Formal, no humor"
Vocabulary"No jargon, 8th-grade reading level"
Structure"Three paragraphs: intro, body, conclusion"
Exclusions"Do not mention competitor products"
Inclusions"Must include a call-to-action"

The Constraint Spectrum​

TOO RESTRICTIVE BALANCED TOO LOOSE
↓ ↓ ↓
"Write exactly "Write a "Write
47 words in 200-300 word something
3 sentences blog post about
with 2 examples with clear marketing"
and 1 statistic subheadings"
formatted as..."

Effective Constraint Examples​

Length Constraints:

✓ "Between 150-200 words"
✓ "Approximately 500 words (±10%)"
✓ "No more than 5 bullet points"
✓ "A single paragraph"

Format Constraints:

✓ "Format as a numbered list"
✓ "Present in a table with columns: Feature, Benefit, Example"
✓ "Use markdown headers (H2 for sections, H3 for subsections)"

Content Constraints:

✓ "Include at least 2 statistics"
✓ "Reference no sources older than 2020"
✓ "Focus only on B2B applications"
✓ "Exclude any mention of pricing"

Context Window Considerations​

What is the Context Window?​

The context window is the maximum amount of text (prompt + response) the AI can process at once.

ModelContext WindowApproximate Pages
GPT-3.54K-16K tokens6-24 pages
GPT-48K-128K tokens12-192 pages
Claude 3200K tokens~300 pages

Context Efficiency Tips​

1. Prioritize Information:

Include (high priority):
- Specific requirements
- Key constraints
- Essential background

Omit (low priority):
- Unnecessary backstory
- Redundant explanations
- Already obvious information

2. Use Summaries: Instead of:

Here are all 47 customer reviews we received last month
with full details...
[thousands of words]

Use:

Summary of 47 customer reviews from last month:
- 30 positive (key themes: speed, quality)
- 12 neutral (key themes: pricing concerns)
- 5 negative (key themes: customer service)

Now analyze this feedback and suggest improvements.

3. Reference External Documents:

Based on the company policy document I'm referencing
(key points: work from home is allowed 2 days/week,
core hours are 10am-3pm, advance notice required),
draft a response to this employee request...

Balancing Context and Constraints​

The Context Matrix​

┌─────────────────────────────────────────────────────────────┐
│ CONTEXT MATRIX │
├─────────────────────────────────────────────────────────────┤
│ │
│ HIGH CONTEXT + HIGH CONSTRAINTS │
│ → Very specific outputs (technical documentation) │
│ │
│ HIGH CONTEXT + LOW CONSTRAINTS │
│ → Creative within parameters (creative writing) │
│ │
│ LOW CONTEXT + HIGH CONSTRAINTS │
│ → Focused but generic (templates) │
│ │
│ LOW CONTEXT + LOW CONSTRAINTS │
│ → Unpredictable results (avoid) │
│ │
└─────────────────────────────────────────────────────────────┘

Finding the Right Balance​

Too Much Context:

❌ "You are a marketing professional who has been in the
industry for exactly 12 years and 3 months, specializing
in social media for B2B SaaS companies in the healthcare
vertical, specifically focusing on hospital management
software, with experience in both LinkedIn and Twitter
marketing campaigns, having previously worked at 3
Fortune 500 companies and 2 startups, one of which
was acquired, and you have an MBA from a top-10 business
school and a bachelor's in communications..."

Just Right:

✓ "You are an experienced B2B SaaS marketing professional
specializing in healthcare technology. Write for LinkedIn,
targeting hospital administrators."

Practical Templates​

Business Email Context Template​

Context:
- Sender role: [Your position]
- Recipient: [Their role/relationship]
- Company context: [Relevant background]
- Email purpose: [What you want to achieve]
- Tone: [Formal/casual/urgent]
- Constraints: [Length, what to include/exclude]

Write an email about [topic].

Content Creation Context Template​

Context:
- Content type: [Blog post/article/social media]
- Target audience: [Demographics, knowledge level]
- Platform: [Where it will be published]
- Brand voice: [Tone, style characteristics]
- Goal: [Inform/persuade/entertain]

Constraints:
- Length: [Word count]
- Format: [Headers, lists, etc.]
- Must include: [Required elements]
- Must avoid: [Restricted content]

Key Takeaways​

Summary
  1. Context transforms generic into relevant - always provide it
  2. Use four types of context: Role, Audience, Purpose, Situational
  3. Constraints prevent off-track responses but don't over-restrict
  4. Consider context window limits and prioritize information
  5. Balance is key: enough context to guide, not so much to confuse

← Previous: Clarity and Specificity | Next: Formatting and Structure →