ACE (Agentic Context Engineering)
Enable agents to learn and improve from human feedback using ACE
AxCrew integrates Agentic Context Engineering (ACE) from the Ax framework, enabling agents to learn and improve from human feedback. ACE maintains a "playbook" of learned rules that guide agent behavior, which can be persisted across sessions.
Key Features
- Online Learning: Agents learn from real-time feedback during conversations
- Playbook Persistence: Save learned rules to JSON files or custom storage
- Teacher/Student Model: Use a separate "teacher" LLM to distill feedback into actionable rules
- Feedback Routing: Distribute feedback across agent dependency chains automatically
Configuration
Add the ace field to any agent configuration:
ACE Configuration Options
| Field | Type | Description |
|---|---|---|
teacher | object | Teacher model config (provider, model, apiURL) |
teacher.provider | string | AI provider for the teacher model |
teacher.providerKeyName | string | Environment variable for teacher API key |
teacher.ai | object | Model configuration for teacher |
persistence.playbookPath | string | File path to save/load playbook |
persistence.autoPersist | boolean | Auto-save playbook after updates |
persistence.onPersist | function | Custom callback for saving playbook |
persistence.onLoad | function | Custom callback for loading playbook |
options.maxEpochs | number | Training epochs for offline compile |
options.allowDynamicSections | boolean | Allow playbook to create new sections |
metric.primaryOutputField | string | Output field to evaluate for quality |
compileOnStart | boolean | Run offline compile on agent init |
Usage: Applying Feedback
Feedback Strategies
| Strategy | Description |
|---|---|
"all" | Apply feedback to all agents involved in the task |
"primary" | Apply only to the primary (entry) agent |
"leaf" | Apply only to leaf agents (no sub-agents) |
Playbook Persistence
File-based Persistence
The simplest approach - save playbooks to JSON files:
Custom Persistence
For databases or cloud storage:
Example: Customer Support with Learning
Best Practices
- Start with a teacher model: Use a capable model (GPT-4, Claude 3) as the teacher
- Enable autoPersist: Don't lose learned rules between sessions
- Use specific feedback: "For X situation, do Y" is better than "be better"
- Monitor playbook size: Large playbooks may affect performance
- Test learned behaviors: Verify the agent applies learned rules correctly
Examples
See the complete examples in the repository:
ace-customer-support.ts- Learn edge-case handlingace-flight-finder.ts- Flight assistant with preference learning