# Context pinning

**Source:** https://promtable.com/glossary/context-pinning

> Context pinning explicitly keeps critical pieces of information at the head or tail of an agent's prompt across many turns — defending against the lost-in-the-middle recall problem on long contexts.

---
Context pinning explicitly keeps critical pieces of information at the head or tail of an agent's prompt across many turns — defending against the lost-in-the-middle recall problem on long contexts.

Models recall information at the head and tail of long contexts much better than in the middle. Context pinning is the production discipline of explicitly anchoring critical content at those positions. Implementations: a fixed "system + critical state" block always at the head; an "open subtasks + recent decisions" summary always near the tail. Used across long agent loops, multi-turn assistants, and RAG over long documents. Best practice in 2026 is to refresh the pinned content during conversation compaction so it stays accurate.

## When to use

- Long agent loops with critical state.
- Multi-turn assistants with returning users.
- RAG over long documents with task-relevant constants.

## Common mistakes

- Pinning too much — context bloat defeats the purpose.
- Letting pinned content drift out of sync with current state.

## Related terms

- [long-context-prompting](https://promtable.com/glossary/long-context-prompting)
- [context-distillation](https://promtable.com/glossary/context-distillation)
- [compaction](https://promtable.com/glossary/compaction)
- [system-message](https://promtable.com/glossary/system-message)

*Last updated: 2026-06-01*
---

Original page: https://promtable.com/glossary/context-pinning
Maintained by Promtable (https://promtable.com). Content: CC BY 4.0. Cite as "Promtable — https://promtable.com/glossary/context-pinning".
Contact: info@vibecodingturkey.com.