Skip to content
LinkedInX

Context Engineering

About 5 minutes

Prerequisites: Basic understanding of Prompt Engineering

Context engineering is the practice of selecting, organizing, and providing the background information generative AI needs to do useful work. OpenAI’s API documentation describes model inputs as including developer instructions, user messages, tools, and other context that shape model output.[1] If prompt engineering designs the instruction, context engineering designs the working document set.

Context is the information available to the AI when it creates an answer.

Examples:

  • User instructions
  • Conversation history
  • Document text
  • Code files
  • Error logs
  • Design policies
  • Output formats
  • Safety rules and prohibitions

Humans also need more than a request. They need history, related documents, current constraints, and completion criteria. AI needs the same kind of working context.

ViewpointPromptContext
Main roleTell the AI what to doProvide judgment material
Example”Summarize this” or “Compare these”Meeting notes, specs, past logs
Design focusClarity of instructionSelection and organization of information
Failure modeVague instructionMissing information or too much noise

Even a good prompt leads to guessing when context is missing. On the other hand, dumping too much material can bury the important parts.

Passing an entire long document is not always best. Selecting the task-relevant parts can work better. A large context window helps, but important information can still be missed when surrounded by noise.

Not all context has the same weight. Mandatory rules, reference notes, and past discussion have different importance.

Priority:
1. Security requirements
2. Current specification
3. Existing code style
4. Past discussion notes

Priority helps the AI decide what to follow when information conflicts.

When providing documents, keep track of where each piece of information came from: which file, date, or statement.

References:
- product-spec.md: current official specification
- meeting-2026-05-01.md: undecided discussion notes
- error.log: latest failure log

This makes verification easier.

Old specifications, fixed bugs, and outdated hypotheses can lead to wrong assumptions. In long tasks, separate current facts from historical notes.

Fix this error.

Without the error message, command, environment, and related code, the AI can only answer generally.

Read the whole repository and fix it nicely.

The scope is too wide. Target files, reproduction steps, and expected behavior make the task more stable.

One spec says "use A" while a note says "A is prohibited."

When context conflicts, the priority rule must be explicit.

RAG (Retrieval-Augmented Generation) retrieves related information from external documents or databases and provides it to the AI before answering.

RAG is part of context engineering, but context engineering is broader. It includes retrieval, prioritization, summarization, history management, and constraint design.

Context engineering designs what the AI sees. Harness engineering also designs what the AI can do, how results are checked, and what happens after failure.

For code changes, context may include the specification, related files, and error logs. The harness adds test execution, diff review, permission control, and review steps. Practical work needs both.

  • Context engineering designs the background information given to AI
  • It organizes documents, history, constraints, and priority, not just instructions
  • Missing, excessive, or contradictory context reduces answer quality
  • RAG is one part of context engineering
  • The next step is harness engineering, which includes tools and verification

Q: Is context organization unnecessary with a large context window?

A: No. The Transformer made long-context sequence processing a core part of modern language models, but important details can still be missed if they are not organized clearly.[2]

Q: Does adding RAG complete context design?

A: No. RAG retrieves related information, but priority, source-of-truth rules, and verification still need design.

Q: Should all conversation history be kept?

A: Not always. Keeping a summary of current decisions, unresolved issues, and constraints is often more stable.

  1. OpenAI, OpenAI API documentation
  2. Ashish Vaswani et al., Attention Is All You Need, June 12, 2017