MCPInstall

agentic-context-engine

Add persistent learning and self-improvement to AI agents using ACE framework

Installs
157
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/reason-machines/ai-agent-skills --skill agentic-context-engine
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads agentic-context-engine automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Agentic Context Engine (ACE)

Skill by ara.so — AI Agent Skills collection.

ACE is a framework that adds persistent learning capabilities to AI agents. Unlike traditional agents that forget everything between sessions, ACE maintains a Skillbook — a living collection of strategies extracted from execution traces. The framework uses a Recursive Reflector that writes and executes Python code to analyze traces and extract actionable patterns.

Installation

# Basic installation
uv add ace-framework

# With optional integrations
uv add 'ace-framework[browser-use]'    # Browser automation
uv add 'ace-framework[langchain]'      # LangChain integration
uv add 'ace-framework[logfire]'        # Observability
uv add 'ace-framework[mcp]'            # MCP server for IDE
uv add 'ace-framework[deduplication]'  # Embedding-based deduplication

Configuration

Interactive setup (recommended):

ace setup

Or set environment variables manually:

export OPENAI_API_KEY="your-key-here"
# OR
export ANTHROPIC_API_KEY="your-key-here"
# Supports 100+ providers via LiteLLM

Core Concepts

Skillbook: Persistent collection of learned strategies
Agent: Executes tasks enhanced with Skillbook strategies
Reflector: Analyzes execution traces to extract insights
SkillManager: Curates the Skillbook (adds, refines, removes strategies)

Quick Start: LiteLLM Runner

The simplest way to add learning to any LLM:

from ace import ACELiteLLM

# Initialize with any LiteLLM model
agent = ACELiteLLM(model="gpt-4o-mini")

# First attempt - may hallucinate
answer = agent.ask("Is there a seahorse emoji?")
print(answer)  # May incorrectly say yes

# Provide corrective feedback
agent.learn_from_feedback("There is no seahorse emoji in Unicode.")

# Second attempt - benefits from learned strategy
answer = agent.ask("Is there a seahorse emoji?")
print(answer)  # Now correctly says no

# Inspect what was learned
strategies = agent.get_strategies()
for strategy in strategies:
    print(f"Strategy: {strategy.name}")
    print(f"Content: {strategy.content}")

# Save skillbook for later
agent.save("my_skillbook.json")

# Load skillbook in new session
agent = ACELiteLLM(model="gpt-4o-mini", skillbook_path="my_skillbook.json")

Learning from Existing Traces

Extract strategies from pre-recorded execution traces:

from ace import ACELiteLLM

agent = ACELiteLLM(model="gpt-4o-mini")

# Your existing traces (list of conversation histories)
traces = [
    [
        {"role": "user", "content": "What's 2+2?"},
        {"role": "assistant", "content": "4"},
    ],
    [
        {"role": "user", "content": "What's 3+3?"},
        {"role": "assistant", "content": "The answer is 6"},
    ]
]

# Learn from traces without re-running tasks
agent.learn_from_traces(traces)

# View extracted strategies
print(agent.get_strategies())

Core Runner: Full Learning Loop

For complete control with batch epochs and evaluation:

from ace import ACE, Skillbook
from pydantic_ai.models.openai import OpenAIModel

# Create skillbook and agent
skillbook = Skillbook()
ace = ACE(
    model=OpenAIModel("gpt-4o-mini"),
    skillbook=skillbook,
    environment=your_env,  # Custom environment
    max_attempts=3
)

# Define your task
async def my_task():
    return "What is the capital of France?"

# Run learning epoch
result = await ace.run_epoch(
    task=my_task,
    task_id="geography_001",
    num_iterations=5
)

print(f"Success rate: {result.success_rate}")
print(f"Strategies learned: {len(skillbook.get_all_strategies())}")

Custom Agent Integration

Wrap your existing agent with ACE learning:

from ace import ACE, Skillbook
from pydantic_ai import Agent

# Your existing PydanticAI agent
my_agent = Agent(
    model="openai:gpt-4o",
    system_prompt="You are a helpful assistant."
)

# Wrap with ACE
skillbook = Skillbook()
ace_agent = ACE(
    agent=my_agent,
    skillbook=skillbook,
    environment=your_env
)

# Agent now learns from execution
result = await ace_agent.run_epoch(task=your_task)

Browser Automation with Learning

ACE integrates with browser-use for self-improving browser automation:

from ace.runners.browser_use import BrowserUse
from browser_use import Agent as BrowserAgent

# Create browser agent with learning
browser_ace = BrowserUse(
    agent=BrowserAgent(
        task="Find flights from NYC to LAX",
        llm=your_llm
    ),
    skillbook_path="browser_skills.json"
)

# Run with learning enabled
result = await browser_ace.run()

# Each run improves the agent
# Strategies are saved to browser_skills.json

LangChain Integration

Add learning to any LangChain chain or agent:

from ace.runners.langchain import LangChain
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate

# Your existing LangChain setup
prompt = PromptTemplate.from_template("Translate {text} to {language}")
chain = LLMChain(llm=your_llm, prompt=prompt)

# Wrap with ACE
ace_chain = LangChain(
    chain=chain,
    skillbook_path="translation_skills.json"
)

# Run with learning
result = await ace_chain.run(
    text="Hello world",
    language="Spanish"
)

Trace Analysis

Analyze traces without re-running tasks:

from ace.runners.trace_analyser import TraceAnalyser

analyzer = TraceAnalyser(
    model="gpt-4o-mini",
    skillbook_path="analyzed_skills.json"
)

# Analyze a batch of traces
traces = load_your_traces()  # List of execution traces
strategies = await analyzer.analyze(traces)

print(f"Extracted {len(strategies)} strategies")
for s in strategies:
    print(f"- {s.name}: {s.content}")

CLI Commands

# Interactive setup
ace setup

# Search available models
ace models gpt
ace models --provider anthropic

# Validate model connection
ace validate gpt-4o-mini
ace validate claude-3-5-sonnet-20241022

# Show configuration
ace config

# Hosted API (requires account at kayba.ai)
kayba login
kayba upload-traces traces.json
kayba fetch-insights
kayba install-prompt my-skill

Custom Pipeline

Build custom learning pipelines with composable steps:

from ace import Pipeline, AgentStep, EvaluateStep, learning_tail
from ace.core.reflector import Reflector
from ace.core.skill_manager import SkillManager

# Create pipeline components
agent_step = AgentStep(agent, skillbook)
eval_step = EvaluateStep(environment)

# Add standard learning tail (reflect + update + deduplicate)
reflector = Reflector(model="gpt-4o")
skill_manager = SkillManager(model="gpt-4o")

steps = [
    agent_step,
    eval_step
] + learning_tail(reflector, skill_manager, skillbook)

# Create and run pipeline
pipeline = Pipeline(steps)
context = await pipeline.run({"task": your_task})

print(context.get("strategies_learned"))

Configuration Options

Model Selection

ACE supports 100+ providers via LiteLLM:

# OpenAI
ACELiteLLM(model="gpt-4o-mini")
ACELiteLLM(model="gpt-4o")

# Anthropic
ACELiteLLM(model="claude-3-5-sonnet-20241022")
ACELiteLLM(model="claude-3-5-haiku-20241022")

# Google
ACELiteLLM(model="gemini/gemini-2.0-flash-exp")

# Local models
ACELiteLLM(model="ollama/llama3")

# Any LiteLLM supported model
ACELiteLLM(model="bedrock/anthropic.claude-v2")

Skillbook Persistence

# Save skillbook
agent.save("path/to/skillbook.json")

# Load skillbook
agent = ACELiteLLM(
    model="gpt-4o-mini",
    skillbook_path="path/to/skillbook.json"
)

# Programmatic access
skillbook = Skillbook()
skillbook.load_from_file("skillbook.json")
strategies = skillbook.get_all_strategies()
skillbook.add_strategy(new_strategy)
skillbook.save_to_file("updated.json")

Common Patterns

Pattern 1: Iterative Improvement

from ace import ACELiteLLM

agent = ACELiteLLM(model="gpt-4o-mini")

# Run task multiple times with feedback
for attempt in range(5):
    result = agent.ask("Complex reasoning task")
    
    # Provide feedback on errors
    if not validate(result):
        agent.learn_from_feedback(f"Error: {get_error(result)}")
    
    print(f"Attempt {attempt + 1}: {result}")

# Save learned strategies
agent.save("improved_agent.json")

Pattern 2: Multi-Task Learning

from ace import ACELiteLLM

agent = ACELiteLLM(model="gpt-4o-mini")

tasks = [
    "Task 1: Data analysis",
    "Task 2: Code generation", 
    "Task 3: Writing"
]

for task in tasks:
    result = agent.ask(task)
    # Agent accumulates strategies across tasks
    
# Single skillbook learns from diverse tasks
agent.save("multi_task_skills.json")

Pattern 3: Batch Trace Analysis

from ace import TraceAnalyser

# Load historical traces
traces = load_traces_from_database()

analyzer = TraceAnalyser(model="gpt-4o")

# Extract all strategies at once
strategies = await analyzer.analyze(traces)

# Use in new agent
agent = ACELiteLLM(
    model="gpt-4o-mini",
    skillbook=analyzer.skillbook
)

Troubleshooting

API Key Issues

# Verify configuration
import subprocess
result = subprocess.run(["ace", "config"], capture_output=True, text=True)
print(result.stdout)

# Test connection
subprocess.run(["ace", "validate", "gpt-4o-mini"])

Empty Skillbook

If no strategies are learned:

# Check if reflector is enabled
agent = ACELiteLLM(
    model="gpt-4o-mini",
    enable_reflection=True  # Ensure this is True
)

# Provide explicit feedback
agent.learn_from_feedback("Specific error description")

# Verify strategies were added
print(len(agent.get_strategies()))

Performance Issues

# Use cheaper models for reflection
from ace import ACE, Skillbook
from pydantic_ai.models.openai import OpenAIModel

ace = ACE(
    model=OpenAIModel("gpt-4o"),  # Expensive for main task
    reflector_model=OpenAIModel("gpt-4o-mini"),  # Cheap for reflection
    skillbook=Skillbook()
)

Trace Format Issues

Traces must be in chat format:

# Correct format
valid_trace = [
    {"role": "user", "content": "Question"},
    {"role": "assistant", "content": "Answer"}
]

# Learn from properly formatted traces
agent.learn_from_traces([valid_trace])

Advanced: Custom Reflector

Customize the reflection process:

from ace.core.reflector import Reflector
from ace.core.skill_manager import SkillManager
from ace import Skillbook

# Custom reflector with specific system prompt
reflector = Reflector(
    model="gpt-4o",
    system_prompt="Focus on error patterns and edge cases"
)

skill_manager = SkillManager(model="gpt-4o-mini")
skillbook = Skillbook()

# Use in custom pipeline
from ace import Pipeline, learning_tail

pipeline = Pipeline(
    learning_tail(reflector, skill_manager, skillbook)
)

Environment Variables

# Required (one of):
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
export GOOGLE_API_KEY=...

# Optional:
export ACE_DEFAULT_MODEL=gpt-4o-mini
export ACE_SKILLBOOK_PATH=/path/to/default.json
export ACE_LOG_LEVEL=INFO

# Hosted API (kayba.ai):
export KAYBA_API_KEY=kb-...

Resources

FAQ

What does the agentic-context-engine skill do?

Add persistent learning and self-improvement to AI agents using ACE framework

How do I install agentic-context-engine?

Run npx skills add https://github.com/reason-machines/ai-agent-skills --skill agentic-context-engine in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/agentic-context-engine/ (personal) or .claude/skills/agentic-context-engine/ (project).

Which AI agents can use agentic-context-engine?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is agentic-context-engine safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains agentic-context-engine?

It is published by reason-machines in reason-machines/ai-agent-skills. It has 157 recorded installs.

More from reason-machines/ai-agent-skills

View all →

agency-agents-zh-skill

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents322 installs

agent-reach-internet-access

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents228 installs

agent-sprite-forge-2d-game-assets

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

Media & Creative216 installs

agentmemory-persistent-memory

reason-machines/ai-agent-skills

Add persistent memory to AI coding agents using agentmemory - remembers context, preferences, and decisions across sessions

AI & Agents216 installs

awesome-agent-skills

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents214 installs

oh-my-openagent-orchestration

reason-machines/ai-agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents211 installs

Popular ai & agents skills

View category →

google-agents-cli-publish

google/agents-cli

This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).

AI & Agents513.9K installs

google-agents-cli-eval

google/agents-cli

This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).

AI & Agents513.5K installs

skill-creator

anthropics/skills

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

OfficialAI & Agents416.4K installs

codex-pet

prime-skills/runcomfy-agent-skills

Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.

AI & Agents402.1K installs

full-output-enforcement

leonxlnx/taste-skill

Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.

AI & Agents401K installs

executing-plans

obra/superpowers

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

AI & Agents245.7K installs