# Context-Optimization Strategy Menu
<!--
ref: @knowledge/frameworks/context-optimization-strategy-menu
type: framework
tags: [context management, agent optimization, strategy, AI, workflow]
triggers: [large messy codebase, context degradation, need for efficient retrieval, high upfront processing]
trigger_prompt: When faced with a large or disorganized corpus, and needing to optimize how an agent processes context without sacrificing quality.
version: 2
updated_at: 2026-07-18T22:56:16.600Z
-->

Five ways to feed an agent the right context instead of dumping everything, each with a distinct cost/effort tradeoff: context engine, hierarchical summarization, knowledge graph, iterative retrieval, and self-correction.

*Synthesized from Nupur Sharma, Why More Context Makes Your Agent Dumber (AI Engineer World's Fair 2026).*

**When to apply.** Choosing a context-management approach for an agent over a large or messy corpus, once you accept that stuffing the whole thing in degrades quality.

**The five options.**
1. Context engine (search + ranking that acts as a "bouncer" deciding what is important): good for large messy codebases; indexing is moderate effort, but scaling degrades badly around 600-700 repos where mapping/indexing slows and becomes unpredictable.
2. Hierarchical summarization (a summary per file and folder the agent scans before diving): reduces what the agent must read, but incurs high upfront LLM processing on every file creation/change.
3. Knowledge graph (a graph DB of logical dependencies, e.g. file impacts file impacts file): works wonders for complex logic and multi-repo dependencies; high initial developer input to build.
4. Iterative retrieval (an index like a "library card" — the agent looks up a topic and decides whether to read deeper): low developer input, good results, and the author's pick for internal/non-product agents; still carries per-call cost.
5. Self-correction (a critic node checks each result against the original goal and triggers a retry if context was lost): low upfront input; adds latency from the extra agent pass.

**Gotcha.** No option is free — the axes are upfront build effort, per-call cost, and scaling ceiling. Match the choice to whether you are building a product (justifies a context engine / knowledge graph) or internal tooling (iterative retrieval often wins on effort-to-value).

---

*Related: `@protocol/ratchet` · `@content/youtube/yifan-bth/how-to-prompt-cursor-windsurf-copilot-to-get-reliable-output` · `@content/youtube/yifan-bth/windsurf-vs-cursor-in-depth-ai-code-editor-comparison` · `@content/youtube/yifan-bth/the-complete-claude-code-workflow-90-skip-this` · `@content/youtube/wes-mcdowell/how-to-use-chatgpt-for-content-creation-itll-sound-like-you`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*