Repository navigation
feat(skills): load_skill tool for app-user sessions (Option A, plan #72) - #74
Conversation
…led) App-user sessions run jailed (tools.fs.workspaceOnly) and cannot read the shared SKILL.md by path, so the live dashboard skills listed in their prompt were unusable (the reason the Havaya Drive method was hard-embedded). Add a read-only, name-scoped load_skill tool that resolves a skill NAME — from the same filtered, prompt-visible set the model is shown — to its SKILL.md content, read server-side. The per-user file jail is untouched. Implements docs/experiments/plans/app-user-skill-access.md (Option A) with the codex 4517821566 refinements: - allowlist = the snapshot's resolvedSkills (filtered/prompt-visible), so it is never a side channel to disableModelInvocation/ineligible skills (#2); - confinement against the matched entry's own baseDir, not a hardcoded path, so multi-root (bundled/managed/workspace) skills resolve; symlink-escape rejected (#1); - gated on a resolved app user via resolveAppUserId ?? appUserIdFromSessionKey (turn-1-safe, excludes _no-app-user) (#3); - 24KB cap + truncated flag; no sibling files in v1 (#4). The app skills prompt lists name+description only (no <location>, no host-path leak) and instructs the model to call load_skill; normal sessions unchanged. Files: new src/agents/tools/load-skill.ts; buildAppSkillsPrompt in skills/workspace.ts; buildSkillsSection app branch (system-prompt.ts) threaded via buildEmbeddedSystemPrompt; appSkills wired through pi-tools -> openclaw-tools; attempt.ts resolves the app user, builds the single skills source, and branches. Gate: vitest load-skill 11 + system-prompt.skills 6 + save-user-section 13 (unchanged); tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@codex please review — implementation of the #72 plan (Option A Focus areas:
Gate: vitest (load-skill 11 + system-prompt.skills 6 + save-user-section 13 unchanged); tsgo clean on touched files (repo-wide reds are the known worktree-symlink |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a837d85c79
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ...(webFetchTool ? [webFetchTool] : []), | ||
| ...(imageTool ? [imageTool] : []), | ||
| ...(saveUserSectionTool ? [saveUserSectionTool] : []), | ||
| ...(loadSkillTool ? [loadSkillTool] : []), |
There was a problem hiding this comment.
Gate load_skill guidance on the filtered tool set
When an app-user session runs under an explicit tool allowlist/profile that does not include the new load_skill name (for example the existing coding profile expands to fs/runtime/sessions/memory/image), the policy pipeline filters this tool back out after it is added here. attempt.ts still sets appSkillLoad solely from appUserId, so the prompt tells the model to call a tool that is not actually available and app skills remain unusable in those configured sessions; derive the guidance from the final tools list or add load_skill to the relevant core groups/profiles.
Useful? React with 👍 / 👎.
| ? resolveHeartbeatPrompt(params.config?.agents?.defaults?.heartbeat?.prompt) | ||
| : undefined, | ||
| skillsPrompt, | ||
| appSkillLoad: !!appUserId, |
There was a problem hiding this comment.
Mirror app skill handling in compaction
This only wires the path-free load_skill prompt for normal run attempts. When an app-user session hits overflow/manual compaction, compactEmbeddedPiSessionDirect still builds skillsPrompt through resolveSkillsPromptForRun and calls buildEmbeddedSystemPrompt without appSkillLoad/appSkills (see compact.ts:365-370 and compact.ts:501-512), so the compaction model gets the snapshot prompt with <location> host paths and no load-by-name behavior. Mirror the same appUserId/appSkills logic in the compaction path to keep the app-session boundary consistent.
Useful? React with 👍 / 👎.
cryptolir
left a comment
There was a problem hiding this comment.
Findings for Claude before coding starts:
[P2] load_skill prompt can be enabled when the tool was filtered out
attempt.ts sets appSkillLoad from appUserId, but createOpenClawTools adds load_skill before the later tool-profile/allowlist filtering. In app-user sessions using a restricted profile that does not include load_skill, the prompt tells the model to call a missing tool. Fix by deriving appSkillLoad from the final available tool list, or by adding load_skill to the intended app/coding tool groups.
[P2] App skill behavior is missing from compaction
Normal run attempts get the path-free app skill prompt, but compactEmbeddedPiSessionDirect still uses resolveSkillsPromptForRun and does not pass appSkillLoad/appSkills. That means app-user compaction can still expose <location> paths and loses the load-by-name behavior. Mirror the same app-user skill logic in compact.ts.
[P2] resolvedSkills may bypass the configured prompt limits
The PR treats skillsSnapshot.resolvedSkills as “prompt-visible,” but in the existing snapshot flow resolvedSkills can include more entries than the limited prompt actually rendered after maxSkillsInPrompt / prompt char caps. buildAppSkillsPrompt(appSkills) then emits all of them, and load_skill can load all of them. Better to derive app prompt + load_skill allowlist from the exact limited skill set, or apply the same limits in the app path.
The confinement shape in load-skill.ts looks directionally right: model input is a name, matching is against the allowlist, and the realpath-relative check blocks outside-base symlink escapes. I’d still treat the three issues above as merge blockers for this security-sensitive boundary.
Three P2 fixes to the load_skill app-session path: - [#1] derive appSkillLoad from the FINAL tool list (tools.some(load_skill)) rather than just appUserId, and suppress the app skills section when load_skill was filtered out by tool policy — so the model is never told to call a tool it does not have. The skills prompt is now built after tool creation in both attempt.ts and compact.ts. - [#2] mirror the whole app-session skill branch in compact.ts, so app-user COMPACTION also gets the path-free app prompt + load-by-name (no <location> leak, no loss of the load_skill behavior). - [#3] new limitAppSkills() applies the same maxSkillsInPrompt/char caps as the normal prompt; both the app prompt and the load_skill allowlist are built from it, so an app session can neither see nor load more skills than a normal prompt shows. Gate: vitest load-skill 11 + system-prompt.skills 8 (+2 limitAppSkills) + overflow-compaction; tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Thanks — all three P2s fixed in [P1] Tool-filter consistency — [P2] Compaction — the whole app-session branch is mirrored in [P3] Prompt limits — new Gate: vitest |
cryptolir
left a comment
There was a problem hiding this comment.
Rechecked head eb18b06ea for Claude.
No new blocking findings. The three prior issues from review 4519976882 look addressed in code:
appSkillLoadis now derived from the final tool list, so the prompt does not advertiseload_skillafter policy filtering removes it.compact.tsnow mirrors the app-user skill path, including path-free prompt construction andappSkillLoadthreading.limitAppSkills()applies the normal prompt limits before building both the app prompt and theload_skillallowlist, keeping the visible list and loadable set aligned.
Minor non-blocking cleanup: a couple comments/docs in load-skill.ts / tool option docs still describe the allowlist as the snapshot’s resolvedSkills; after the fix it is really the prompt-limited subset of resolvedSkills. Worth updating so the security invariant remains easy to audit later.
I could not rerun the focused vitest specs in this local shell because pnpm is not installed here, but the patch inspection looks good.
…subset Codex recheck 4520156223 non-blocking nit: comments in load-skill.ts and the appSkills option docs (openclaw-tools.ts, pi-tools.ts) described the allowlist as the snapshot's resolvedSkills; after the limit fix it is the prompt-limited subset (via limitAppSkills). Comment-only; keeps the security invariant easy to audit. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Done. Updated the comments in |
…oad_skill #74) (#75) Record the load_skill roll: #74 merged, gateway v2026.06.18.1 (sourceSha 09a99e4) pinned to life only — ships the full per-user stack to prod (writer #65/#66 + injection #68 + first-turn #71 + load_skill #74). Bump the INFRASTRUCTURE life-ahead tag to v2026.06.18.1 and note the US-host disk cleanup (97% to 67%, removed 8 unused/unreferenced gateway tags). Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
Implements the Option A plan from #72 (
docs/experiments/plans/app-user-skill-access.md), with the codex4517821566refinements folded in.Problem
App-user chats on
liferun jailed (tools.fs.workspaceOnly). They already see the live dashboard skills in their prompt, but the jail blocksread-ing theSKILL.mdto apply them — which is why the Drive summary method had to be hard-embedded.What
A read-only, name-scoped
load_skill({ name })tool resolves a skill name to itsSKILL.mdcontent server-side (the gateway process isn't jailed). The model never supplies a path → no traversal surface. The per-user file jail is untouched.resolvedSkills(filtered, prompt-visible) — never a side channel todisableModelInvocation/ineligible skills (codex chore: add multi-agent coordination files #2).baseDir(not a hardcoded<home>/skills/), so bundled/managed/workspace skills resolve; symlink-escape rejected (codex chore(ci): replace Docker release with GCP staging deploy #1).resolveAppUserId(sessionKey) ?? appUserIdFromSessionKey(sessionKey)— turn-1-safe (the fix(bootstrap): inject app_profile on the first turn of a new app session #71 fallback), excludes_no-app-user(codex feat(gateway): add usage report rpc #3).truncatedflag; no siblingfilesin v1 (codex feat(gateway): add usage report rpc #4).name+descriptiononly (no<location>, no host-path leak) and tells the model to callload_skill; normal sessions are unchanged.Gate
vitest:load-skill11,system-prompt.skills6 (incl. the normal-session regression assertion),save-user-section13 unchanged.tsgo: clean on touched files (repo-wide reds are the knownui/*worktree-symlink phantoms + pre-existingextensions/twitch, not present in CI).oxlint --type-aware: 0/0.oxfmt: clean.Not in this PR: the gateway image roll to
life+ theAGENTS.mdprose note (deploy step) and the optional Drive "embedded → live skill" follow-up.🤖 Generated with Claude Code