Skip to content

feat(agentsapi): discover self-hosted skills - #159363

Merged
sjf-oa merged 6 commits into
mainfrom
sjf/agentsapi-self-hosted-skills
Sep 28, 2026
Merged

sjf-oa merged 6 commits into
mainfrom
sjf/agentsapi-self-hosted-skills

Conversation

@sjf-oa

@sjf-oa sjf-oa commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Self-hosted Agents API sessions need to discover skill files already installed on their executor host. This is separate from choosing the execution environment, and builds on the merged environment settings PR #158307.

Changes

  • Add plugins.entries.agentsapi.config.hostExecutorSkillDirectories, forwarding the configured paths to the official SDK's capability_directories for self-hosted sessions. OpenClaw does not copy or install skill files.
  • Accept up to 32 unique absolute POSIX, Windows drive or complete UNC paths. Runtime and manifest validation reject incomplete UNC roots, duplicate entries and . or .. path components. Preserve configured bytes without normalization.
  • Document that operators choose entire native skill directories. Native discovery does not apply OpenClaw's per-agent skill eligibility filters; Gateway function policies remain separate.
  • Include the directory list in saved-session binding checks. Changing a nonempty list requires reset; omitted and empty lists remain compatible with sessions created without directories. Hosted sessions do not receive the directories.

Evidence and limitations

Current published head: 3a871d23a27372e36c5844a5678ad48af1f211f8, based on settings merge c0196aec9eb22dde60d1d36616d9d8e6d41fcbd4 on main.

  • All six skills commits were preserved during the rebase. The four feature source/documentation files are byte-identical to the previously reviewed head; only generated configuration artifacts were reconciled with the new base. pnpm config:docs:check and git diff --check passed. No live tests were run.

  • The UNC correction is a separate commit quoting ClawSweeper's request. Independent source review found no actionable issues. Offline checks exercised the actual environment resolver and manifest pattern: four valid paths retained their bytes, six invalid paths were rejected, and runtime duplicate rejection passed. Canonical generated config documentation and whitespace checks pass.

  • Historical real self-hosted evidence used the retained native-arm64 Docker Gateway at runtime commit 63b394dce43bac184fdb078d25ea7eb3904e1567. Ordinary Slack prompts asked for a walking forecast and a faster React loader without skill names, file paths or prescribed tools. The replies followed skill-specific behavior, weather data matched real HTTP results, native turns completed, sessions returned idle and delivery/leases settled. These are functional behavior observations, not independently traced skill-file reads; normal channel history included earlier guided tests.

  • Historical saved-session proof rejected a changed directory list, preserved the native session ID and resumed that session after restoring the list. These observations predate the field rename and later rebases, so they are not exact-head live verification.

  • The maintainer has explicitly waived additional live validation and prohibited rerunning live tests, including at ClawSweeper's request. No new live test, Docker build, Gateway restart or skill-file synchronization was performed for the latest correction.

  • The settings prerequisite feat(agentsapi): configure hosted or self-hosted environments #158307 is merged. Its existing connection timeout remains unchanged. The new settings base includes the upstream repair for the prior inherited test-type errors; no unrelated CI repair is included in this PR. GitHub CI is running on the head rebased onto merged main.

Operator contract

The requested feature is to make the skills already installed in explicitly configured executor-host directories available to the native harness. Selecting a directory opts into discovery of all skills within that directory; per-agent OpenClaw eligibility filtering is outside this change. This boundary is documented in the setting and setup guide. The existing saved-session binding rule from #158307 also covers this environment option: changing a nonempty directory list requires resetting the session rather than silently reusing the previous environment. No new behavior has been added in response to review.

@clawsweeper

clawsweeper Bot commented Sep 27, 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 extensions: agentsapi size: XS labels Sep 27, 2026
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-self-hosted-skills branch 3 times, most recently from a66e3f9 to eda87c9 Compare September 27, 2026 03:14
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 1:09 AM ET / 05:09 UTC (Revision 7).

ClawSweeper review

What this changes

The Agents API plugin adds a setting that passes operator-selected executor skill directories to new self-hosted sessions, validates the paths, and documents discovery and session-reset behavior.

Merge readiness

✅ Ready for maintainer review

