Skip to content

Commit 874c633

Browse files
authored
fix(skills): remove regex correction capture; self-learning is reviewer-only
Deletes the deterministic regex capture path that templated raw chat text into skill proposals (junk like a proposal whose whole procedure was one slugified user message). All autonomous learning now flows through the isolated experience reviewer: it sees a bounded workspace skill list, prefers revising pending proposals or updating the governing skill over creating new ones, and treats durable user corrections as first-class evidence. Update proposals are reviewer-only (explicit opt-in) and never auto-apply, since the reviewer drafts them without the live skill body. Removes the producerless pending-suggestion session machinery. Regression test proves the junk path is gone; real-Telegram E2E verdict in the PR body.
1 parent 355c107 commit 874c633

33 files changed

Lines changed: 395 additions & 4252 deletions

‎docs/tools/self-learning.md‎

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,14 @@ skill authoring.
1717
The default mode is `auto`. OpenClaw captures strong learning signals and applies
1818
them through the normal scanner-gated Workshop service without asking for
1919
approval. Choose `propose` to review every capture before it becomes active, or
20-
`off` to keep only the suggestion nudge.
20+
`off` to disable autonomous capture.
2121

22-
## Capture paths
22+
## Experience review
2323

24-
OpenClaw uses two complementary capture paths.
25-
26-
### Deterministic correction capture
27-
28-
When an interactive turn ends, OpenClaw looks for durable instructions such as
29-
"from now on," "next time," and direct corrections to a failed approach. This
30-
path is deterministic and does not start another model run. It can:
31-
32-
- group related instructions into up to three focused skills;
33-
- route a correction to a matching writable workspace skill;
34-
- revise its own related pending proposal; and
35-
- capture after a failed turn because the user instruction remains useful even
36-
when the work did not complete.
37-
38-
Detection is intentionally heuristic. A durable phrase can occasionally produce
39-
an overly broad or low-value capture. That is an accepted tradeoff because
40-
miscaptures are cheap to inspect and remove, while Workshop governance keeps the
41-
write bounded and recoverable.
42-
43-
### Experience review
24+
Every autonomous capture is authored by a model reviewing real evidence. There
25+
is no template or pattern-matching path: content that reaches a proposal was
26+
written by the reviewer against the Workshop authoring standards, never copied
27+
from conversation text.
4428

4529
After substantial work, OpenClaw can run one isolated background review to find
4630
a reusable recovery technique or a stable procedure that would remove at least
@@ -66,14 +50,23 @@ Experience review starts only when all of these conditions hold:
6650
A later foreground completion in the same session restarts the quiet period.
6751
Only one experience review runs at a time. The foreground answer is never delayed.
6852

69-
The reviewer is isolated and conservative. It can list or inspect proposals and
70-
create or revise at most one pending proposal. Its one-mutation budget is shared
71-
across retries. It cannot apply, reject, quarantine, message, update a live skill,
72-
or use general agent tools. The reviewed trajectory is evidence, not instructions.
53+
The reviewer is isolated and conservative. It sees a bounded workspace skill
54+
list and can list or inspect proposals. It drafts at most one pending proposal:
55+
preferring to revise a matching pending proposal, then to propose an update to
56+
the existing skill governing the work, and creating a new skill only when
57+
nothing covers the class. Its one-mutation budget is shared across retries.
58+
Every mutation is a pending proposal — it never writes a live skill directly and
59+
cannot apply, reject, quarantine, message, or use general agent tools. Because
60+
the reviewer drafts update bodies without reading the live skill, update
61+
proposals are never auto-applied: they stay pending for operator review even in
62+
`auto` mode. The reviewed trajectory is evidence, not instructions.
7363

7464
Good candidates include:
7565

