How ACE Works

Agentic Context Engineering (ACE) enables AI agents to learn from their own execution feedback. Instead of updating model weights (expensive, slow, opaque), ACE evolves a skillbook of strategies based on what actually works.

Research

ACE was introduced in Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models by researchers at Stanford University and SambaNova Systems.

The Learning Loop

Three collaborative roles share the same base LLM:

  1. The Agent executes a task using strategies from the skillbook
  2. The Environment evaluates the result (correct/incorrect, feedback)
  3. The Reflector analyzes what worked and what failed
  4. The SkillManager updates the skillbook with new strategies

The Skillbook accumulates strategies across runs, making every subsequent agent call smarter.

Three Roles

RoleResponsibilityKey Class
AgentExecutes tasks using skillbook strategiesAgent
ReflectorAnalyzes execution results (what worked, what failed)Reflector
SkillManagerTransforms reflections into skillbook updatesSkillManager

All three roles use the same LLM — the intelligence comes from the specialized prompts each role receives.

See Three Roles for details on each role's inputs and outputs.

Two Architecture Patterns

Full ACE Pipeline

Use when building a new agent from scratch.

All three roles participate. The Agent produces answers, the Environment evaluates them, and the learning pipeline updates the skillbook.

from ace import ACE, Agent, Reflector, SkillManager, SimpleEnvironment

runner = ACE.from_roles(
    agent=Agent("gpt-4o-mini"),
    reflector=Reflector("gpt-4o-mini"),
    skill_manager=SkillManager("gpt-4o-mini"),
    environment=SimpleEnvironment(),
)
results = runner.run(samples, epochs=3)

Integration Pattern

Use when wrapping an existing agent (browser-use, LangChain, Claude Code).

No ACE Agent — the external framework handles execution. ACE only learns from the results.

Three steps: INJECT skillbook context, EXECUTE with external agent, LEARN from results.

from ace import BrowserUse

runner = BrowserUse.from_model(
    browser_llm=ChatOpenAI(model="gpt-4o"),
    ace_model="gpt-4o-mini",
)
results = runner.run("Find the top post on Hacker News")

See Integration Pattern for building custom integrations.

How It Compares

ApproachUpdatesSpeedInterpretability
Fine-tuningModel weightsSlow (hours)Low (opaque)
RAGExternal documentsMediumMedium
ACESkillbook contextFast (real-time)High (readable strategies)

ACE strategies are human-readable, auditable, and transferable between models.

Performance

BenchmarkImprovementNotes
AppWorld Agent+17.1 ppComplex multi-step tasks with tool use
FiNER (Finance)+8.6 ppFinancial reasoning tasks
Adaptation Latency-86.9%vs. existing context-adaptation methods

What to Read Next