Enable language models to improve via context adaptation rather than weight updates. Use ACE (Agentic Context Engineering) to treat contexts as evolving playbooks that accumulate, refine, and organize strategies through modular generation, reflection, and curation processes. Achieve +10.6% agent benchmark gains and +8.6% on finance tasks using small open-source models matching production-level performance.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Enable language models to improve via context adaptation rather than weight updates. Use ACE (Agentic Context Engineering) to treat contexts as evolving playbooks that accumulate, refine, and organize strategies through modular generation, reflection, and curation processes. Achieve +10.6% agent benchmark gains and +8.6% on finance tasks using small open-source models matching production-level performance.
Agentic Context Engineering: Evolving Contexts
Core Concept
Context optimization approaches suffer from brevity bias (eliminating domain insights) and context collapse (iterative rewrites eroding details). ACE treats contexts as evolving playbooks maintained through modular processes of generation, reflection, and curation. Contexts accumulate task-relevant strategies without size explosion, enabling self-improvement without weight updates.
Architecture Overview
Modular Context Evolution: Separate generation (create strategies), reflection (evaluate effectiveness), and curation (organize playbook)
Dynamic Memory: Evolving system prompts and agent memories that grow and refine through interactions
Incremental Updates: Strategic additions to context preserve previous insights while adding new ones
No Labeled Supervision: Learn directly from natural execution feedback
Scalability with Long Context: Leverage long-context models (128K tokens) for rich playbooks
Implementation Steps
1. Context Generation and Reflection
Iteratively generate strategies and reflect on their effectiveness.
classAgenticContextEvolver:
def__init__(self, model='gpt-4.1', context_window_size=32000):
self.model = model
self.context_window = context_window_size
self.playbook = {} # Dict of strategiesdefgenerate_strategy(self, task_description, execution_history):
"""
Generate new strategy based on task and prior execution.
"""
prompt = f"""Task: {task_description}
Execution history (recent failures/successes):
{execution_history[-500:]} # Recent context window
Based on the task and execution history, generate a new strategy:
- Clear objective
- Key steps
- Success criteria
- Failure recovery
Strategy:"""
strategy = self.model.generate(prompt, max_tokens=)
strategy
():
prompt =
reflection = .model.generate(prompt, max_tokens=)
reflection
():
prompt =
curated = .model.generate(prompt, max_tokens=context_size_limit)
curated
():
current_context =
iteration (iterations):
()
strategy = .generate_strategy(task_description, execution_log)
()
test_results = .test_strategy(strategy, task_description)
reflection = .reflect_on_effectiveness(strategy, test_results)
()
.playbook[] = {
: strategy,
: reflection,
: test_results[]
}
strategies_list = [s[] s .playbook.values()]
reflections_list = [s[] s .playbook.values()]
current_context = .curate_context(
strategies_list,
reflections_list,
context_size_limit=
)
execution_log +=
current_context, .playbook
():
result = .model.generate(
,
max_tokens=
)
{
: result,
: result.lower() result.lower(),
:
}
f"""Strategy being tested:
{strategy}
Execution results:
Success: {execution_results['success']}
Outcome: {execution_results['outcome']}
Time taken: {execution_results['duration']}
Reflection questions:
1. Did the strategy succeed? Why/why not?
2. What worked well?
3. What could be improved?
4. Should we refine, keep, or discard this strategy?
Reflection:"""
"""
Organize strategies into concise, useful playbook.
Remove redundant or ineffective strategies.
"""
f"""Current strategies and reflections:
{chr(10).join([f'Strategy: {s}\nReflection: {r}'for s, r inzip(strategies, reflections)])}
Organize these into a concise playbook:
1. Group related strategies
2. Remove duplicates
3. Keep highest-value strategies
4. Create decision tree for which strategy to use when
5. Total token budget: {context_size_limit} tokens
Curated playbook:"""
Context Size Management: Monitor context token count; curate regularly to avoid explosion. 8K-16K tokens sufficient for most playbooks.
Reflection Quality: Use capable model for reflection (GPT-4.1) even if base agent is smaller. Reflection drives improvement.
Update Frequency: Update context every 10-50 episodes. More frequent updates add overhead; less frequent miss improvement opportunities.
Strategy Diversity: Keep diverse strategies even if some work better. Diversity handles task distribution shifts.
When to Use / When NOT to Use
Use When:
Long-running agents that adapt to task distributions
You want to improve without retraining
Rich context representations are feasible (long context models)
Continuous improvement is important
NOT For:
One-off inference without feedback loops
Severely compute-constrained environments
Tasks requiring guaranteed, unchanged behavior
Reference
This skill synthesizes findings from "Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models" (arXiv:2510.04618). Context as playbook enables adaptation without weights.