Keep this distinct feature PR open. Current main lacks executor skill-directory discovery, the self-hosted prerequisite is merged, and the earlier path-validation finding is resolved. The feature owner’s verified repository maintain role and written discussion establish acceptance of the documented directory-wide discovery and manual-reset tradeoffs.

Priority: P2
Reviewed head: 3a871d23a27372e36c5844a5678ad48af1f211f8

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and the prior validation issue is resolved; historical real behavior evidence is useful but does not directly prove skill-file discovery at this head.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The verified maintain-role author is exempt from the ordinary external-contributor proof gate. Historical real Slack turns exercised an earlier self-hosted runtime and showed skill-consistent replies, but did not trace a skill-file read or validate this head; the feature owner expressly waived further live tests. Existing stored bindings remain compatible because omitted or empty lists preserve the prior fingerprint input, while a changed nonempty list intentionally requires reset.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified maintain-role author is exempt from the ordinary external-contributor proof gate. Historical real Slack turns exercised an earlier self-hosted runtime and showed skill-consistent replies, but did not trace a skill-file read or validate this head; the feature owner expressly waived further live tests. Existing stored bindings remain compatible because omitted or empty lists preserve the prior fingerprint input, while a changed nonempty list intentionally requires reset.
Evidence reviewed 12 items Current main still needs the feature: At fetched main, the Agents API configuration has only the environment setting and the resolver sends no capability directories.
Introduced request path: The new optional list is validated and sent as capability_directories only for self-hosted sessions; the existing client forwards that environment in the SDK session-create request.
Prior validation finding addressed: The runtime schema and plugin manifest require a complete UNC server and share, reject dot segments and duplicate strings, and cap the list at 32.
Findings None None.
Security None None.

How this fits together

The Agents API plugin turns OpenClaw agent requests into sessions through the official OpenAI SDK. For self-hosted sessions, an operator-provided executor supplies the workspace and skill files, and the resulting agent reply returns through OpenClaw.

flowchart LR
A[Operator settings] --> B[Agents API plugin]
B --> C[Validate skill directories]
C --> D[Check saved session binding]
D --> E[OpenAI session request]
E --> F[Self-hosted executor]
F --> G[Agent reply]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +32, Docs +27, Generated 0. Total +59 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 33 1 +32
Tests 0 0 0 0
Docs 2 30 3 +27
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 6 66 7 +59

Review metrics

Metric Value Why it matters
New operator setting 1 directory-list setting; maximum 32 roots An operator's directory choice determines the native skills made discoverable to self-hosted sessions.

Technical review

Best possible solution:

Keep native skill roots as an explicit plugin setting, with the accepted whole-directory exposure and reset instructions visible to operators while preserving the hosted default.

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

Not applicable: this adds an optional capability. Source establishes the request path, while the historical real run shows skill-consistent behavior without independently tracing a skill-file read.

Is this the best way to solve the issue?

Yes. Forwarding the official SDK field from the existing plugin is a narrow solution, and the maintain-role feature owner has documented the operator-controlled discovery scope.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 02e1ac8391f8.

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review merge-risk labels are merge-risk: 🚨 security-boundary.

Label justifications:

  • P2: This is a bounded optional Agents API capability with limited blast radius.
  • merge-risk: 🚨 security-boundary: Native discovery exposes all skills in selected executor roots without OpenClaw per-agent eligibility filtering; the maintain-role feature owner explicitly accepted and documented that operator-controlled tradeoff.
  • 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. Not applicable: The verified maintain-role author is exempt from the ordinary external-contributor proof gate. Historical real Slack turns exercised an earlier self-hosted runtime and showed skill-consistent replies, but did not trace a skill-file read or validate this head; the feature owner expressly waived further live tests. Existing stored bindings remain compatible because omitted or empty lists preserve the prior fingerprint input, while a changed nonempty list intentionally requires reset.

Evidence

What I checked:

  • Current main still needs the feature: At fetched main, the Agents API configuration has only the environment setting and the resolver sends no capability directories. (extensions/agentsapi/config.ts:5, 02e1ac8391f8)
  • Introduced request path: The new optional list is validated and sent as capability_directories only for self-hosted sessions; the existing client forwards that environment in the SDK session-create request. (extensions/agentsapi/config.ts:32, 3a871d23a273)
  • Prior validation finding addressed: The runtime schema and plugin manifest require a complete UNC server and share, reject dot segments and duplicate strings, and cap the list at 32. (extensions/agentsapi/openclaw.plugin.json:20, 3a871d23a273)
  • Saved-session compatibility: Omitted or empty directory lists leave the self-hosted environment object unchanged. The existing fingerprint check rejects a changed nonempty list before creating or writing a native session; a registered-harness persistence test covers an older hosted binding. (extensions/agentsapi/agentsapi-attempt.ts:225, 3a871d23a273)
  • Documented skill visibility boundary: The general agent skill allowlist is the final OpenClaw skill set but is expressly not a host-shell authorization boundary; the PR documents that explicitly selected native executor roots bypass those eligibility filters. Public docs: docs/tools/skills.md. (docs/tools/skills.md:240, 3a871d23a273)
  • Maintainer tradeoff acceptance: GitHub reports sjf-oa with the repository maintain role. In the PR discussion, that feature owner expressly describes directory-wide native discovery without per-agent eligibility filtering, the manual-reset contract, and the decision not to run further live tests; these statements cover the current feature source.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-27T03:20:42.693Z sha eda87c9 :: needs changes before merge. :: [P2] Reject capability directories that violate the API contract
  • reviewed 2026-09-27T03:35:46.255Z sha eda87c9 :: blocked before merge. :: [P2] Reject invalid capability directories before session creation
  • reviewed 2026-09-27T16:37:47.795Z sha e167175 :: blocked before merge. :: none
  • reviewed 2026-09-27T19:35:51.661Z sha 1817455c92bc54b586b2d3aa08d2a7b3ae0a4922 :: blocked before merge. :: [P2] Require a complete UNC share before accepting a directory
  • reviewed 2026-09-27T19:56:52.507Z sha 51f121f :: needs changes before merge. :: none
  • reviewed 2026-09-28T04:11:11.253Z sha 51f121f :: blocked before merge. :: none

@sjf-oa

sjf-oa commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Live evidence: ordinary Slack requests

PASS for the two functional tasks below. These ran on a real local native-arm64 Docker Gateway with the Agents API and an existing self-hosted executor, using a leased Slack bot and its ordinary message flow. No mocks or special test mode were used.

  • Test window: 2026-09-26 20:23–20:28 PDT.
  • Actual Gateway source: 63b394dce43bac184fdb078d25ea7eb3904e1567.
  • PR head when evidence was attached: eda87c9dc9baea4fba84b9b81a2478813638b0f1.
  • This is historical runtime evidence, not validation of the current PR head. The later hostExecutorSkillDirectories rename and incorporated main changes were not rebuilt in this Gateway.

1. Walking forecast

New Slack request, with only the bot mention removed:

I'm planning a walk in London tomorrow. What's the forecast, and should I bring a raincoat?

The agent announced the weather skill and made these actual native function calls. Selected fields from the captured API items:

[
  {
    "name": "web_fetch",
    "arguments": {
      "extractMode": "text",
      "maxChars": 12000,
      "url": "https://wttr.in/London?format=j2"
    },
    "status": "completed"
  },
  {
    "name": "web_fetch",
    "arguments": {
      "extractMode": "text",
      "maxChars": 50000,
      "url": "https://wttr.in/London?format=j1"
    },
    "status": "completed"
  }
]

Corresponding tool-result fields:

[
  {
    "url": "https://wttr.in/London?format=j2",
    "status": 200,
    "truncated": false
  },
  {
    "url": "https://wttr.in/London?format=j1",
    "status": 200,
    "truncated": true
  }
]

The first call matches the installed weather skill's JSON-fetch instructions. Both requests returned HTTP 200. The second response was truncated, but retained the full requested day's forecast. The final reply's 14–22°C range, 6% midday/afternoon rain chance, 29% evening rain chance, and 21 km/h midday wind matched the returned data. The delivered Slack reply was independently read back.

Delivered forecast

Bring a lightweight raincoat, especially if you’ll be out into the evening.

London’s forecast for tomorrow, 2026-09-27, is 14–22°C, with a cloudy morning and brighter spells around midday. Rain chances are around 6% at midday and mid-afternoon, rising to 29% in the evening. Midday winds reach roughly 21 km/h. Forecast

I’d aim for 12:00–15:00 London time for the warmest, driest part of the day.

2. React loader review

New Slack request, with only the bot mention removed:

This loader for my React page feels slow. Can you review it and show a faster version that returns the same data?

async function loadDashboard() {
  const profile = await fetchProfile();
  const notifications = await fetchNotifications();
  const preferences = await fetchPreferences();
  return { profile, notifications, preferences };
}

The agent announced the React best-practices skill and delivered this refactor:

async function loadDashboard() {
  const [profile, notifications, preferences] = await Promise.all([
    fetchProfile(),
    fetchNotifications(),
    fetchPreferences(),
  ]);

  return { profile, notifications, preferences };
}

The reply correctly qualified that the requests must be independent, preserved result mapping, explained rejection behavior, and identified the skill's “Promise.all() for Independent Operations” rule with its CRITICAL impact rating. The final response was independently read back from Slack. This was a code-review task; the returned example was not executed or benchmarked.

Completion and limits

For each captured native session, the recorded state was:

{
  "turn_status": "completed",
  "turn_error": null,
  "session_status": "idle",
  "required_actions": [],
  "session_error": null
}

After both replies, the Gateway turn outbox and delivery queue were empty and no Agents API session lease remained. The Gateway stayed running without a restart; existing skill files were not changed.

The new requests supplied no skill name, file location, tool choice, or expected answer. Each used a fresh Slack thread, but the normal Gateway context still included channel history containing earlier guided skill tests. These checks establish ordinary task completion and skill-consistent behavior; they do not independently establish fresh skill discovery or a skill-file read, because the captured native items expose no file-read event. The operator helper connected the real executor; automatic webhook delivery was not exercised. The current-head saved-session upgrade/reset path remains unverified. Private Slack links, native session identifiers, host paths, and credentials are omitted from this public evidence.

@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-self-hosted-skills branch 2 times, most recently from c94a304 to 796e1db Compare September 27, 2026 16:25
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-self-hosted-skills branch from 951b015 to e167175 Compare September 27, 2026 16:30
@sjf-oa

sjf-oa commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The requested skill-directory validation is implemented in e167175. Both the manifest and runtime schema reject duplicate entries and ./.. path components before native session creation, preserving POSIX and Windows path semantics without rewriting paths. The commit directly quotes the review request.

Independent source review found no remaining mismatch between the two validators. The earlier ordinary Slack proof remains linked from the PR description with its actual runtime commit and limitations; it is not claimed as live proof of this new validation commit. No new unit tests or special test mode were used.

Please review this head as the separate skills layer above #158307. Rebases are held until that settings prerequisite merges. This is a review-only request; do not autofix, rebase, or merge the stacked PR.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@sjf-oa

sjf-oa commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Review response for current skills head 51f121f65fdddc79a9202a1484c3be2829ffe8ce:

  • Fixed the incomplete UNC-path finding in its own commit: 51f121f. Both validators now require a server and share. The commit message directly quotes the review request. Offline checks exercised the real environment resolver and manifest pattern: four valid POSIX/drive/UNC paths retained their exact bytes, six invalid paths were rejected, and runtime duplicate rejection passed. Independent source review found no additional issues.
  • The intended setting remains an explicit operator choice of native skill roots for self-hosted sessions. Native discovery scans the selected directories and does not apply OpenClaw's per-agent skill eligibility list. This is already documented in the manifest, README and runtime configuration guide. This PR does not introduce per-agent filtering or claim that skill selection is filesystem authorization.
  • The maintainer explicitly prohibited further live tests for this work, including tests requested by ClawSweeper. Additional discovery, file-read and saved-session live proof is waived. Existing real evidence stays attached with its stated source and independence limitations. Do not treat that older evidence as current-head live verification.
  • The branch now contains the settings PR's latest test-only correction. The settings dependency remains open; significant new logic changes still require maintainer approval. The previously stated no-rebase hold was explicitly lifted for this stack alignment.

Please review the corrected path validation and documented existing directory contract without requiring more live tests.

@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-environment-setting branch 2 times, most recently from acb6451 to 2ffd4ff Compare September 27, 2026 19:13
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-self-hosted-skills branch 3 times, most recently from 4b81373 to 1817455 Compare September 27, 2026 19:27
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Sep 27, 2026
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-self-hosted-skills branch from 1817455 to 51f121f Compare September 27, 2026 19:47
@sjf-oa

sjf-oa commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review head 51f121f. The UNC validation finding is fixed, and the existing maintainer response has been updated at #159363 (comment). Further live tests are explicitly prohibited; retain the documented limitations of the historical evidence.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 27, 2026
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-environment-setting branch 2 times, most recently from 617bc68 to 6ea95a5 Compare September 28, 2026 04:11
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-self-hosted-skills branch 2 times, most recently from 8a0ba72 to 325d790 Compare September 28, 2026 04:52
Base automatically changed from sjf/agentsapi-environment-setting to main September 28, 2026 04:59
sjf added 6 commits September 27, 2026 21:59
ClawSweeper request:

> The new prefix regex accepts duplicate directories and `.` or `..` segments, such as `/workspace/../skills`, then forwards them to the native request. [OpenAI's Agents API guidance](https://developers.openai.com/api/docs/guides/tools-skills) forbids those entries, so an accepted OpenClaw setting can fail only when a session starts. Validate the whole list at the plugin boundary and cover the request path.

Reject duplicate paths and dot segments in both plugin configuration validation
and the runtime schema. Preserve executor-host path semantics for POSIX and
Windows; do not normalize or rewrite configured paths.
ClawSweeper requested:
"Require a server and share in both validators and cover the request path."

Require both path components in runtime and manifest validation while
preserving configured directory bytes and existing POSIX/drive handling.
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-self-hosted-skills branch from 325d790 to 3a871d2 Compare September 28, 2026 04:59
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 28, 2026
@sjf-oa
sjf-oa enabled auto-merge (squash) September 28, 2026 05:42
@sjf-oa
sjf-oa merged commit 6bd0d91 into main Sep 28, 2026
161 of 164 checks passed
@sjf-oa
sjf-oa deleted the sjf/agentsapi-self-hosted-skills branch September 28, 2026 06:12
@sjf-oa

sjf-oa commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

MarMarLabs added a commit to MarMarLabs/openclaw that referenced this pull request Sep 28, 2026
8 upstream commits that landed while the previous merge was being checked,
including self-hosted skill discovery for agentsapi (openclaw#159363). No file
outside the generated set changed on both sides.

Two conflicts, both generated: docs/.generated/config-baseline.counts.json
and docs/.generated/config-baseline.sha256. openclaw#159363 adds two agentsapi
plugin settings, so plugin goes from 4351 to 4353. This branch keeps
channel at 3788 and core stays at 2464. Both files came from upstream and
were regenerated.

build:docker ran in a separate detached checkout of this commit outside the
nested node_modules install. Regenerating there changed those two files and
nothing else, giving the predicted counts, the upstream core and plugin
hashes, this branch's channel hash and a new combined hash. The three
generated-file checks pass there.

Upstream deleted five files in this range, none of them tests and none
touched by this branch.

Feishu: 106 files and 1853 tests in the extension project, 17 files and
312 tests in the database-workers project. The forwarder test and the
routing guards pass, 1958 tests. tsgo:core, tsgo:extensions,
tsgo:extensions:test, tsgo:test:root, the line-cap, max-lines and
assertion-safety ratchets against upstream/main, oxlint and oxfmt on the
43 changed code files all pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
* feat(agentsapi): discover self-hosted skills

* fix(agentsapi): accept absolute Windows capability paths

* docs(agentsapi): clarify skill directory binding compatibility

* refactor(agentsapi): name executor skill directories clearly

* fix(agentsapi): reject invalid executor skill directories

ClawSweeper request:

> The new prefix regex accepts duplicate directories and `.` or `..` segments, such as `/workspace/../skills`, then forwards them to the native request. [OpenAI's Agents API guidance](https://developers.openai.com/api/docs/guides/tools-skills) forbids those entries, so an accepted OpenClaw setting can fail only when a session starts. Validate the whole list at the plugin boundary and cover the request path.

Reject duplicate paths and dot segments in both plugin configuration validation
and the runtime schema. Preserve executor-host path semantics for POSIX and
Windows; do not normalize or rewrite configured paths.

* fix(agentsapi): require complete executor UNC directories

ClawSweeper requested:
"Require a server and share in both validators and cover the request path."

Require both path components in runtime and manifest validation while
preserving configured directory bytes and existing POSIX/drive handling.

---------

Co-authored-by: Sarah Fortune <[email protected]>
obviyus added a commit that referenced this pull request Nov 1, 2026
…olicies (#190036)

## Summary

- **Problem:** `modelPolicy.allow` had two grammars under one name. Operator roles accepted a model-name prefix such as `openai/gpt-*`; agent policies rejected it. Role matching used a separate glob matcher, and five other callers detected wildcards by hand (`endsWith("/*")`, `slice(0, -2)`, `startsWith`). The copies agreed today but could drift, for example on padded refs like `"openai / *"`.
- **Fix:** `src/config/model-policy-ref.ts` now owns one parser (`parseModelPolicyWildcardRef`: `provider/*`, `provider/namespace/*`, `provider/family-*`) and one matcher (`modelPolicyWildcardMatches`). Role policy matching, config validation, `isModelKeyAllowedBySet`, configured model entries, alias candidates, `models status` and the legacy Codex wildcard migration use them. The role-only parser, the role glob matcher and the role-only validation branch are deleted.
- **User impact:** agent policies now also accept model-name prefixes such as `openai/gpt-*`. Existing agent and role configs keep their meaning; no config is invalidated.

## Evidence

**Live Gateway, real operator-role identity.** Setup:
- Candidate Gateway (`openclaw.mjs gateway run` from this branch) on an isolated HOME, state and loopback port.
- `gateway.auth.mode: "trusted-proxy"` with a loopback proxy that sets `x-forwarded-user: [email protected]`.
- `gateway.roles.default: "limited"`, with `modelPolicy: { allow: ["fixture/echo-*"], deny: ["fixture/echo-restricted*"] }`.
- A loopback fake OpenAI-completions provider that logs every request.
- The client is the real `GatewayClient` (webchat mode, device identity, no token), so the proxy-verified user is its only credential.

```text
(1)+(2) sessions.patch fixture/echo-restricted       -> FORBIDDEN "Your operator role cannot use this model…"
        sessions.patch fixture/echo-restricted-mini  -> FORBIDDEN
        sessions.patch fixture/other-x               -> FORBIDDEN (outside allow)
        sessions.patch fixture/echo-main             -> ok
        agent run on that session                    -> status ok
        provider log: POST /v1/chat/completions model=echo-main   (only request; no echo-restricted* or other-x call)
(3)     live reload narrows the role: deny += "fixture/echo-main*"
        [reload] config change detected; evaluating reload (gateway.roles.definitions.limited.modelPolicy.deny)
        next agent run on the pinned echo-main session -> status error "Your operator role cannot use this model…"
        provider requests before=2 after=2 (no new provider call)
(4)     upgrade cell, same state directory:
        published [email protected] Gateway writes and serves the role config:
          echo-restricted / echo-restricted-mini / other-x -> FORBIDDEN, echo-main -> ok, provider called with echo-main
        stop; candidate `doctor --fix` (agent DB schema 25 -> 39, role config untouched); candidate Gateway on that state:
          identical sessions.patch decisions (diff: IDENTICAL), provider called only with echo-main
```

**Role policy compatibility (main vs this PR, real owner code).** One script prepared role policies through `prepareOperatorModelPolicy` on an `origin/main` checkout and on this branch. It evaluated `allows()` for 12 models under 5 policies (family deny `vendor/restricted-v1*`, family allow `vendor/gpt-*`, nested `router/anthropic/*`, padded ` VENDOR / gpt-* ` with deny `vendor/gpt-5.5*`, inherited-source deny `vendor/restricted-*`). It also captured the `main` snapshots with `captureOperatorModelPolicySnapshot` and restored them on this branch with `restoreOperatorModelPolicySnapshot`.

```text
prepared decisions, main vs PR:           0 differences / 60
main snapshots restored on PR vs main:    0 differences / 60
familyDeny on PR: vendor/restricted-v1 false, vendor/restricted-v1-mini false, vendor/restricted-v2 true, vendor/primary true
```

**Admission proof.** New case in `src/gateway/sessions-patch.operator-model-policy.test.ts` drives `projectSessionsPatchEntry` (the `sessions.patch` owner that admits a model before any run or provider request) with role policy `allow: ["fixture/*"]`, `deny: ["fixture/restricted-v1*"]`, once with the freshly prepared policy and once with a policy restored from its captured snapshot:

```text
fixture/restricted-v1       -> FORBIDDEN "operator role cannot use this model"
fixture/restricted-v1-mini  -> FORBIDDEN
fixture/allowed             -> ok; after the operator source is revoked, its commit guard -> FORBIDDEN
```

It fails with this PR's first matcher (strict length check) and passes now. Rebased onto #190019; `pnpm check:changed` and the auth-model-policy suites pass on the rebased head.

Role admission suites that consume this predicate before provider calls also pass on this branch: model fallback, CLI runner, isolated completion and image fallback operator-policy suites, plus `operator-model-policy.test.ts` (65 tests).

- New regression in `model-visibility-policy.test.ts` (agent policy `openai/gpt-5.6-*` allows `gpt-5.6-sol`, not `gpt-5.5`) fails on `origin/main` and passes here.
- Validation table adds `openai/gpt-*` (valid for agents) and rejects `openai/gpt *` and `*`.
- Focused suites pass: model visibility, config model-ref validation, operator model policy, role mutation authority, `models status`, legacy Codex model migration, configured model entries, model selection.
- Role compatibility: `modelPolicyWildcardMatches` is a plain prefix test, the same set the old role glob (`^prefix.*$`) accepted, because the parser forbids any other `*`. A new operator-policy regression (`allow: ["vendor/*"]`, `deny: ["vendor/restricted-v1*"]` must deny `vendor/restricted-v1` itself) fails on the first head of this PR and passes now. Stored role snapshots keep the same canonical wildcard keys, so restored policies match as before.
- `pnpm check:changed` (dead-code step skipped) passes; config docs baseline regenerated.

## Merge danger

Two-way door: no stored state or migration; a revert restores the narrower agent grammar. Blast radius: model policy matching for agents and operator roles. Role semantics are unchanged (same prefix rule, same normalized `provider/model` key).

Pash/Sarah check: Sarah's commits on these files (#161609, #162335, #161048, #161004, #159363, #158307, #158703, #151176, #123875) touch Agents API, Codex and Slack config help/validation entries. This PR edits only model-policy wildcard parsing, matching and help text, so their behavior is unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…olicies (openclaw#190036)

## Summary

- **Problem:** `modelPolicy.allow` had two grammars under one name. Operator roles accepted a model-name prefix such as `openai/gpt-*`; agent policies rejected it. Role matching used a separate glob matcher, and five other callers detected wildcards by hand (`endsWith("/*")`, `slice(0, -2)`, `startsWith`). The copies agreed today but could drift, for example on padded refs like `"openai / *"`.
- **Fix:** `src/config/model-policy-ref.ts` now owns one parser (`parseModelPolicyWildcardRef`: `provider/*`, `provider/namespace/*`, `provider/family-*`) and one matcher (`modelPolicyWildcardMatches`). Role policy matching, config validation, `isModelKeyAllowedBySet`, configured model entries, alias candidates, `models status` and the legacy Codex wildcard migration use them. The role-only parser, the role glob matcher and the role-only validation branch are deleted.
- **User impact:** agent policies now also accept model-name prefixes such as `openai/gpt-*`. Existing agent and role configs keep their meaning; no config is invalidated.

## Evidence

**Live Gateway, real operator-role identity.** Setup:
- Candidate Gateway (`openclaw.mjs gateway run` from this branch) on an isolated HOME, state and loopback port.
- `gateway.auth.mode: "trusted-proxy"` with a loopback proxy that sets `x-forwarded-user: [email protected]`.
- `gateway.roles.default: "limited"`, with `modelPolicy: { allow: ["fixture/echo-*"], deny: ["fixture/echo-restricted*"] }`.
- A loopback fake OpenAI-completions provider that logs every request.
- The client is the real `GatewayClient` (webchat mode, device identity, no token), so the proxy-verified user is its only credential.

```text
(1)+(2) sessions.patch fixture/echo-restricted       -> FORBIDDEN "Your operator role cannot use this model…"
        sessions.patch fixture/echo-restricted-mini  -> FORBIDDEN
        sessions.patch fixture/other-x               -> FORBIDDEN (outside allow)
        sessions.patch fixture/echo-main             -> ok
        agent run on that session                    -> status ok
        provider log: POST /v1/chat/completions model=echo-main   (only request; no echo-restricted* or other-x call)
(3)     live reload narrows the role: deny += "fixture/echo-main*"
        [reload] config change detected; evaluating reload (gateway.roles.definitions.limited.modelPolicy.deny)
        next agent run on the pinned echo-main session -> status error "Your operator role cannot use this model…"
        provider requests before=2 after=2 (no new provider call)
(4)     upgrade cell, same state directory:
        published [email protected] Gateway writes and serves the role config:
          echo-restricted / echo-restricted-mini / other-x -> FORBIDDEN, echo-main -> ok, provider called with echo-main
        stop; candidate `doctor --fix` (agent DB schema 25 -> 39, role config untouched); candidate Gateway on that state:
          identical sessions.patch decisions (diff: IDENTICAL), provider called only with echo-main
```

**Role policy compatibility (main vs this PR, real owner code).** One script prepared role policies through `prepareOperatorModelPolicy` on an `origin/main` checkout and on this branch. It evaluated `allows()` for 12 models under 5 policies (family deny `vendor/restricted-v1*`, family allow `vendor/gpt-*`, nested `router/anthropic/*`, padded ` VENDOR / gpt-* ` with deny `vendor/gpt-5.5*`, inherited-source deny `vendor/restricted-*`). It also captured the `main` snapshots with `captureOperatorModelPolicySnapshot` and restored them on this branch with `restoreOperatorModelPolicySnapshot`.

```text
prepared decisions, main vs PR:           0 differences / 60
main snapshots restored on PR vs main:    0 differences / 60
familyDeny on PR: vendor/restricted-v1 false, vendor/restricted-v1-mini false, vendor/restricted-v2 true, vendor/primary true
```

**Admission proof.** New case in `src/gateway/sessions-patch.operator-model-policy.test.ts` drives `projectSessionsPatchEntry` (the `sessions.patch` owner that admits a model before any run or provider request) with role policy `allow: ["fixture/*"]`, `deny: ["fixture/restricted-v1*"]`, once with the freshly prepared policy and once with a policy restored from its captured snapshot:

```text
fixture/restricted-v1       -> FORBIDDEN "operator role cannot use this model"
fixture/restricted-v1-mini  -> FORBIDDEN
fixture/allowed             -> ok; after the operator source is revoked, its commit guard -> FORBIDDEN
```

It fails with this PR's first matcher (strict length check) and passes now. Rebased onto openclaw#190019; `pnpm check:changed` and the auth-model-policy suites pass on the rebased head.

Role admission suites that consume this predicate before provider calls also pass on this branch: model fallback, CLI runner, isolated completion and image fallback operator-policy suites, plus `operator-model-policy.test.ts` (65 tests).

- New regression in `model-visibility-policy.test.ts` (agent policy `openai/gpt-5.6-*` allows `gpt-5.6-sol`, not `gpt-5.5`) fails on `origin/main` and passes here.
- Validation table adds `openai/gpt-*` (valid for agents) and rejects `openai/gpt *` and `*`.
- Focused suites pass: model visibility, config model-ref validation, operator model policy, role mutation authority, `models status`, legacy Codex model migration, configured model entries, model selection.
- Role compatibility: `modelPolicyWildcardMatches` is a plain prefix test, the same set the old role glob (`^prefix.*$`) accepted, because the parser forbids any other `*`. A new operator-policy regression (`allow: ["vendor/*"]`, `deny: ["vendor/restricted-v1*"]` must deny `vendor/restricted-v1` itself) fails on the first head of this PR and passes now. Stored role snapshots keep the same canonical wildcard keys, so restored policies match as before.
- `pnpm check:changed` (dead-code step skipped) passes; config docs baseline regenerated.

## Merge danger

Two-way door: no stored state or migration; a revert restores the narrower agent grammar. Blast radius: model policy matching for agents and operator roles. Role semantics are unchanged (same prefix rule, same normalized `provider/model` key).

Pash/Sarah check: Sarah's commits on these files (openclaw#161609, openclaw#162335, openclaw#161048, openclaw#161004, openclaw#159363, openclaw#158307, openclaw#158703, openclaw#151176, openclaw#123875) touch Agents API, Codex and Slack config help/validation entries. This PR edits only model-policy wildcard parsing, matching and help text, so their behavior is unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
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 extensions: agentsapi merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

2 participants