mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
b0c27e2d8f
## What Problem This Solves Skill Workshop experience review ran as an isolated agent with a re-rendered 60k-character transcript, its own bootstrap, and a trimmed tool surface. Every review was a cold request: no prompt-cache reuse, a large re-serialized trajectory, and a reasoning/tool profile that differed from the foreground turn. Autonomous updates could target any workspace skill, size limits allowed 40 KB skills to grow unchecked (one deployed workspace hit a 21 KB `SKILL.md`), the collection reviewer had to re-list every skill in its plan and read them under a fixed 24k-character budget (a 16-skill workspace failed every pass with "Read every current skill before reconciling"), collection review only recorded successes so a failing pass retried on every Gateway restart, and `openclaw skills curator status` showed nothing about what the last reviews did. ## Why This Change Was Made - **Warm fork.** Experience review now continues the finished turn from the same in-memory session prefix (same session identity, bootstrap, skills prompt, tool schemas, `promptCacheKey`), appends one short review message, and runs with `sessionPersistence: "detached"` so nothing it writes reaches the foreground transcript or session record. Only `skill_workshop` executes; every other tool keeps its schema for cache parity and fails with a next-step message. The gate wraps the core tool list before Code Mode / Tool Search compaction, so catalog-hidden tools stay gated while `tool_call`/`exec` remain callable. `src/agents/embedded-agent-runner/run/attempt.skills-policy.test.ts` asserts identical system-prompt and tool digests between a foreground turn and its review, and that `tool_call` reaches `skill_workshop` but not `read` during review. Code Mode swarm globals (`phase`, `log`, `agents.run`) are the `sessions_spawn` capability and gate on the same allowlist, so a review cannot emit foreground lifecycle events or launch collectors. The review shares the foreground session, so it no longer retires that session's MCP runtime on run end; it reuses the warm runtime like any turn. Accepted tradeoff: the review inherits foreground tool construction (it creates the session MCP runtime only when the session has none, and spawns per-attempt LSP servers only when configured), because splitting tool construction from the foreground turn would break the cache-parity invariant this PR exists for. - **One apply owner, rechecked at the write boundary.** `src/skills/workshop/autonomous-apply.ts` decides apply-vs-pending for both the post-review loop and foreground repair: creates and updates to Workshop-authored skills apply; updates to user-authored skills stay pending with a recorded reason. `applySkillProposalTransition` rechecks path-based ownership under the commit lock for non-operator actors (agent, or no actor), so a claim released after the pre-check cannot let an agent write a user-authored skill; gateway and CLI operators still approve any pending proposal. The user-authored pending write runs under the same commit lock and rereads the row, so an operator apply that lands first is kept. The old `auto-apply.ts` path and name-based `listWorkshopAuthoredSkillNames` are deleted. - **Sparse collection plan and model-relative reads.** The collection reviewer returns only `write` and `drop` entries; unlisted skills stay untouched, so a 16-skill workspace no longer has to restate 16 keeps. The skill read budget is derived from the model's context window (35%) instead of a fixed 24k characters, with the 10,000-character skill cap still enforced per skill. No windowed read parameters: a skill is read whole or not at all. - **Weekly cadence.** Collection review runs once every 7 days instead of daily (`REVIEW_INTERVAL_MS`), matching how slowly a skill library actually changes; the attempt is recorded before the model starts, so a failed pass does not retry on every restart. - **Lean cap.** `AUTONOMOUS_SKILL_MAX_CHARS = 10,000` in `src/skills/workshop/collection-contracts.ts` is enforced by the tool and by collection reconcile; an oversized skill may only shrink. Tool description, experience prompt, and collection prompt were rewritten around procedures-not-records, one trigger per branch, and "NOTHING_TO_LEARN is the correct answer for most turns". - **Detached runs end quietly.** A detached run writes no transcript or session record and runs under the foreground session key, so `attempt-finalize` now skips agent_end side effects for it: plugins do not observe the review as a foreground turn, and a deep review cannot schedule a successor review of itself. - **Recorded outcomes.** Experience review records `applied | proposed | nothing | failed` with usage; one attempt per turn, drop on error. `openclaw skills curator status` prints the last collection and experience review outcome. ## User Impact - Default `auto` mode: experience review reuses the foreground prompt cache and skips message/other tool execution, so review cost is one bounded continuation instead of a cold re-render. - Autonomous edits touch only Workshop-authored skills; handwritten skills surface as pending proposals for operator approval. - Autonomous `SKILL.md` results stay ≤ 10,000 characters. - Collection review runs weekly and succeeds on larger skill libraries. A workspace with no recorded attempt reviews at the first daily check after Gateway start; an upgraded install keeps its recorded last attempt and reviews once it is older than 7 days. The 10,000-character cap applies to the next autonomous write; existing oversized skills are only ever shrunk. - `openclaw skills curator status` shows the last collection and experience review outcome, time, and tokens. - Docs: https://docs.openclaw.ai/tools/self-learning, https://docs.openclaw.ai/tools/skill-workshop Related: #123866, #128871 both patch skills above the reviewer read budget; this PR caps autonomous skill size and restricts oversized skills to shrink-only rewrites. ## Evidence - Live gateway (Linux, Telegram, `xai` provider) at `133ffe3`: manual experience review on a real foreground turn → `nothing` (usage: 0 uncached input, 13,902 cached, 36 output — the forked review hit the foreground prompt cache); manual collection review over the workspace → `succeeded`; the three oversized skills were rewritten under the cap (21,002 → 9,449; 11,882 → 7,735; 10,300 → 7,413 bytes, originals in `skill-workshop/collection-backups/`), the rest untouched, and the pre-PR "Read every current skill before reconciling" failure is gone. The next foreground turn's automatic experience review recorded `nothing` and `openclaw skills curator status` shows both outcomes. The apply recheck, MCP-runtime change (`26e821f`), and detached agent_end skip (`7e4a506`) landed after that run and are covered by the regression tests below. - `pnpm test src/skills/workshop src/agents/tools/skill-workshop-tool src/gateway/server-methods/skills` plus `src/agents/embedded-agent-runner/run/attempt.skills-policy.test.ts`, `src/agents/embedded-agent-runner/run/attempt.tool-search-catalog-abort.test.ts`, `src/cli/skills-cli.curator.test.ts`, `src/agents/harness/tool-surface-bridge.test.ts` — green. New regression tests (`service.test.ts` agent-vs-operator apply on a user-authored skill and operator apply kept over a stale pending snapshot; `experience-review.apply.test.ts` no `cleanupBundleMcpOnRunEnd`; `attempt-phase-lifecycle.test.ts` no agent_end for a detached run; `code-mode-swarm.test.ts` swarm globals refused under the review allowlist) fail on the pre-fix code. - Dependent sweep: 46 test files importing the touched modules — green. - `oxfmt`, `scripts/run-oxlint.mjs` on changed files, `git diff --check` — clean. - `pnpm tsgo && pnpm check:test-types` on Blacksmith Testbox — clean. - Local ClawSweeper review (`gpt-5.6-terra`, high): `133ffe3` raised two findings (ownership recheck removed from the apply boundary; review retiring the shared session's MCP runtime), fixed in `26e821f`; `26e821f` raised one (detached review re-entering agent-end scheduling), fixed in `7e4a506`; `7e4a506` raised three: pending write racing an operator apply and Code Mode swarm globals bypassing the execution gate, both fixed in `e4b4322`; "prove detached review does not start configured MCP or LSP runtimes" is skipped as the cache-parity tradeoff stated above (LSP tool schemas come from the LSP runtime; the MCP runtime is session-owned and already warm). Maintainer decision on `e4b4322`: accepted — a detached review reuses the session MCP runtime and re-spawns configured per-attempt LSP servers exactly like a foreground turn; it still cannot execute them. - Unrelated CI on `26e821f`/`7e4a506`: `check-lint-core-2` (`max-lines` in `src/gateway/server-methods/models-list-result.ts`, unused param in `models.test.ts`, both from #129332) and `checks-node-compact-small-8` (`doctor-auth.profile-health.test.ts`, Claude CLI auth from #129052) fail identically on `main` run 32857954734; `checks-node-compact-small-31` pins plugin SDK export counts (`4340` vs `4342`) that #129052 moved — this PR touches no `src/plugin-sdk` file. On `e4b4322` the failing set is the same twelve `checks-node-compact` shards that fail on `main` run 32857954734 (`large-5/12/13/14/15/18/22`, `small-8/14/20/21/26`) plus `small-31`; `check-lint-core-2` passes here. None are fixed here; #129357 carries the `main` fix. - LOC (raw numstat): production +712 / −664 (net +48; the four review-fix commits after the live run add +76 / −26); tests + docs +1269 / −1238 (net +31).
340 lines
16 KiB
Markdown
340 lines
16 KiB
Markdown
---
|
|
summary: "Turn corrections and successful work into reusable skills through Skill Workshop"
|
|
read_when:
|
|
- You want OpenClaw to learn reusable procedures from completed conversations
|
|
- You are choosing between off, propose, and auto self-learning modes
|
|
- You need to understand self-learning safety, cost, privacy, or troubleshooting
|
|
title: "Self-learning"
|
|
sidebarTitle: "Self-learning"
|
|
---
|
|
|
|
Self-learning turns corrections and successful work into reusable skills. Skills
|
|
are the durable unit: they hold procedures that future sessions can discover and
|
|
follow. Every learned skill flows through [Skill Workshop](/tools/skill-workshop),
|
|
the same governed proposal, scan, apply, and lifecycle path used for explicit
|
|
skill authoring.
|
|
|
|
The default mode is `auto`. OpenClaw captures strong learning signals and applies
|
|
them through the normal scanner-gated Workshop service without asking for
|
|
approval. Choose `propose` to review every capture before it becomes active, or
|
|
`off` to disable autonomous capture.
|
|
|
|
## Immediate repair
|
|
|
|
When the foreground agent discovers that a skill it used is wrong or incomplete,
|
|
it reads the current live skill and drafts a targeted patch through Skill
|
|
Workshop in the same turn. A runtime usage receipt prevents foreground repair of
|
|
skills that the run did not use. Autonomous mode controls the outcome: `off`
|
|
disables the repair, `propose` leaves it pending for explicit review and apply,
|
|
and `auto` scans and applies it immediately. The repair still goes through
|
|
proposal storage, hash binding, the security scanner, and rollback capture.
|
|
|
|
Immediate repair changes the live skill for new sessions. It does not rewrite the
|
|
skill snapshot already loaded into the running session. The delayed experience
|
|
review remains a fallback for durable learning that the foreground agent did not
|
|
repair itself.
|
|
|
|
## Experience review
|
|
|
|
Every autonomous capture is authored by a model reviewing real evidence. There
|
|
is no template or pattern-matching path: content that reaches a proposal was
|
|
written by the reviewer against the Workshop authoring standards, never copied
|
|
from conversation text.
|
|
|
|
After substantial work, OpenClaw can run one detached background review to find
|
|
a reusable recovery technique or a stable procedure that would remove at least
|
|
two future model or tool round trips. Deep turns the user interrupted qualify
|
|
too: the wrong path and its correction are exactly the evidence worth keeping.
|
|
The reviewer is told when a turn was interrupted and captures only procedures
|
|
that visibly worked before the stop. Turns that ended in a provider or prompt
|
|
error never schedule a review; that failure is transient environment noise, and
|
|
a review on the same model would likely hit it again.
|
|
|
|
Experience review starts only when all of these conditions hold:
|
|
|
|
- the foreground turn completed or was interrupted, but did not end in a
|
|
provider or prompt error;
|
|
- the current turn used at least 10 model iterations;
|
|
- the run was an eligible foreground conversation, not cron, heartbeat, memory,
|
|
overflow, hook, subagent, or review work;
|
|
- the runtime reported the resolved provider, model, and actual availability of
|
|
`skill_workshop`;
|
|
- the system has been quiet for 30 seconds; and
|
|
- no agent or reply run is still active.
|
|
|
|
A later foreground completion in the same session restarts the quiet period.
|
|
Only one experience review runs at a time. The foreground answer is never delayed.
|
|
|
|
The reviewer continues the finished turn from the same transcript prefix. This
|
|
lets the provider reuse the foreground prompt cache. Its appended review message
|
|
and tool results never enter the foreground transcript or session record.
|
|
|
|
The reviewer is detached and biased toward small, well-evidenced captures. It
|
|
receives an authoritative receipt of the skills the foreground run actually
|
|
read or command-invoked, plus a bounded workspace skill list. It prefers a used
|
|
writable skill when that skill governs the learning, then another existing
|
|
skill, and creates a new skill only when nothing covers the class.
|
|
|
|
Before changing an existing skill, the reviewer reads its current body. Both
|
|
update forms bind the proposal to that content hash. An oversized skill can be
|
|
rewritten only when the result is shorter. Autonomous `SKILL.md` results stay at
|
|
or below 10,000 characters. Longer reference and examples move into bundled
|
|
files. The reviewer sees the foreground tool schemas, but only `skill_workshop`
|
|
can execute. The reviewed transcript is evidence, not instructions.
|
|
|
|
Workshop-authored skills can apply automatically. Updates to user-authored skills
|
|
stay pending with a reason for operator review. Each review gets one attempt.
|
|
A failure is logged and dropped instead of retrying the turn.
|
|
|
|
Good candidates include:
|
|
|
|
- a reliable recovery after repeated tool or model failures;
|
|
- a durable user correction or standing instruction ("from now on," "always,"
|
|
"never," "stop doing X"), embedded as a procedure step in the skill governing
|
|
that work;
|
|
- a non-obvious ordering constraint that prevented a recurring error;
|
|
- a stable multi-step workflow that required repeated discovery; or
|
|
- a reusable preflight that would avoid several future calls.
|
|
|
|
The reviewer should abstain for:
|
|
|
|
- routine successful work or a one-time request;
|
|
- personal facts and simple preferences;
|
|
- transient environment or service failures;
|
|
- generic advice without concrete supporting evidence;
|
|
- unsupported negative claims; or
|
|
- secrets and credential material.
|
|
|
|
## Mode policy
|
|
|
|
| Mode | Capture behavior |
|
|
| --------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
| `off` | Does not create experience-review captures. |
|
|
| `propose` | Creates or revises pending proposals. Nothing applies automatically. |
|
|
| `auto` | Applies autonomous creates and Workshop-authored updates. User-authored updates stay pending for review. This is the default. |
|
|
|
|
Set the mode with the CLI:
|
|
|
|
```bash
|
|
openclaw config set skills.workshop.autonomous.mode auto
|
|
openclaw config set skills.workshop.autonomous.mode propose
|
|
openclaw config set skills.workshop.autonomous.mode off
|
|
```
|
|
|
|
Or edit `~/.openclaw/openclaw.json`:
|
|
|
|
```json5
|
|
{
|
|
skills: {
|
|
workshop: {
|
|
autonomous: {
|
|
mode: "auto",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
```
|
|
|
|
Changing the mode does not alter existing proposals or applied skills. Manual
|
|
history review, `/learn`, and explicit Workshop requests remain available in all
|
|
three modes.
|
|
|
|
## Why auto is safe to default
|
|
|
|
Automatic learning uses the same apply path as an operator-approved Workshop
|
|
proposal. It does not give the isolated reviewer new tools or a way to bypass
|
|
lifecycle checks.
|
|
|
|
Every learned skill receives these controls:
|
|
|
|
- **Security scan at apply:** Workshop reruns the scanner immediately before the
|
|
live write. A critical finding quarantines the proposal instead of applying it.
|
|
- **Workshop-owned writes:** creates target the selected workspace. Only updates
|
|
to skills created by Workshop apply automatically. User-authored updates stay
|
|
pending. Bundled, plugin, managed, system, and extra-root skills remain read-only.
|
|
- **Hash binding:** update proposals bind to the current live skill and go stale
|
|
if that target changes before apply.
|
|
- **Lean cap:** autonomous results stay at or below 10,000 characters. A skill
|
|
already above the cap can only become shorter.
|
|
- **Rollback metadata:** apply records the prior skill and support-file contents
|
|
before the live write.
|
|
- **Collection review:** once a week in `auto` mode, an isolated model session
|
|
reads the skills it intends to change. Externally owned skills stay untouched; only
|
|
Workshop-owned paths can be rewritten or dropped. Collection-created skills
|
|
receive automatically applied `create` proposal records.
|
|
- **Collection backup:** review validates and scans every rewrite before changing
|
|
the workspace, keeps one recoverable collection backup, and restores it if a
|
|
write fails.
|
|
- **Authoring standards:** learned skills use class-level names, trigger-first
|
|
descriptions, evidence-backed steps, and token-efficient language.
|
|
- **Bounded failure:** an automatic apply is attempted once. A normal apply
|
|
failure leaves the proposal pending, while a scanner-critical proposal is
|
|
quarantined. OpenClaw does not retry in a loop.
|
|
|
|
Reject a pending miscapture with one command:
|
|
|
|
```bash
|
|
openclaw skills workshop reject <proposal-id> --reason "Not reusable"
|
|
```
|
|
|
|
Applied captures remain visible in `openclaw skills workshop list` and retain
|
|
their rollback metadata. The weekly collection review can later improve, merge,
|
|
or remove them. This makes
|
|
approval-free learning reversible and observable rather than silent.
|
|
|
|
Residual risk remains: learned content comes from conversation and tool output,
|
|
and the scanner blocks recognized dangerous patterns, not every possible piece
|
|
of bad advice. Review `openclaw skills workshop list` when in doubt.
|
|
|
|
## Runtime support
|
|
|
|
Delayed experience review requires the runtime to report its resolved model and
|
|
actual `skill_workshop` availability. The embedded runner and Codex app-server
|
|
harness report those facts; Codex also reports its exact model-iteration count.
|
|
Other CLI-backed runtimes fail closed until they provide the same runtime facts.
|
|
`/learn` does not depend on delayed review and continues to work on those
|
|
runtimes.
|
|
|
|
## Cost and privacy
|
|
|
|
Experience review adds one bounded model run on the configured provider only
|
|
after a substantial turn, not after every message. The review can make more
|
|
than one provider request while it inspects or drafts its single proposal.
|
|
|
|
The review forks the foreground transcript in memory and appends one small user
|
|
message. It uses the same provider, model, auth profile, session identity,
|
|
bootstrap context, skills prompt, and tool schemas. The provider can reuse the
|
|
finished turn's cached request prefix. Review writes remain detached.
|
|
|
|
The reviewer reuses the foreground provider, model, and available auth identity,
|
|
with model fallbacks disabled. Provider pricing and data-handling terms apply to
|
|
the additional run.
|
|
|
|
Weekly collection review also uses the configured agent model. It receives the
|
|
names, descriptions, and ownership state of eligible workspace skills, then reads each
|
|
skill it intends to change before one atomic call listing only changes. Disabled and
|
|
agent-filtered skills stay untouched. Shared workspaces use the union of each
|
|
agent's allowed skills only when provider, model, and resolved auth identity
|
|
match. Reconciliation must leave every sharing agent at least one visible skill.
|
|
It has no message tool or general agent tools. Skill bodies are treated as
|
|
untrusted evidence, not as instructions. A persisted per-workspace attempt time
|
|
prevents Gateway restarts from repeating a failed or successful review within 7 days. The
|
|
foreground agent can restore the one retained collection backup when asked to
|
|
undo the cleanup, unless an affected skill changed afterward.
|
|
|
|
Manual history scan uses a separate bounded path. It reviews up to 20 substantial
|
|
sessions with at least six model turns, redacts recognized secrets, bounds the
|
|
transcript bundle, and can create or revise at most three pending proposals. It
|
|
stores cursor and coverage metadata in the shared state database without copying
|
|
transcript content into scan state.
|
|
|
|
<Warning>
|
|
Experience review and manual history scan can send eligible conversation
|
|
content, including tool inputs and results, to the configured model provider.
|
|
Choose a provider and mode that match the workspace privacy and data-handling
|
|
requirements.
|
|
</Warning>
|
|
|
|
## Review and revert learning
|
|
|
|
List and inspect every pending, applied, rejected, quarantined, or stale capture:
|
|
|
|
```bash
|
|
openclaw skills workshop list
|
|
openclaw skills workshop inspect <proposal-id>
|
|
```
|
|
|
|
Stop a pending capture from becoming active or quarantine it for safety review:
|
|
|
|
```bash
|
|
openclaw skills workshop reject <proposal-id> --reason "Too specific"
|
|
openclaw skills workshop quarantine <proposal-id> --reason "Needs security review"
|
|
```
|
|
|
|
Use `/learn` when you want an explicit proposal from the current conversation or
|
|
named sources:
|
|
|
|
```text
|
|
/learn
|
|
/learn docs/runbook.md; focus on recovery
|
|
```
|
|
|
|
`/learn` first revises a matching pending proposal or updates a matching live
|
|
skill. It creates a new pending proposal only when no skill owns the procedure,
|
|
and never auto-applies the result.
|
|
|
|
To review older work manually, open **Plugins -> Workshop** in Control UI and
|
|
select **Find skill ideas**. Each click reviews one bounded window and leaves any
|
|
result pending regardless of autonomous mode.
|
|
|
|
## Configuration reference
|
|
|
|
| Setting | Default | Effect |
|
|
| ------------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
| `skills.workshop.autonomous.mode` | `"auto"` | Chooses capture behavior; `auto` also enables weekly collection review. |
|
|
| `skills.workshop.approvalPolicy` | `"auto"` | Controls prompts for normal agent-initiated lifecycle calls. It never expands the isolated reviewer tool surface. |
|
|
| `skills.workshop.maxPending` | `50` | Caps pending and quarantined proposals per workspace. |
|
|
| `skills.workshop.maxSkillBytes` | `40000` | Caps proposal body size in bytes. |
|
|
| `skills.workshop.allowSymlinkTargetWrites` | `false` | Allows apply through explicitly trusted workspace skill symlinks. Capture itself does not widen the trusted target list. |
|
|
|
|
See [Skills config](/tools/skills-config#workshop-skills-workshop) for ranges and
|
|
the complete `skills.*` schema.
|
|
|
|
## Troubleshooting
|
|
|
|
### No capture appears
|
|
|
|
Check the following:
|
|
|
|
1. `skills.workshop.autonomous.mode` is `propose` or `auto` in the active Gateway
|
|
config.
|
|
2. The turn reached at least 10 model iterations without ending in a provider or
|
|
prompt error.
|
|
3. The conversation is eligible foreground work.
|
|
4. The runtime reported the resolved model and actual `skill_workshop`
|
|
availability.
|
|
5. The run was not sandboxed and tool policy still permits `skill_workshop`.
|
|
6. The Gateway stayed running and idle through the 30-second quiet period.
|
|
|
|
An eligible experience review can still abstain. No proposal is the expected
|
|
result when the evidence does not clear the reusable-procedure bar.
|
|
Use `openclaw skills curator status` to inspect the last collection and
|
|
experience review outcomes.
|
|
|
|
### Doctor reports that Workshop is hidden
|
|
|
|
In `propose` and `auto` modes, `openclaw doctor` checks whether the default agent
|
|
tool policy permits `skill_workshop`. Apply the reported `tools.allow` or
|
|
`tools.alsoAllow` change, or set the autonomous mode to `off`.
|
|
|
|
### A proposal remains pending in auto mode
|
|
|
|
Automatic apply runs once. Inspect the proposal and its scanner state:
|
|
|
|
```bash
|
|
openclaw skills workshop inspect <proposal-id>
|
|
```
|
|
|
|
A user-authored target or normal write failure leaves it pending for manual review. A critical
|
|
scanner result moves it to quarantine. Fix the cause and apply manually; do not
|
|
build a retry loop around automatic capture.
|
|
|
|
### Too many low-value captures appear
|
|
|
|
Switch to `propose` to review every capture, or `off` to disable autonomous
|
|
capture:
|
|
|
|
```bash
|
|
openclaw config set skills.workshop.autonomous.mode propose
|
|
openclaw config set skills.workshop.autonomous.mode off
|
|
```
|
|
|
|
Existing proposals and applied skills remain visible after the mode changes.
|
|
|
|
## Related
|
|
|
|
- [Skill Workshop](/tools/skill-workshop) for proposal lifecycle and storage
|
|
- [Creating skills](/tools/creating-skills) for hand-authored skills
|
|
- [Skills config](/tools/skills-config) for every `skills.*` setting
|
|
- [Skills CLI](/cli/skills) for Workshop commands
|