← ACE home Architecture Source on GitHub Paper
📓 Cookbook

Learn ACE one recipe at a time

Ten short, runnable scripts that teach Agentic Context Engineering from a first playbook to a self-improving OpenAI Agents SDK agent. Recipes 01–07 need no API key and are verified in CI.

The 30-second version

Construct, learn, evaluate — then point the same code at a real model.

from ace import ACE, SimulatedLLM, TeachingEnvironment, build_teaching_task

env  = TeachingEnvironment()
task = build_teaching_task()
train, test = task.split()

ace = ACE(SimulatedLLM(env))
ace.adapt_offline(train)          # build a playbook from feedback
print(ace.evaluate(test).accuracy)  # measure on held-out data
print(ace.playbook.render())        # inspect what it learned

Core recipes no API key

Deterministic, offline, and covered by tests/test_cookbook.py.

RECIPE 01

first_playbook

The three-line workflow — construct → adapt_offlineevaluate — and the accuracy lift over a base LLM with no context.

RECIPE 02

online_adaptation

Test-time learning: predict-then-learn per sample, and proving the agent improves with windowed accuracy.

RECIPE 03

your_own_task

Define a Task from your own Samples and scorer — ACE makes no assumptions about your domain.

RECIPE 04

label_free_feedback

Learn with no gold labels via a feedback_fn that returns execution signals — the realistic production setting.

RECIPE 05

save_and_resume

Persist a playbook to JSON and warm-start a fresh engine from it — memory that survives a restart.

RECIPE 06

grow_and_refine

De-duplicate near-identical bullets and prune consistently harmful ones — deterministic, non-LLM compaction.

RECIPE 07

inspect_and_report

Introspect bullets and stats, then render a polished, dependency-free HTML report of a run.

OpenAI Agents SDK recipes API key

Install the extras and set a key: pip install "ace-playbook[all]" && export OPENAI_API_KEY=sk-...

RECIPE 08

agent_quickstart

wrap_agent in one call: playbook injection on every run, run_and_learn, and save() for durable memory.

needs key View source →
RECIPE 09

auto_learn_from_tool_errors

Capture hooks turn a failed tool call into an automatic learning signal — no explicit feedback required. Read out.auto_signal / out.events.

needs key View source →
RECIPE 10

streaming_and_sessions

Stream and learn with arun_streamed_and_learn, and compose ACE's learned memory with an SDK session for multi-turn history.

needs key View source →

Suggested learning path

Start with the regimes, then your data, then operations, then agents.

01 first_playbook ─► 02 online_adaptation ─► 03 your_own_task ─► 04 label_free_feedback
        │                                                              │
        ▼                                                              ▼
05 save_and_resume ─► 06 grow_and_refine ─► 07 inspect_and_report      │
                                                                       ▼
                              08 agent_quickstart ─► 09 auto_learn ─► 10 streaming/sessions

Browse all recipes on GitHub ← Back to home