Skip to content

context engineering

Context engineering is the systematic design, curation, and ongoing maintenance of all the information given to a model at inference time so it can respond reliably, not just for a single call but across the many turns of an agent loop, where the context state has to be managed as it grows. This includes prompts, retrieved documents or memory, tool outputs, metadata, policies, and session state.

Context engineering is the natural progression of prompt engineering rather than a rival to it. Where prompt engineering focuses on writing and organizing instructions, context engineering manages the full context state that occupies the model’s context window.

Typical parts include retrieval and selection of content, chunking and ranking, schema-based formatting, grounding and citations, session history, and integration of tool and API outputs. Long-running agents add context-management techniques on top: compaction summarizes a conversation nearing the context limit and restarts from that summary, structured note-taking persists memory outside the context window, and sub-agent architectures isolate focused subtasks in their own clean context windows.

A person in a green coat drops a document into a cabinet labeled CONTEXT WINDOW, beside a token-budget gauge, a Python logo, and a checklist on a tripod.

Tutorial

Context Engineering for Python Codebases

Learn how context engineering shapes what your AI coding agent sees on every turn, and use four practical strategies to keep your Python projects on track.

intermediate ai best-practices tools

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Aug. 27, 2026 • Reviewed by Martin Breuss