Context Engineering

Context engineering is the discipline of designing and managing the information provided to LLMs to improve their performance. The approach focuses on optimizing the surrounding context rather than changing model weights. Three major approaches have emerged: evolving prompts via agentic loops, building enterprise context graphs, and structuring layered context for data agents.

Agentic Context Engineering (ACE)

A Stanford paper introduced Agentic Context Engineering (ACE), which treats the prompt itself as an artifact to be evolved. Instead of fine-tuning model weights, ACE has the model write, reflect on, and edit its own prompt over repeated iterations, building an evolving "playbook" of strategies.

How it works: The model executes a task, receives feedback, then edits its own context. It adds strategies that worked and removes those that didn't. Over iterations, this produces a long, detailed, self-improving prompt. The key insight is that LLMs benefit from context density, not brevity.

Results:

  • +10.6% over GPT-4-powered agents on AppWorld
  • +8.6% on finance reasoning
  • 86.9% lower cost and latency
  • No labels required, just feedback

ACE suggests that the "next generation of AI won't be fine-tuned — it'll be self-tuned." This connects to the broader auto research trend of agents improving through their own experimentation.

ACE architecture

Source: Stanford ACE paper thread by @rryssf_
Attachment: Agentic Context Engineering.pdf

Context Graphs (Glean)

Glean's approach to context engineering operates at the enterprise level, building a context graph that connects entities (people, documents, tickets) with temporal traces of actions and events.

Traditional knowledge systems model static entities. Context graphs model behavior: who did what, in which apps, in what order, with what effect. Actions become first-class nodes, and edges represent causality and correlation.

Architecture layers:

  1. Deep connectors and observability: Integration with CRM, ticketing, chat, docs, email, calendars, code, dashboards
  2. Unified knowledge graph: ML pipeline infers higher-level entities (projects, customers, products, teams) and their relationships
  3. Personal graph: Per-user activity streams stitched into semantic tasks, using LLMs to infer coherent work units
  4. Context graph: Aggregated, anonymized process patterns showing "what tends to happen" with probabilistic paths

Agent learning loop: After agents execute, their traces feed back into the graph. Offline replay scores alternative routes. Successful runs become natural language playbooks while failed runs highlight anti-patterns.

The graph and orchestration must be co-located to prevent drift. The graph evolves in sync with how agents actually operate.

Context graph process model

Context graph building layers

Source: Arvind Jain / Glean blog

Six Layers of Context (OpenAI / Dash)

OpenAI's internal data agent and the open-source Dash project demonstrate context engineering for Text-to-SQL agents. Their key finding: "context is everything — without it, even strong models hallucinate column names, miss type quirks, and ignore tribal knowledge."

The six layers:

  1. Table Usage: Schema, columns, relationships
  2. Human Annotations: Metrics, definitions, gotchas
  3. Query Patterns: SQL known to work
  4. Institutional Knowledge: External docs, research
  5. Memory: Error patterns, discovered fixes
  6. Runtime Context: Live schema when things change

This layered approach solves the statefulness problem. Most agents make mistakes, get corrected, then make the same mistake again because each session starts fresh. Persisting context across sessions lets agents compound their knowledge. See data agents for the full Dash architecture.

Source: Ashpreet Bedi / Dash

Cross-Cutting Themes

  • Context > weights: ACE, context graphs, and layered data agents all show that managing what the model sees matters more than retraining the model itself
  • Self-improvement through context: The best systems evolve their context based on feedback, whether that's ACE editing its own prompt or Glean's graph learning from agent traces
  • agentic engineering best practices makes the same argument from a practitioner perspective, emphasizing that agents perform best with the minimum necessary context

Related Topics

  • auto research - Agents improving through self-experimentation
  • data agents - Full Dash architecture and self-learning loop
  • agentic engineering best practices - Practical context management for coding agents
  • llm knowledge bases - Personal knowledge base as a form of persistent context
  • agent memory and harnesses - Memory as persistent context owned by the harness
MeProjectsWiki
AI Agents & Agentic Engineering
Context EngineeringContext EngineeringBuilding AI AgentsBuilding AI AgentsAgentic Engineering Best PracticesAgentic Engineering Best PracticesAuto-Research and Self-Improving AgentsAuto-Research and Self-Improving AgentsSelf-Maintaining AgentsSelf-Maintaining AgentsScaling Long-Running Autonomous CodingScaling Long-Running Autonomous CodingData AgentsData AgentsAgent Memory and Harness OwnershipAgent Memory and Harness Ownership
LLM Internals & Training
Reinforcement Learning for LLMsReinforcement Learning for LLMsCursor Composer 2Cursor Composer 2Training-Free GRPOTraining-Free GRPOPrompt Repetition for Non-Reasoning LLMsPrompt Repetition for Non-Reasoning LLMsLLM QuantizationLLM QuantizationLLM Knowledge BasesLLM Knowledge Bases
AI Safety & Security
Constitutional ClassifiersConstitutional ClassifiersProject GlasswingProject Glasswing
Personal Development & Mindset
Deep Focus and ProductivityDeep Focus and ProductivityIdentity and Life DesignIdentity and Life DesignSelf-Competition and EntrepreneurshipSelf-Competition and Entrepreneurship
GitHubLinkedIn