Context Engineering for Agentic Systems
Prompt engineering got all the attention first.
Context engineering is what matters when the agent touches real work.
An agent does not need every document, every Slack thread, every ticket, and every log line. It needs the right context, at the right time, with the right permissions, in the right shape.
That is an architecture problem.
Context is not just retrieval#
Context can come from:
- User input.
- Workflow state.
- Tool results.
- Docs.
- Tickets.
- Code.
- Logs.
- Traces.
- Metrics.
- Memory.
- Policies.
- Prior approvals.
Treat these as separate sources with different trust levels.
Freshness matters#
Old docs can be worse than no docs.
Every context source needs a freshness story:
- When was it updated?
- Is it authoritative?
- Does live system state override it?
- Should stale data be labeled?
- Should the agent ask for confirmation?
A runbook from six months ago should not outrank a failing trace from five minutes ago.
Scope context before retrieval#
Do not retrieve first and filter later.
Scope by:
- User permissions.
- Workspace.
- Customer.
- Service.
- Repository.
- Incident.
- Data classification.
- Time window.
This keeps context engineering tied to security.
Compress without erasing evidence#
Long context is tempting. It is also expensive and noisy.
Use compression carefully:
- Keep source links.
- Preserve timestamps.
- Preserve uncertainty.
- Preserve approval status.
- Preserve conflicting evidence.
Bad summaries create confident agents with missing facts.
Context changes tool use#
The context layer should help the agent decide what to do next:
- Enough evidence to answer.
- Need another tool call.
- Need approval.
- Need a stronger model.
- Need to stop.
That is why context engineering belongs in the workflow, not just the retrieval backend.
Build it in Codelit#
Try this:
Design context engineering for an agentic internal support system. Include source routing, scoped retrieval, freshness, memory, tool results, compression, citations, approval-aware context, and evals.
Better prompts help. Better context changes the system.
Try these templates
Netflix Video Streaming Architecture
Global video streaming platform with adaptive bitrate, CDN distribution, and recommendation engine.
10 componentsCloud File Storage Platform
Dropbox-like file storage with sync, sharing, versioning, and real-time collaboration.
8 componentsSearch Engine Architecture
Web-scale search with crawling, indexing, ranking, and sub-second query serving.
8 componentsContinue learning
Go deeper on AI agents and LLM systems
As an Amazon Associate I earn from qualifying purchases. Codelit may receive a commission at no extra cost to you.
From Prompt to Proof
How to Use AI to Think Clearly, Finish Real Work, and Verify What Matters
A proof-first method for turning AI output into finished work with evidence, judgment, and clear stopping rules.
View on AmazonThis book is written by Codelit founder Mo Sharif. Its Amazon link is a paid affiliate link.
AI Engineering
Chip Huyen · 2025
Book-length treatment of evals, prompts and deployment tradeoffs for foundation-model apps.
LLMOps
Abi Aryan · 2025
What running LLMs in production costs you: monitoring, governance, drift and compute budgets.
3.8 (10)Kindle editionPrompt Engineering for LLMs
John Berryman, Albert Ziegler · 2024
How context assembly actually works, from two engineers who built GitHub Copilot's prompts.
4.0 (63)