Designing Context Injection Patterns
Quick start
Collect or infer:
- •Agent's task domain and required knowledge
- •Context sources (docs, user history, real-time data)
- •Context window limits and token budget
- •Freshness and accuracy requirements
Then produce output using TEMPLATES.md. Validate with RUBRIC.md.
Workflow
- •Inventory available context sources and their update frequencies
- •Classify context by type: static, session, query-dependent, real-time
- •Define retrieval triggers and selection criteria
- •Design context structure and ordering within the prompt
- •Specify compression and truncation strategies
- •Define fallback behavior for missing or stale context
- •Run the rubric check. Revise until it passes.
Degrees of freedom
- •Medium: Context ordering and formatting may vary based on agent type
- •Allowed variation: Specific retrieval mechanisms; chunking strategies for different content types
Failure modes to avoid
- •Context exceeds token limits, causing truncation of critical information
- •Stale context presented as current
- •Irrelevant context diluting signal
- •Missing attribution for injected content
References
- •Templates: TEMPLATES.md
- •Rubric: RUBRIC.md
- •Examples: EXAMPLES.md
- •Context types: reference/context-types.md
- •Retrieval strategies: reference/retrieval-strategies.md