7666
- a reliable recovery after repeated tool or model failures;
67+
- a durable user correction or standing instruction ("from now on," "always,"
68+
"never," "stop doing X"), embedded as a procedure step in the skill governing
69+
that work;
7770
- a non-obvious ordering constraint that prevented a recurring error;
7871
- a stable multi-step workflow that required repeated discovery; or
7972
- a reusable preflight that would avoid several future calls.
@@ -89,11 +82,11 @@ The reviewer should abstain for:
8982

9083
## Mode policy
9184

92-
| Mode | Capture behavior | Suggestion nudge |
93-
| --------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
94-
| `off` | Does not create deterministic or experience-review captures. | Enabled. OpenClaw can offer to save a detected durable instruction. |
95-
| `propose` | Creates or revises pending proposals through both capture paths. Nothing applies automatically. | Suppressed. |
96-
| `auto` | Creates or revises proposals, then immediately calls the normal Workshop apply path. This is the default. | Suppressed. |
85+
| Mode | Capture behavior |
86+
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
87+
| `off` | Does not create experience-review captures. |
88+
| `propose` | Creates or revises pending proposals. Nothing applies automatically. |
89+
| `auto` | Creates or revises proposals, then applies new-skill proposals through the normal Workshop apply path. Update proposals stay pending for review. This is the default. |
9790

9891
Set the mode with the CLI:
9992

@@ -167,17 +160,13 @@ Delayed experience review requires the runtime to report its resolved model and
167160
actual `skill_workshop` availability. The embedded runner and Codex app-server
168161
harness report those facts; Codex also reports its exact model-iteration count.
169162
Other CLI-backed runtimes fail closed until they provide the same runtime facts.
170-
171-
Deterministic correction capture and `/learn` do not depend on delayed review and
172-
continue to work on those runtimes. In `auto` mode, a runtime that does not report
173-
actual Workshop availability leaves deterministic captures pending instead of
174-
applying them.
163+
`/learn` does not depend on delayed review and continues to work on those
164+
runtimes.
175165

176166
## Cost and privacy
177167

178-
Deterministic correction capture does not make an extra model call. Experience
179-
review adds one bounded model run on the configured provider only after a
180-
substantial turn, not after every message. The review can make more
168+
Experience review adds one bounded model run on the configured provider only
169+
after a substantial turn, not after every message. The review can make more
181170
than one provider request while it inspects or drafts its single proposal.
182171

183172
The reviewer receives only the current turn beginning with its most recent user
@@ -262,14 +251,13 @@ Check the following:
262251

263252
1. `skills.workshop.autonomous.mode` is `propose` or `auto` in the active Gateway
264253
config.
265-
2. The correction uses durable language, or the turn reached at least 10 model
266-
iterations without ending in a provider or prompt error.
254+
2. The turn reached at least 10 model iterations without ending in a provider or
255+
prompt error.
267256
3. The conversation is eligible foreground work.
268257
4. The runtime reported the resolved model and actual `skill_workshop`
269258
availability.
270259
5. The run was not sandboxed and tool policy still permits `skill_workshop`.
271-
6. For experience review, the Gateway stayed running and idle through the
272-
30-second quiet period.
260+
6. The Gateway stayed running and idle through the 30-second quiet period.
273261

274262
An eligible experience review can still abstain. No proposal is the expected
275263
result when the evidence does not clear the reusable-procedure bar.
@@ -294,8 +282,8 @@ build a retry loop around automatic capture.
294282

295283
### Too many low-value captures appear
296284

297-
Switch to `propose` to review every capture, or `off` to keep only the suggestion
298-
nudge:
285+
Switch to `propose` to review every capture, or `off` to disable autonomous
286+
capture:
299287

