Skip to content

feat(learn): /learn can save lessons to the selected memory plugin - #181879

Merged
jalehman merged 4 commits into
mainfrom
openclaw-23f/learn-memory-provider
Oct 23, 2026
Merged

jalehman merged 4 commits into
mainfrom
openclaw-23f/learn-memory-provider

Conversation

@jalehman

@jalehman jalehman commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

/learn can only save lessons as Skill Workshop skills. Facts, preferences, decisions and knowledge about a person or project have nowhere to go, and Workshop's own rules tell the agent not to save those as skills. Agents without Skill Workshop can't use /learn at all.

User Impact

No change for current installs: with no memory plugin opting in, /learn sends the same prompt as today and gives the same reply when unavailable.

When the plugin that owns the memory slot opts in, /learn sends repeatable procedures to Skill Workshop and other lessons to that plugin's memory. It also works on agents where only memory is available. If neither can write, the reply now names both instead of only Skill Workshop.

Plugin developers get two optional fields on registerMemoryCapability: learnToolNames and learnGuidanceBuilder. This adds to the public plugin SDK, so it needs SDK owner review.

Why This Change Was Made

The memory plugin knows how its memory should be written, but not which of its tools the current turn's policy allows. So the plugin declares its write tools, and core runs those names, tagged with the plugin's id, through the same final tool-policy composition and runtime allowlist used for skill_workshop, so plugin-ID and group:plugins entries apply as they do to the real tools. Core then passes the surviving names to the plugin, which returns a few lines of guidance, or nothing if those tools aren't enough. Core splices the guidance into the /learn turn's user message, so the cached prompt prefix is unchanged.

Memory plugins that don't own the memory slot (for example Memory Core running as a dreaming sidecar) have both fields removed at registration, the same treatment recallToolNames already gets. /learn adds no new authority: the turn calls the plugin's tools under the access it already had. Undo is still Workshop-only.

