Menu
InfoQ Architecture·August 14, 2026

Context Engineering for LLM-Powered Agents and Architectures

This article explores the architectural challenges and solutions for building reliable AI agents by addressing the 'stuffed prompt' antipattern. It introduces context engineering principles like lazy-loaded skills and externalized memory banks to optimize LLM context windows, enhancing agent performance and reducing operational costs. The discussion highlights how to manage and version contextual artifacts for robust, scalable AI workflows.

Read original on InfoQ Architecture

The Challenge of Stuffed Prompts in LLM Agents

When building AI agents, a common anti-pattern is the 'stuffed prompt,' where too much information (code, documentation, chat history) is indiscriminately fed into the Large Language Model's (LLM) context window. This often leads to several problems: context window overflow, where the LLM loses relevant information due to length limits; conflicting instructions, where redundant or outdated data leads to incorrect agent behavior (e.g., a coding agent introducing errors); and increased inference costs due to processing larger inputs. The article emphasizes that LLMs, by default, often operate stateless, sending the entire conversation history with each new query, quickly exhausting context limits.

Architectural Solutions: Context Engineering Principles

To counter the stuffed prompt issue, the authors propose Context Engineering, which focuses on intelligent management and delivery of contextual information to LLMs. Key architectural solutions discussed include:

  • Lazy-Loaded Skills: Instead of pre-loading all possible context, skills (modular pieces of knowledge or instructions) are loaded only when relevant to the agent's current task. A descriptive activation criteria helps the agent dynamically determine which skills to inject into the prompt.
  • Versioned Context Artifacts: Treating context (like markdown files for skills) as first-class artifacts, similar to code, allows for version control (e.g., Git) and proper artifact management systems (like JFrog Artifactory). This ensures consistency, auditability, and prevents 'garbage in, garbage out' scenarios with outdated or conflicting instructions.
  • Externalized Memory Banks: For persistent knowledge beyond a single session, externalized memory banks can store long-term context that agents can query. This prevents re-sending large documents repeatedly and keeps the immediate context window focused.
  • LLM-as-a-Judge Evaluations: Using an LLM to evaluate the effectiveness of prompt responses and context delivery helps refine skill descriptions and context engineering strategies, ensuring that the 'right 300 tokens beat 100k noisy ones'.

Managing Skills and Preventing Conflicts

While lazy-loaded skills solve the initial stuffed prompt problem, new challenges arise. Agents can still accumulate context over a long session, necessitating session management (e.g., starting new sessions) or delegation to sub-agents with clean contexts. Furthermore, conflicting skill descriptions can lead to incorrect skill activation. Proper version control and testing for skills are crucial, treating them not just as text files but as critical components of the agent's architecture, requiring maintenance and quality assurance similar to any other software artifact.

💡

System Design Implication

Designing LLM-powered systems requires a shift from traditional monolithic context handling to a more modular, dynamic, and version-controlled approach. This impacts data pipelines for context ingestion, runtime architecture for skill loading, and evaluation frameworks for agent performance.

LLMAI AgentContext WindowPrompt EngineeringContext EngineeringSystem DesignSoftware ArchitectureAI Architecture

Comments

Loading comments...