Every failure becomes a lesson. Common-error failure rate drops as O(1/n) where n = agents who attempted the task.
- Trials — structured records of agent attempts (success or failure) with failure mode classification
- Lessons — compiled knowledge from multiple trials, retrievable by category and difficulty
- Experience capture — record agent interactions and outcomes automatically
- Curriculum — organize lessons by topic and difficulty for progressive learning
- Knowledge transfer — apply lessons from one agent/context to new situations
- Proven math — fleet with trial recording achieves O(1/n) failure rate vs O(1) without
pip install cocapn-lessonsfrom cocapn_lessons import Trial, Lesson, LessonLibrary, Experience, Curriculum
# Record a failed trial
trial = Trial(
task="deploy to staging",
agent_id="agent-3",
success=False,
failure_mode="timeout",
context={"timeout_seconds": 30, "service": "api-gateway"},
error_details="Connection timed out after 30s"
)
# Extract lessons from experiences
from cocapn_lessons import LessonExtractor
lib = LessonLibrary()
extractor = LessonExtractor()
experience = Experience(agent_id="agent-3", trials=[trial])
lesson = extractor.extract(experience)
lib.add(lesson)
# Build a curriculum
curriculum = Curriculum(name="deployment")
curriculum.add_lesson(lesson, level=CurriculumLevel.INTERMEDIATE)
# Transfer knowledge to a new agent
from cocapn_lessons import KnowledgeTransfer
transfer = KnowledgeTransfer()
applicable = transfer.find_applicable(lib, context={"task": "deploy to production"})
for l in applicable:
print(f"Lesson: {l.title} — {l.summary}")Trial— Single attempt record with failure mode, context, error detailsLesson— Compiled knowledge from trials, with confidence scoringLessonLibrary— Searchable collection of lessonsFailureMode— Enum:TIMEOUT,ERROR,REJECTION,WRONG_RESULT,CRASH,RESOURCE_EXHAUSTED, etc.Category— Enum:TOOLING,NAVIGATION,API,STRATEGY,RESOURCE_MANAGEMENT, etc.
Experience— Agent interaction record withOutcomeand trialsLessonExtractor— Finds patterns in experiences and creates lessonsCurriculum/CurriculumLevel— Organized lesson sequencesKnowledgeTransfer— Cross-agent, cross-context lesson application
The pedagogical engine of the SuperInstance fleet. Inspired by PLATO's unit-based pedagogy and spaced repetition — agents get smarter as a fleet, not just individually.
- cocapn — Core infrastructure (rooms train on lessons)
- cocapn-explain — Explainability (lessons feed traces)
- cocapn-dreamer — Speculative execution (avoids known failures)
pytest tests/pip install cocapn-lessonsPython 3.10+. MIT license.