Evidence

  • Focused tests pass: commands-learn (memory-only, combined, neither available, plugin-ID and group:plugins allow/deny, plus the existing policy and undo cases; the plugin-wide policy case fails without the fix), memory-state, registry.dual-kind-memory-gate (an unselected sidecar can't contribute the learning fields), memory-provider-registration, tool-policy-diagnostic and tool-policy-pipeline.
  • agent-tools.prefix-stability test: 8 passed.
  • pnpm tsgo:core, oxlint, oxfmt --check and git diff --check are clean.
  • pnpm plugin-sdk:surface:check: no unauthorized removals against the shipped SDK (v2026.10.5).
  • Independent review (autoreview, branch mode against origin/main, P0–P1): scoped-clean.
  • Gap: no plugin on main uses the new fields yet, so this PR doesn't change runtime behavior, and the memory path has unit-test proof only. The first user is the Knowledge plugin, landing separately. /learn with a participating plugin has not yet been run end to end through a real Gateway; that proof belongs with the Knowledge change. Merging should wait for an SDK owner's review and that proof.
Memory Core

Memory Core doesn't opt in here. It could declare its file tools (read, write, edit) and return a line telling the agent which topic file under memory/ each lesson goes in. Note that a write grant isn't limited to memory files, so that rule would be a prompt convention, not an enforced restriction.

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Oct 23, 2026
@jalehman
jalehman marked this pull request as ready for review October 23, 2026 19:56
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets the selected memory plugin contribute policy-filtered learning guidance to /learn alongside Skill Workshop.

Example: With a participating memory plugin, send /learn remember that I prefer American English.

  • Before: /learn only offers Skill Workshop, whose authoring rules exclude plain personal facts.
  • After: The agent receives guidance to save the preference through the selected memory plugin.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, coherent extension with the prior defect resolved; confidence in the new user flow remains limited to unit coverage.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied coverage exercises the handler with a mocked memory contribution, while the inspected Knowledge screenshots do not exercise /learn and the author explicitly defers the Gateway demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Users cannot use /learn to retain facts and preferences through their selected memory provider, and memory-only agents cannot use the command.
Reason: The supplied maintainer direction addresses a documented gap through an existing extension owner, with Knowledge as a concrete intended consumer.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: the previous policy finding is resolved, and this maintainer-directed SDK extension has a concrete intended consumer.

Priority: P2
Reviewed head: 655b63590d0a0c9bacf131859dc9025de40598b2

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The deferred demonstration should show /learn saving a record through a participating provider in combined and memory-only modes, including plugin-wide policy filtering; the previous-head regression failure is reported but was not independently run.
Agent review details

How this fits together

The foreground command handler combines registered memory guidance with conversation tool policy and rewrites the current user turn for execution through existing agent tools.

flowchart TD
  A[User learn command] --> B[Authorized command handler]
  C[Selected memory capability] --> B
  D[Conversation tool policy] --> B
  B --> E[Rewritten user turn]
  E --> F[Agent execution]
  F --> G[Workshop or memory tools]
Loading

Technical review

Best possible solution:

Keep learning orchestration in the existing command and let the selected memory plugin supply guidance for its existing tools.

Do we have a high-confidence way to reproduce the issue?

Current-main source confirms the Workshop-only limitation; this is a capability addition, and no target code was executed during review.

Is this the best way to solve the issue?

The extension fits the existing memory-slot and command owners, preserves Workshop-only behavior, and now supplies ownership metadata to the shared policy filter.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a8aee07e3870.

Provenance checked

  • Foreground learning orchestration keeps the original intent (feat(commands): add /learn to draft skills from recent work #100442: Turn recent successful work into a skill through a server-built instruction executed by the normal agent turn; subsequent refactors retained this ownership.)
  • Skill versus memory destination changes intended behavior with a stated reason (improve(skills): learned skills keep repeatable procedures, not facts or codebase knowledge #167404: Learned skills intentionally contain repeatable procedures rather than plain facts or repository-specific knowledge; this PR explicitly adds memory routing while retaining the skill restrictions.)
  • Selected memory slot ownership keeps the original intent (32339db: Provider-owned persistence belongs to the selected memory slot owner, while unselected sidecars retain consolidation contributions.)
  • Availability policy composition keeps the original intent (133ca4b: Reuse production policy composition with lightweight probes instead of constructing tools with unrelated setup or storage effects.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 32339db adds src/plugins/memory-state.ts:68 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 32339db16b0d; files: src/plugins/memory-state.ts)
  • Peter Steinberger: Raw commit 62ecc23 adds src/auto-reply/reply/commands-learn.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 62ecc2306c90; files: src/auto-reply/reply/commands-learn.ts)
  • Ayaan Zaidi: Raw commit c7a0bc9 adds src/auto-reply/reply/commands-learn.ts:168 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c7a0bc9a9713; files: src/auto-reply/reply/commands-learn.ts)

PR surface

Source +122, Tests +89, Docs +16. Total +227 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 165 43 +122
Tests 2 90 1 +89
Docs 2 18 2 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 273 46 +227

Review metrics

Metric Value Why it matters
Plugin SDK additions 2 optional capability fields learnToolNames and learnGuidanceBuilder extend the public registration contract without adding configuration or persisted state.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded, opt-in learning improvement with a concrete memory-plugin consumer.
  • merge-risk: 🚨 compatibility: The change adds a public memory capability contract; its additive nature, opt-in behavior, and need for SDK review are explicitly recorded.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the author-deferred Gateway demonstration with a participating memory provider, redacting credentials and non-public endpoints.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-23T20:19:27.722Z sha ba13448 :: needs changes before merge. :: [P2] Preserve plugin ownership when filtering learning tools

Reviewed October 23, 2026, 4:31 PM ET / 20:31 UTC (Revision 2).

@jalehman

Copy link
Copy Markdown
Contributor Author

Addressed the P2 in 655b635: learning-tool policy probes now carry the memory slot owner's plugin id, so plugin-ID and group:plugins allow/deny entries match them as they match the real tools. Added a regression for plugin-wide allow and deny (fails on the previous head).

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 23, 2026
@jalehman
jalehman merged commit f8d9d25 into main Oct 23, 2026
122 checks passed
@jalehman
jalehman deleted the openclaw-23f/learn-memory-provider branch October 23, 2026 22:46
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…penclaw#181879)

* feat(learn): let /learn route lessons to the selected memory plugin

* docs(learn): link the memory runtime contract instead of an unshipped plugin page

* fix(learn): apply plugin-ID and group:plugins policy to memory learning tools

* refactor(learn): type the plugin policy probe instead of casting it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant