Skip to content

fix: report native Claude CLI models as available - #129332

Merged
shakkernerd merged 2 commits into
mainfrom
fix/native-auth-ci
Aug 25, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
fix/native-auth-ci

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Configured Anthropic models routed through the native Claude CLI runtime were reported unavailable unless OpenClaw had a copied OAuth credential. Claude CLI owns that login, so model availability must not depend on copied bearer tokens.

This is a follow-up to #129052, which moved Claude authentication ownership back to the native CLI.

Root Cause

After #129052 removed copied Claude credentials, the legacy models.list availability path could resolve the configured CLI runtime but had no prepared ownership check that tied together:

  • the model provider
  • the CLI runtime
  • the synthetic-auth declaration
  • the active plugin that owns all three

Without that complete binding, native Claude CLI authentication could not make the configured Anthropic model selectable safely.

Changes

  • derive active plugin owners from the canonical plugin activation policy
  • use prepared metadata owner maps to require one plugin to own the provider, CLI runtime, and matching synthetic-auth reference
  • reject explicitly disabled, globally disabled, and ambiguous ownership
  • remove copied Claude credential state from the Gateway regression fixture

Verification

  • 42 focused Gateway tests
  • positive native Claude CLI availability
  • explicit and global plugin disablement
  • ambiguous runtime ownership
  • formatting
  • core typecheck
  • autoreview

Follow-up

#129374 moved the ownership resolver into the model-list auth module and removed the stale test callback after the core lint gate found a max-lines violation and an unused parameter.

Fixes #129326

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: M and removed size: S labels Aug 25, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 9:20 AM ET / 13:20 UTC.

ClawSweeper review

What this changes

The PR makes Gateway model availability honor eligible bundled native-CLI plugin metadata and presents that authentication as native rather than copied OAuth.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this active maintainer PR open for normal review. Current main still omits bundled manifest synthetic-auth references, while the branch repairs that owner-boundary gap without copying native Claude CLI credentials.

Priority: P1
Reviewed head: a25bae8a15602d566f36bebeb3da489f631db193

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused owner-boundary repair with relevant regression coverage, subject to native-login behavior proof before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports focused Gateway validation but does not include a live operator-flow artifact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports focused Gateway validation but does not include a live operator-flow artifact.
Evidence reviewed 6 items Current-main gap: Current main enumerates synthetic-auth references only from the installed-plugin index, excluding bundled manifests from this decision.
Canonical eligibility path: The branch enumerates prepared manifest records and uses the existing control-plane eligibility policy, including explicit plugin disablement.
Runtime ownership fallback: The branch only upgrades availability when the configured runtime and model provider share an eligible manifest owner.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/server-methods/models-list-result.cli-runtime-availability.test.ts

Result: FAIL (partial) — step 2 expect_output models.list CLI runtime availability: expected terminal output was not visible within 30 seconds: "models.list CLI runtime availability"

node scripts/run-vitest.mjs src/gateway/server-methods/models-list-result.cli-runtime-availability.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129332-G1fbtT/target$ node scripts/run-vitest.mjs src/gateway/server-methods/models-list-result.cli-runtime-ava
ilability.test.ts
node scripts/run-vitest.mjs src/gateway/server-methods/models-list-result.cli-runtime-availability.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129332-G1fbtT/target

[vitest] still running with no output for 30000ms.










































Assertions:

  • FAIL expect_output: models.list CLI runtime availability

How this fits together

Gateway model listing combines configured model routes with prepared plugin metadata to decide whether a model is selectable. Its availability result feeds model selection and status output, while the native CLI retains credential ownership.

flowchart LR
  A[Configured model route] --> B[Gateway model listing]
  C[Prepared plugin metadata] --> D[Eligible native runtime check]
  B --> D
  D --> E[Model availability]
  E --> F[Model selection and status]
Loading

Before merge

  • Resolve merge risk (P1) - The availability flag now treats an eligible native CLI declaration as sufficient rather than copied OAuth state; before merge, confirm a host without a usable CLI login reaches the existing visible recovery path rather than silently failing after selection.
  • Resolve merge risk (P2) - Production code is net +20 lines despite the overall net deletion; the added manifest enumeration and configured-runtime ownership fallback should remain the only two decision stages.
  • Complete next step (P2) - This active MEMBER-authored, maintainer-labeled repair should remain in normal human review rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source +20, Tests -181. Total -161 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 5 79 59 +20
Tests 8 21 202 -181
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 100 261 -161

Review metrics

Metric Value Why it matters
Production versus test delta production +79/-59 (net +20); tests +21/-202 (net -181) The branch removes credential-copy fixtures and projection code, while adding two small manifest-based availability decisions.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-auth.profile-health.test.ts, serialized state: src/auto-reply/reply/commands-status.test.ts, serialized state: src/gateway/server-methods/models-list-result.cli-runtime-availability.test.ts, unknown-data-model-change: src/commands/doctor-auth.profile-health.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove native CLI outcomes before merge (recommended)
    Add redacted Gateway evidence showing the configured model is selectable with native CLI login and has a visible recovery outcome when that login is absent.
  2. Accept declared-auth availability
    Merge with the explicit product decision that configured eligible native runtimes are listed as available even when per-list login readiness is not probed.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add redacted Gateway proof for native CLI login-present and login-absent behavior, including the expected availability and recovery semantics.

Technical review

Best possible solution:

Keep the manifest eligibility policy as the canonical source of native-runtime ownership, prove the logged-in and missing-login operator outcomes, and retain the small production increase because those two owner-boundary decisions cannot be absorbed into the removed alias projection.

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

Yes, from source: current main reads only installed-plugin index records, and its focused test expects a configured Claude CLI model to be unavailable without copied OAuth state.

Is this the best way to solve the issue?

Yes, the branch uses the prepared manifest snapshot and existing eligibility policy instead of reintroducing credential copying; the remaining need is operator-visible native-login proof.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9444aa5a0ab7.

Labels

Label changes:

  • add P1: Configured Anthropic models can be incorrectly excluded from the Gateway model-selection flow.
  • add merge-risk: 🚨 auth-provider: The PR changes how native CLI authentication is represented when deciding model availability.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports focused Gateway validation but does not include a live operator-flow artifact.

Label justifications:

  • P1: Configured Anthropic models can be incorrectly excluded from the Gateway model-selection flow.
  • merge-risk: 🚨 auth-provider: The PR changes how native CLI authentication is represented when deciding model availability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports focused Gateway validation but does not include a live operator-flow artifact.

Evidence

What I checked:

Likely related people:

  • steipete: Introduced the current main resolver file whose index-only enumeration is implicated. (role: current-history introducer; confidence: high; commits: 5af05ab1a2af; files: src/gateway/server-methods/models-list-auth-resolver.ts, src/gateway/server-methods/models-list-result.ts)
  • obviyus: Focused prior work covers Claude CLI native-auth and Gateway availability behavior. (role: native CLI availability contributor; confidence: medium; commits: f1b8082d61c1, 750a64e7cd4a; files: src/gateway/server-methods/models-list-auth-resolver.ts, extensions/anthropic/cli-auth-seam.ts)

Rank-up moves

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

  • Attach redacted Gateway evidence for the configured native CLI path with login present and absent.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@shakkernerd shakkernerd self-assigned this Aug 25, 2026
@shakkernerd shakkernerd changed the title fix: preserve native CLI model availability fix: report Claude CLI-backed models as available Aug 25, 2026
@openclaw-barnacle openclaw-barnacle Bot removed commands Command implementations agents Agent runtime and tooling labels Aug 25, 2026
@shakkernerd
shakkernerd marked this pull request as ready for review August 25, 2026 13:50
@shakkernerd
shakkernerd merged commit b008868 into main Aug 25, 2026
47 checks passed
@shakkernerd
shakkernerd deleted the fix/native-auth-ci branch August 25, 2026 13:54
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Claude CLI-backed Anthropic models now remain selectable without copying Claude credentials into OpenClaw.

@shakkernerd shakkernerd changed the title fix: report Claude CLI-backed models as available fix: report native Claude CLI models as available Aug 25, 2026
roboclaw-bot added a commit that referenced this pull request Aug 25, 2026
Move the synthetic CLI runtime resolver into the auth owner to keep the model-list file below its enforced size limit and fix the unused test callback parameter introduced by #129332 without ratcheting the lint baseline.
shakkernerd added a commit that referenced this pull request Aug 25, 2026
Moved native CLI availability ownership resolution into the model-list auth owner and removed the stale test callback, restoring lint without changing behavior.

Refs #129332.
obviyus added a commit that referenced this pull request Aug 25, 2026
…129282)

## 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).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
Configured Anthropic models routed through native Claude CLI now remain selectable without copying Claude credentials into OpenClaw, while disabled or ambiguous runtime owners remain unavailable.

Fixes openclaw#129326.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
Moved native CLI availability ownership resolution into the model-list auth owner and removed the stale test callback, restoring lint without changing behavior.

Refs openclaw#129332.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…penclaw#129282)

## 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: openclaw#123866, openclaw#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 openclaw#129332) and `checks-node-compact-small-8` (`doctor-auth.profile-health.test.ts`, Claude CLI auth from openclaw#129052) fail identically on `main` run 32857954734; `checks-node-compact-small-31` pins plugin SDK export counts (`4340` vs `4342`) that openclaw#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; openclaw#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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

[Bug]: Claude CLI-routed models are reported unavailable

1 participant