AI Dictionary of Terms

Context Engineering

The discipline of designing and optimizing the complete context provided to large language models — including prompts, retrieved information, tools, memory, and system instructions — to elicit desired behaviors and outputs, representing an evolution beyond prompt engineering to encompass the entire informational environment.

The Simple Version

Imagine you’re hiring a brilliant assistant for a day. Prompt engineering is like writing a good job description — you tell them what to do. But context engineering is everything else: giving them access to the right files, introducing them to the right people, setting up their workspace, providing the tools they need, and creating an environment where they can succeed.

Context engineering recognizes that an AI’s performance depends not just on the prompt, but on the entire informational environment: what documents it can access, what tools it can use, what it remembers from previous interactions, what system instructions guide its behavior, and how all these pieces fit together.

It’s the difference between asking someone a question and creating the conditions for them to give you the best possible answer.

Detailed Explanation

Context engineering emerged in 2025 as practitioners realized that prompt engineering — while important — was too narrow. The quality of AI outputs depends on the entire context, not just the user’s prompt.

The Context Stack: Modern LLM applications assemble context from multiple sources:

  1. System Instructions: Base behavior, persona, constraints
  2. Retrieved Knowledge: Documents from RAG, databases, APIs
  3. Conversation History: Previous messages in the session
  4. User Memory: Long-term information about the user
  5. Tool Definitions: Available functions the model can call
  6. Few-Shot Examples: Demonstrations of desired behavior
  7. User Prompt: The actual question or request

Context Engineering vs. Prompt Engineering:

Aspect Prompt Engineering Context Engineering
Scope The user’s prompt The entire informational environment
Focus Wording and structure Assembly and orchestration
Components Instructions, examples Prompts + RAG + tools + memory + system
Goal Clear instructions Optimal conditions for success
Analogy Writing a good question Setting up the right environment

Key Techniques:

1. Context Assembly

2. Tool Integration

3. Memory Management

4. Retrieval Optimization

5. Context Pruning

6. Multi-Turn Orchestration

Why It Matters:

Key Characteristics

Business Context

Context engineering is becoming a core competency for enterprise AI teams:

Why it matters:

Enterprise Applications:

Organizational Impact:

ROI of Context Engineering:

Real-World Analogy

A chef preparing a meal. Prompt engineering is the recipe (what to make). Context engineering is everything else: sourcing the best ingredients, having the right tools, knowing your guests’ preferences, managing the kitchen workflow, and creating the conditions for a great meal. The recipe matters, but the context determines whether the meal is mediocre or exceptional.

Code Example

# Context engineering for a customer support assistant
from typing import List, Dict
import openai

def assemble_context(user_query: str, customer_id: str) -> List[Dict]:
    """
    Assemble the complete context for a customer support query
    """
    context = []
    
    # 1. System instructions (base behavior)
    context.append({
        "role": "system",
        "content": """You are a helpful customer support assistant for TechCorp.
        Be empathetic, concise, and solution-oriented.
        Always verify customer identity before discussing account details."""
    })
    
    # 2. Retrieved knowledge (RAG)
    relevant_articles = search_knowledge_base(user_query, top_k=3)
    if relevant_articles:
        kb_context = "\n\n".join([f"Article {i+1}: {a['content']}" 
                                   for i, a in enumerate(relevant_articles)])
        context.append({
            "role": "system",
            "content": f"Relevant knowledge base articles:\n{kb_context}"
        })
    
    # 3. Customer history (memory)
    customer_info = get_customer_info(customer_id)
    recent_tickets = get_recent_tickets(customer_id, limit=5)
    
    customer_context = f"""
    Customer: {customer_info['name']} ({customer_info['tier']} tier)
    Account age: {customer_info['account_age_days']} days
    Recent issues: {', '.join([t['summary'] for t in recent_tickets])}
    """
    context.append({
        "role": "system",
        "content": f"Customer context:{customer_context}"
    })
    
    # 4. Available tools
    tools = [
        {"type": "function", "function": {"name": "reset_password", ...}},
        {"type": "function", "function": {"name": "check_order_status", ...}},
        {"type": "function", "function": {"name": "escalate_to_human", ...}}
    ]
    
    # 5. Conversation history
    conversation_history = get_conversation_history(customer_id)
    context.extend(conversation_history)
    
    # 6. User's current query
    context.append({
        "role": "user",
        "content": user_query
    })
    
    return context, tools

# Usage
context, tools = assemble_context(
    user_query="I can't log into my account",
    customer_id="cust_12345"
)

response = openai.chat.completions.create(
    model="gpt-4",
    messages=context,
    tools=tools
)

Common Misconceptions

Sources & Further Reading