300288
```bash
301289
openclaw config set skills.workshop.autonomous.mode propose

‎docs/tools/skill-workshop.md‎

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,14 @@ Skill Workshop tool, so run proposal review actions from a normal host-side
266266
agent session or the CLI.
267267
</Note>
268268

269-
## Suggested skills
269+
## Self-learning
270270

271-
OpenClaw detects durable instructions such as “next time,” “remember to,” and reactive corrections
272-
when an interactive turn ends, including failed turns. On the next turn, the agent offers to save
273-
the most recent detected workflow through `skill_workshop`; the user decides whether to create a
274-
proposal. This built-in suggestion does not create or change a skill by itself. Set
275-
`skills.workshop.autonomous.mode` to `propose` to create pending proposals directly, or to `auto`
276-
to apply scanner-approved captures through the normal Workshop service. The Control UI Workshop
277-
tab shows whether self-learning is on; use the config setting to choose all three modes.
271+
After substantial work, an isolated background review can turn corrections and
272+
successful procedures into Workshop proposals; see
273+
[Self-learning](/tools/self-learning). Set `skills.workshop.autonomous.mode` to
274+
`propose` to create pending proposals, or to `auto` to apply scanner-approved
275+
captures through the normal Workshop service. The Control UI Workshop tab shows
276+
whether self-learning is on; use the config setting to choose all three modes.
278277

279278
### Scan past sessions
280279

@@ -303,10 +302,12 @@ are stored in the shared OpenClaw state database; transcript content is not copi
303302
into scan state.
304303

305304
In `propose` and `auto` modes, OpenClaw can also perform a conservative review after successful,
306-
substantial work and after the whole agent system becomes idle. That isolated review can create or
307-
revise at most one pending proposal. It cannot update a live skill or apply, reject, or quarantine a
308-
proposal. In `auto` mode, the orchestrating capture pipeline applies the result afterward through
309-
the normal scanner-gated service.
305+
substantial work and after the whole agent system becomes idle. That isolated review can draft at
306+
most one pending proposal — a new skill, an update to an existing workspace skill, or a revision
307+
of a pending proposal. It never writes a live skill directly and cannot apply, reject, or
308+
quarantine a proposal. In `auto` mode, the orchestrating capture pipeline applies a new-skill
309+
result afterward through the normal scanner-gated service; update proposals always stay pending
310+
for operator review.
310311

311312
See [Self-learning](/tools/self-learning) for enablement, eligibility, privacy and cost details,
312313
the proposal threshold, and troubleshooting.
@@ -331,23 +332,20 @@ the proposal threshold, and troubleshooting.
331332

332333
| Setting | Default | Effect |
333334
| -------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
334-
| `autonomous.mode` | `"auto"` | `"off"` keeps the suggestion nudge, `"propose"` creates pending captures, and `"auto"` applies captures through the normal Workshop scanner and apply path. |
335+
| `autonomous.mode` | `"auto"` | `"off"` disables autonomous capture, `"propose"` creates pending captures, and `"auto"` applies captures through the normal Workshop scanner and apply path. |
335336
| `allowSymlinkTargetWrites` | `false` | Lets apply write through workspace skill symlinks whose real target is listed in `skills.load.allowSymlinkTargets`. |
336337
| `approvalPolicy` | `"auto"` | `"auto"` skips an additional prompt for agent-initiated `apply`, `reject`, or `quarantine` (the agent still has to call the action). `"pending"` requires approval. |
337338
| `maxPending` | `50` | Caps pending and quarantined proposals per workspace (1-200). |
338339
| `maxSkillBytes` | `40000` | Caps proposal body size in bytes (1024-200000). |
339340

340-
Autonomous capture in `propose` and `auto` modes recognizes prospective rules (for example, “from now on”) and reactive
341-
corrections (for example, “that’s not what I asked”). It groups new instructions by topic into up
342-
to three proposals per turn, routes vocabulary matches to existing writable workspace skills, and
343-
revises its own pending proposal when another correction targets the same skill.
344-
345-
For successful substantial work without an explicit correction, an isolated run of the selected
346-
model decides whether the completed trajectory clears the conservative proposal bar. The
347-
foreground model is not prompted to learn before it replies. The background reviewer preserves the
348-
foreground run as proposal provenance, cannot access general agent tools, and cannot make lifecycle
349-
decisions. In `auto` mode, the capture pipeline applies the resulting pending proposal only after
350-
the isolated run completes. The review starts only when the foreground runtime reports its resolved model
341+
In `propose` and `auto` modes, an isolated run of the selected model decides whether the
342+
completed trajectory clears the conservative proposal bar. The foreground model is not prompted
343+
to learn before it replies. The background reviewer preserves the foreground run as proposal
344+
provenance, cannot access general agent tools, and cannot make lifecycle decisions. In `auto`
345+
mode, the capture pipeline applies a resulting new-skill proposal only after the isolated run
346+
completes; update proposals targeting an existing skill always stay pending for operator review,
347+
because the reviewer drafts them without reading the live skill body. The review starts only when
348+
the foreground runtime reports its resolved model
351349
and that `skill_workshop` was actually available. Restrictive or unknown tool policy therefore
352350
fails closed and creates no proposal.
353351

‎src/agents/cli-runner.reliability.test.ts‎

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import {
4141
type UserTurnTranscriptRecorder,
4242
} from "../sessions/user-turn-transcript.js";
4343
import { createTestUserTurnTranscriptTarget } from "../sessions/user-turn-transcript.test-support.js";
44-
import { runSkillResearchAutoCapture } from "../skills/research/autocapture.js";
4544
import { captureEnv, setTestEnvValue } from "../test-utils/env.js";
4645
import { testing as cliBackendsTesting } from "./cli-backends.test-support.js";
4746
import {
@@ -92,18 +91,13 @@ vi.mock("../plugins/hook-runner-global.js", () => ({
9291
getGlobalHookRunner: vi.fn(() => null),
9392
}));
9493

95-
vi.mock("../skills/research/autocapture.js", () => ({
96-
runSkillResearchAutoCapture: vi.fn(async () => undefined),
97-
}));
98-
9994
vi.mock("../tts/tts-settings.js", () => ({
10095
buildTtsSystemPromptHint: vi.fn(() => undefined),
10196
resolveModelOverridePolicy: vi.fn(),
10297
setTtsMachinePrefsPathResolver: vi.fn(),
10398
}));
10499

105100
const mockGetGlobalHookRunner = vi.mocked(getGlobalHookRunner);
106-
const mockAutoCapture = vi.mocked(runSkillResearchAutoCapture);
107101
const hookRunnerGlobalStateKey = Symbol.for("openclaw.plugins.hook-runner-global-state");
108102
const autoCleanupTempDirs = useAutoCleanupTempDirTracker(afterEach);
109103
let sessionFileEnvSnapshot: ReturnType<typeof captureEnv> | undefined;
@@ -383,8 +377,6 @@ describe("runCliAgent reliability", () => {
383377
restoreCliRunnerTestDeps();
384378
replyRunTesting.resetReplyRunRegistry();
385379
mockGetGlobalHookRunner.mockReset();
386-
mockAutoCapture.mockReset();
387-
mockAutoCapture.mockResolvedValue(undefined);
388380
setHookRunnerForTest(null);
389381
vi.unstubAllEnvs();
390382
sessionFileEnvSnapshot?.restore();
@@ -3260,71 +3252,6 @@ describe("runCliAgent reliability", () => {
32603252
expect(resolved).toBe(true);
32613253
});
32623254

3263-
it("waits for eligible Skill Research auto-capture before resolving direct CLI runs", async () => {
3264-
let releaseAutoCapture: () => void = () => undefined;
3265-
const autoCaptureSettled = new Promise<void>((resolve) => {
3266-
releaseAutoCapture = resolve;
3267-
});
3268-
mockAutoCapture.mockReturnValueOnce(autoCaptureSettled);
3269-
3270-
supervisorSpawnMock.mockResolvedValueOnce(
3271-
createManagedRun({
3272-
reason: "exit",
3273-
exitCode: 0,
3274-
exitSignal: null,
3275-
durationMs: 50,
3276-
stdout: "hello from cli",
3277-
stderr: "",
3278-
timedOut: false,
3279-
noOutputTimedOut: false,
3280-
}),
3281-
);
3282-
3283-
const context = buildPreparedContext({ sessionKey: "agent:main:main" });
3284-
let resolved = false;
3285-
const run = runPreparedCliAgent({
3286-
...context,
3287-
params: {
3288-
...context.params,
3289-
agentId: "main",
3290-
trigger: "user",
3291-
config: {
3292-
skills: {
3293-
workshop: {
3294-
autonomous: {
3295-
mode: "propose",
3296-
},
3297-
},
3298-
},
3299-
},
3300-
},
3301-
}).then((result) => {
3302-
resolved = true;
3303-
return result;
3304-
});
3305-
3306-
await vi.waitFor(() => {
3307-
expect(mockAutoCapture).toHaveBeenCalledTimes(1);
3308-
});
3309-
await Promise.resolve();
3310-
expect(resolved).toBe(false);
3311-
expect(mockAutoCapture).toHaveBeenCalledWith(
3312-
expect.objectContaining({
3313-
ctx: expect.objectContaining({
3314-
agentId: "main",
3315-
sessionKey: "agent:main:main",
3316-
trigger: "user",
3317-
}),
3318-
}),
3319-
);
3320-
3321-
releaseAutoCapture();
3322-
await expect(run).resolves.toMatchObject({
3323-
payloads: [{ text: "hello from cli" }],
3324-
});
3325-
expect(resolved).toBe(true);
3326-
});
3327-
33283255
it("does not wait for agent_end hooks before resolving channel-backed CLI runs", async () => {
33293256
let releaseAgentEnd: () => void = () => undefined;
33303257
const agentEndSettled = new Promise<void>((resolve) => {

‎src/agents/embedded-agent-runner/run/attempt-tool-base-prepare.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export function prepareEmbeddedAttemptToolBase(params: {
254254
skillWorkshop: {
255255
env: attempt.skillWorkshopProposalEnv,
256256
proposalOnly: attempt.skillWorkshopProposalOnly,
257+
...(attempt.skillWorkshopUpdateProposals ? { updateProposals: true } : {}),
257258
...(attempt.skillWorkshopAutonomousCapture ? { autonomousCapture: true } : {}),
258259
origin: attempt.skillWorkshopOrigin,
259260
proposalMutationBudget: attempt.skillWorkshopProposalMutationBudget,

‎src/agents/embedded-agent-runner/run/params.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export type RunEmbeddedAgentParams = {
167167
skillWorkshopProposalOnly?: boolean;
168168
/** Mark proposals created by this internal review as autonomous captures. */
169169
skillWorkshopAutonomousCapture?: boolean;
170+
skillWorkshopUpdateProposals?: boolean;
170171
/** Preserve the foreground run as proposal provenance for an internal review run. */
171172
skillWorkshopOrigin?: SkillProposalOrigin;
172173
/** Run-scoped mutation budget shared across internal runner attempts. */

‎src/agents/embedded-agent-runner/run/skill-workshop-attempt-params.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export function resolveSkillWorkshopAttemptParams(
44
params: Pick<
55
RunEmbeddedAgentParams,
66
| "skillWorkshopAutonomousCapture"
7+
| "skillWorkshopUpdateProposals"
78
| "skillWorkshopOrigin"
89
| "skillWorkshopProposalEnv"
910
| "skillWorkshopProposalMutationBudget"
@@ -13,6 +14,7 @@ export function resolveSkillWorkshopAttemptParams(
1314
) {
1415
return {
1516
skillWorkshopAutonomousCapture: params.skillWorkshopAutonomousCapture,
17+
skillWorkshopUpdateProposals: params.skillWorkshopUpdateProposals,
1618
skillWorkshopProposalOnly: params.skillWorkshopProposalOnly,
1719
skillWorkshopProposalEnv: params.skillWorkshopProposalEnv,
1820
skillWorkshopOrigin: params.skillWorkshopOrigin,

0 commit comments

Comments
 (0)