Notes on Context Engineering
Notes on Anthropic's Context Engineering Blog post¶
Image taken from Anthropic article
-
Why is context engineering relevant? Due to context rot, which is the process where as the context of a model increases, its ability to recall information from that context decreases
- Models are also more used to shorter sequences, meaning less experience with context wide dependencies
-
Great quote defining the goal of context engineering:
good context engineering means finding the smallest possible set of high-signal tokens that maximize the likelihood of some desired outcome.
-
Organize prompts with sections (using XML or markdown headers)
minimal set of information that fully outlines your expected behavior.
-
Start with minimal and improve instructions based on failure modes
-
"Just-in-time" context strategies means dynamically loading what the agent needs when it needs it
-
Hybrid strategies with agents (like using
CLAUDE.mdfiles for Claude Code) represent this acknowledgement that as agents become more intelligent they will require less human curation over time so the advice Anthropic gives is: -
Techniques to address context polution constraints for long horizon tasks:
-
structured note-taking: agents writes external notes for later retrieval on demand
- For example a todo list for keeping track of progress, having a
NOTES.mdfile for maintaining critical context - They exemplify this with an example of Claude playing pokemon
- They built a memory tool with the Sonnet 4.5 launch
- For example a todo list for keeping track of progress, having a
-
sub-agent architectures:
- involves using specialized sub-agents with clean focused tasks and a clean context window
- ideal for complex research tasks
- When to use each strategy:
- Compaction for extensive back-and-forth conversational tasks
- note-taking for iterative development with clear milestones
- multi-agent architectures for complex research and analysis where parallel exploration pays dividends
Agentic Loops¶
-
New skill to develop: designing agentic loops
-
Yolo mode (running coding agents with automatic approval)
- Risks:
- bad shell commands deleting or maing stuff
- exfiltration attacks
- attacks that use your machine as a proxy to attack another target
- options
- Run your agent in a secure sandbox
- acceptable options for most
- https://github.com/apple/container
- Docker
- But remember this is not perfect! (container escapes)
- Use someone else's computer
- Just risk it! (avoid expositing it to potentially palicious sources)
- Best option for Simon: Github Codespaces
- Set credentials with tight budget limit on staging environments to contain any potential damage then design a cool agentic loop like this for testing, exploring, prototyping...
- Examples of scenarios for agentic loops: debugging, performance optimization, upgrading dependencies, optimizing container sizes.
-
Automated tests!