Turn agent traces into reviewed, reusable operational lessons.
Project description
lessonweaver
Turn agent execution traces into reviewed, governed instructions that prevent repeated operational mistakes.
AI agents repeat avoidable mistakes: skipping evidence checks, using stale context, validating too late, or missing governance constraints. lessonweaver is a small, deterministic loop that finds those patterns in execution traces, puts a human review gate in front of them, and exports approved guidance back into agent context. No LLM calls in the core, no automatic self-training, no skill activation without review.
Before / after
- Before: A coding agent "reviews" a PR from the title and description without inspecting the diff. A human corrects it. The same mistake recurs next week.
- Trace: The run is recorded, including the
human_correctionevent. - lessonweaver: Detects a conservative candidate, a human reviews it via multiple-choice questions, and approves it into a reviewed skill.
- After: The reviewed lesson is exported as a Markdown/runtime snippet and
pasted into
AGENTS.md/ Copilot / Claude instructions, so future sessions start with "inspect the changed files first."
What it is / what it is not
| It is | It is not |
|---|---|
| A reviewed-guidance layer over agent traces | An agent framework or orchestrator |
| A deterministic detect → review → export loop | An observability/telemetry product |
| A producer of governed instruction fragments | An eval runner |
| Human-gated and auditable | Autonomous self-training or generic memory |
lessonweaver complements observability, evals, and memory — see comparisons and ecosystem.
Quickstart
lessonweaver is not yet on PyPI (planned, #64). Install from source:
pip install -e ".[dev]"
# 1. Detect candidates from a trace and save them to a temporary registry
lessonweaver detect examples/traces/github_pr_review_failure.json \
--save --registry-root /tmp/lw
# 2. Generate review questions
lessonweaver interview trace-gh-pr-review-001-human-correction --registry-root /tmp/lw
# 3. Record a review answer
lessonweaver answer trace-gh-pr-review-001-human-correction decision approve \
--free-text "Diff inspection is required before review conclusions." \
--registry-root /tmp/lw
# 4. Approve into an operational lesson and skill
lessonweaver approve trace-gh-pr-review-001-human-correction \
--approved-by reviewer --registry-root /tmp/lw
# 5. Export the reviewed skill for an instruction surface
lessonweaver export-skill skill-trace-gh-pr-review-001-human-correction \
--format markdown --redact --registry-root /tmp/lw
Drop --registry-root /tmp/lw to use the default ~/.lessonweaver/registry.
For full recipes, see the coding-agent cookbook.
For a complete worked example with traces, an approved skill, and a validation
suite, see examples/coding_agent_pr_review/.
Runtime loading
from lessonweaver import FileSystemRegistry, SkillLoader
registry = FileSystemRegistry()
loader = SkillLoader(registry=registry)
context = loader.load_for_task(
task="Review this PR for security issues",
agent_type="coding",
tools=["github"],
scope="project",
budget_chars=2000,
)
print(context.snippet)
Commands
lessonweaver detect <trace.json> [--save] [--output FILE] [--dry-run]lessonweaver interview <candidate-id-or-json> [--session FILE] [--dry-run]lessonweaver resume-interview <session.json>— reload a saved review and print the remaining (adaptive) questionslessonweaver answer <candidate-id> <question-id> <option-id> [--free-text ...] [--session FILE]lessonweaver approve <candidate-id> [--approved-by ...] [--dry-run]lessonweaver export-skill <skill-id-or-json> --format markdown|json|copilot|copilot-repo|copilot-path|claude|claude-skill|claude-rule|claude-md|agents-md|codex|runtime [--applies-to GLOB] [--redact] [--output FILE] [--json] [--dry-run]lessonweaver export-lesson <candidate-id-or-json> --format eval|guardrail|workflow [--redact] [--output FILE] [--json] [--dry-run]
Shared output flags: --output FILE writes the result to a file instead of stdout;
--json wraps export-skill/export-lesson output in a {"format": ..., "content": ...}
envelope for scripting; --dry-run previews a command without writing any file or
registry entry (it prints a [dry-run] would write to: ... notice when --output is set).
The review interview is adaptive: marking a lesson high risk or workflow_change
queues a follow-up question, and a reject decision skips the remaining scoping
questions. Save progress with interview --session FILE (a registry-backed candidate
is required so it can be reloaded), record answers into that session with
answer --session FILE, and continue later with resume-interview, which lists the
remaining adaptive questions from the answers recorded so far.
Commands return non-zero on bad input: a missing file exits 1, and invalid JSON or
an invalid trace/skill payload exits 2 with an Error: message on stderr.
lessonweaver lint <skill-id-or-json>lessonweaver analyze-skills <skills-dir>lessonweaver retrieve "<task>"lessonweaver load "<task>"lessonweaver validate-skill <suite.json> [--skills-dir DIR | --registry-root ROOT]- Suite JSON:
{"suite_id": "s1", "skill_id": "pr-review", "examples": [{"example_id": "pos", "task": "Review this pull request", "should_load": true}, {"example_id": "neg", "task": "Generate a SQL migration", "should_load": false}]}. Negative examples (should_load=false) measure precision; the command prints the eval result as JSON and exits0when every example passes,1otherwise.
- Suite JSON:
lessonweaver promote-skill <skill-id> <target-status>
Supported outputs and integrations
| Integration | Status |
|---|---|
| Markdown skill cards | Supported |
| JSON skill cards | Supported |
| GitHub Copilot instruction fragments | Supported (copilot, copilot-repo, copilot-path) |
| Claude Code skill / rule / CLAUDE.md exports | Supported (claude, claude-skill, claude-rule, claude-md) |
| Generic runtime prompt snippets | Supported |
| Codex skill directory export | Supported (codex) |
| AGENTS.md fragment export | Supported (agents-md) |
| Eval / guardrail / workflow exports | Supported (export-lesson) |
| LlamaIndex, OpenAI Agents SDK, Pipecat | Example integrations (LlamaIndex, OpenAI Agents SDK, Pipecat) |
Governance and safety
- Detection is conservative; false negatives are preferred over noisy guidance.
- Human review is the expected governance step before a lesson becomes an
approved skill; the workflow requires it, though the
approvecommand does not yet enforce that review questions were answered. experimentalskills must pass governed lifecycle checks (lint with no errors) before becomingactive.SimpleRedactoris a best-effort safety net before export, not a compliance control.- Skills carry owner, approver, expiration, sensitivity, scope, and evidence metadata.
See when not to create a skill — turning every observation into a skill causes context poisoning.
Anti-goals
- No LLM-based lesson generation in the core library.
- No automatic skill injection without human approval.
- No agent orchestration or framework lock-in.
- No replacement for evals, tests, or review gates.
- No compliance-grade privacy scanner.
Roadmap
Grouped by adoption path (tracking issues):
- Operational memory: #57
- Runtime lesson retrieval API: #59
- Eval companion: #60
- Closed-loop effectiveness measurement: #61
- Policy-gated lesson promotion: #62
Documentation
- Architecture — modules, data flow, lifecycle
- Glossary — canonical terms
- Comparisons — vs. observability, evals, memory, frameworks
- Ecosystem positioning — integration boundaries
- When not to create a skill
- Coding-agent cookbook
- Repository-check findings cookbook
- Integrations: LlamaIndex, OpenAI Agents SDK, Pipecat
- Interoperability
- Trace format
- Repository readiness
- Examples
- Agent instructions
Contributing
See CONTRIBUTING.md for principles, local development, and good first issues.
pip install -e ".[dev]"
ruff check src/ tests/
ruff format --check src/ tests/
mypy src/lessonweaver/
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lessonweaver-0.3.0.tar.gz.
File metadata
- Download URL: lessonweaver-0.3.0.tar.gz
- Upload date:
- Size: 68.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba65b0cbcf6238d0bf6f269097ba9880a5eceb9ec725faff2c16bf5f1211cfc2
|
|
| MD5 |
6113e436cc8ffe7b855de04f0edf70c1
|
|
| BLAKE2b-256 |
d1b0db3f21aad3db663678954c105619859875962f05b7d29e80fbd4e228d059
|
Provenance
The following attestation bundles were made for lessonweaver-0.3.0.tar.gz:
Publisher:
publish.yml on dgenio/lessonweaver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lessonweaver-0.3.0.tar.gz -
Subject digest:
ba65b0cbcf6238d0bf6f269097ba9880a5eceb9ec725faff2c16bf5f1211cfc2 - Sigstore transparency entry: 1707688603
- Sigstore integration time:
-
Permalink:
dgenio/lessonweaver@545a6b451ef477dc3ccf54fcbe2d279999ed24c6 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/dgenio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@545a6b451ef477dc3ccf54fcbe2d279999ed24c6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lessonweaver-0.3.0-py3-none-any.whl.
File metadata
- Download URL: lessonweaver-0.3.0-py3-none-any.whl
- Upload date:
- Size: 51.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36567e5709caad089d7a2193f8c08ffe6e52523d13982a5ab6d96c11fd39aedc
|
|
| MD5 |
b2bffe17cfc50574073ee233cc26be12
|
|
| BLAKE2b-256 |
fcf5b7d1247a60d4392314dbc2c21c606dedecf2d2dd50b049e0761b5917b358
|
Provenance
The following attestation bundles were made for lessonweaver-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on dgenio/lessonweaver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lessonweaver-0.3.0-py3-none-any.whl -
Subject digest:
36567e5709caad089d7a2193f8c08ffe6e52523d13982a5ab6d96c11fd39aedc - Sigstore transparency entry: 1707688666
- Sigstore integration time:
-
Permalink:
dgenio/lessonweaver@545a6b451ef477dc3ccf54fcbe2d279999ed24c6 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/dgenio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@545a6b451ef477dc3ccf54fcbe2d279999ed24c6 -
Trigger Event:
release
-
Statement type: