Skip to content

Add Agent Skills support to Studio - #10247

Merged
danielhanchen merged 39 commits into
unslothai:mainfrom
wasimysaid:agent-skills
Sep 14, 2026
Merged

danielhanchen merged 39 commits into
unslothai:mainfrom
wasimysaid:agent-skills

Conversation

@wasimysaid

@wasimysaid wasimysaid commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • discover and validate Agent Skills from ~/.agents/skills and ~/.claude/skills, with deterministic precedence and persisted enable/disable controls
  • expose a contained, paginated read_skill tool across Studio inference paths and add authenticated skill management APIs
  • add the Agent Skills dialog, @ mention picker for normal and compare chat, highlighted sent mentions, and standard tool activity UI

Safety

  • reject unsafe manifests, path traversal, symlinks/reparse points, oversized resources, invalid UTF-8, and file/root replacement races
  • refresh tool availability from the filesystem without coupling chat requests to the catalog API

Testing

  • pytest -q studio/backend/tests/test_skills.py (14 passed)
  • Ruff and Python compilation checks
  • frontend TypeScript typecheck
  • frontend production build
  • git diff --check
  • local Studio install and live Qwen GGUF chat verification for mention selection, read_skill, token count, responsive dialog layout, and keyboard scrolling

Before and after

Two isolated Studio installs, merge base 159207880 (BEFORE) and head d2873fa43 (AFTER), same seeded ~/.agents/skills/probe-alpha/SKILL.md on both sides, no model loaded.

Plus menu: BEFORE has no Agent Skills entry; AFTER lists it between MCP and Projects. GET /api/skills answers 404 on BEFORE and 200 on AFTER.

PR 10247 plus menu before and after

Agent Skills dialog: BEFORE has nothing to open; AFTER lists probe-alpha (Agents, enabled) and the bundled skill-creator (off by default) with a switch each. The empty-thread greeting differs between the halves because it is a random pick, not this PR.

PR 10247 Agent Skills dialog before and after

The @ mention picker needs a loaded tool-capable model and is not part of this pair; it was checked live with a Qwen GGUF in Chromium, Firefox and WebKit.

@danielhanchen

Copy link
Copy Markdown
Member

This also drops the bypass_permissions gate around _build_tool_action_nudge on the Codex and external tool paths in studio/backend/routes/inference.py, so the general tool nudge now goes into instructions on every run rather than only Full access. Could you either split that out or confirm it is intended, and say whether _enabled_agent_skills() scanning the skills roots on each tool-selection call is cached?

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T07:50:44.650978Z b2350ba Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c5938525a

ℹ️ 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".

Comment on lines +284 to +285
<div ref={resultsRef} className="max-h-64 overflow-y-auto">
{results.map((skill, index) => (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound the mention results before rendering them

In the compare composer, typing a bare @ makes results contain every enabled skill and this map eagerly renders a full button, icon, and description for each one. The backend permits 1,000 entries in each of two roots, so a valid catalog can produce 2,000 complex DOM rows and repeat the work as the query changes, causing substantial input lag or a frozen picker. Cap the displayed matches or virtualize the scrollable list.

Useful? React with 👍 / 👎.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 3fcaf423f2

ℹ️ 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".

@wasimysaid

wasimysaid commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Agent Skills — live Studio UI evidence

Tested in isolated installs at merge base 553fdf8b6 and PR head 8e570aad1, using the locally cached on-device model unsloth/Qwen3.5-4B-GGUF with Q4_K_M.

Before: typing @ produces no skill results

Before — no Agent Skills mention results

After: @ opens the Agent Skills mention picker

After — Agent Skills mention picker

After: Agent Skills management dialog

After — Agent Skills dialog

After: live read_skill tool call and model response

After — live read_skill tool call

The request used enable_tools: true with enabled_tools: ["read_skill"]. The backend parsed and executed one read_skill call, returned HTTP 200, and Qwen correctly read playwright-cli/SKILL.md and reported its first heading.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 9aaed5f510

ℹ️ 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".

…, bound the picker, translate the dialog

The local token count listed read_skill and create_skill unconditionally while the
completion request gated them on an enabled skill, so the context meter counted
schemas and a catalog nudge the request never carried. Both now use the same gate.

The mention pattern accepted any whitespace-bounded @word (@example.com, @3pm,
@Probe-Alpha), and an unknown one made every send await a full /api/skills rescan
with no deadline. The pattern now follows the Agent Skills name rules and the
settle step races the rescan against a 3 s deadline.

Mention results are capped at 50 rows, and the dialog and picker strings move into
a skills i18n namespace present in all 12 locales.
… cache the catalog per account

Discovery read the host home and the overrides file lived in the install root, so
in a shared install any managed account could list and read the owner's skills,
toggle them for everyone, and create_skill wrote into the owner's home. This also
failed the multi-account route matrix for PUT /api/skills/{name}/enabled. The
owner keeps ~/.agents/skills and ~/.claude/skills; a managed account now gets
workspace_root()/skills plus the bundled skills, its own overrides file, and
create_skill writes there. The inference catalog cache is keyed per account and
a matrix Factory covers the route.

The bundled skill-creator was enabled by default, which put read_skill and
create_skill and a catalog paragraph into every tools-on request and made the
frontend send enable_tools on every chat with every pill off. Bundled skills now
ship disabled; enabling one in the dialog is a one-click override.

The catalog scan stays inline on the request path on purpose: the api_monitor
row is already open when tools are selected and only the generation hop
finalizes it on CancelledError, so an extra await there would leave a cancelled
request's row running (test_non_streaming_safetensors_tool_task_cancel_finalizes_monitor).
The 1 s per-account cache bounds the cost. read_skill stops halving its page
below 64 characters and reports the missing room instead.
…oreign manifest, tolerate bad roots and overrides

Reads validated the resource path and the skill directory but not the root's
ancestors, while create did, so a root swapped for a symlink between selection
and open redirected read_skill outside the tree. Discovery now records each
skill directory's identity and resources are opened relative to that directory
with O_NOFOLLOW at every component.

A failed create unlinked SKILL.md after checking only the directory, so a
manifest another writer had replaced during the race was deleted. Cleanup now
closes the descriptor first and removes only the file this call created.

One unreadable or overfull root raised out of list_skills and hid every skill
including the bundled ones, and a corrupt skill-overrides.json did the same
with no in-product way to repair it. Each root now reports its own error and
an invalid overrides file is ignored and rewritten by the next toggle. Regular
files in a root are skipped, the entry limit counts skill directories only, an
indented --- inside a block scalar no longer closes the frontmatter, explicit
null tool arguments take their defaults, and Windows reserved device names get
their own message.
pre-commit-ci Bot and others added 4 commits September 14, 2026 04:01
The test replaces SKILL.md while the creating descriptor is still open. Windows
sharing semantics refuse that replace, so create reports "Could not create
skill" instead of the race message and the scenario the test guards cannot
occur there. Also restores the blank lines the merge dropped between two tests.
@danielhanchen

Copy link
Copy Markdown
Member

Thanks for the PR, this is a solid implementation and it matches the agentskills.io spec on every rule I checked (name, description, compatibility, metadata, allowed-tools, directory match). I pushed a few commits on top of 9aaed5f51 with the fixes below, grouped by area, so they are easy to read or revert.

What the commits change

cd0a02900 linked skill directories, catalog budget, shorter comments

  • A skill directory that is itself a symlink was rejected, which is how npx skills add, Zed and most dotfile setups install skills into ~/.agents/skills. Discovery now follows that one link, then pins every later read to the resolved directory, so a link swapped afterwards cannot redirect a read; dangling links, links to files and symlinked resources inside the skill are still rejected.
  • The catalog was cut at 1536 bytes with no marker, so read_skill accepted names the model had never seen. It now ends with - N more enabled skills not listed; mention one as @skill-name. when trimmed, and models of 9B and above get a 4096-byte budget (the same size split the web tip already uses).
  • Comments in the PR's code trimmed to one line each.
  • d2873fa43 adds the Windows symlink-denied guard the other symlink tests already carry; a1c3383b7 is comment wording only (AST-checked, no code change).

fbefbd7d1 skills.py: containment, cleanup, tolerance

  • Reads validated the resource path and the skill dir but not the root's ancestors, while create did. Swapping ~/.agents/skills for a symlink between selection and open redirected read_skill outside the tree (reproduced). Discovery now records each skill dir's identity and resources open relative to it with O_NOFOLLOW at every component.
  • A failed create_skill unlinked SKILL.md after checking only the directory, so a manifest another writer replaced during the race was deleted (reproduced). Cleanup closes the descriptor first and removes only the file this call created.
  • One unreadable or overfull root raised out of list_skills and hid every skill including the bundled one, and /api/skills answered 500; a corrupt skill-overrides.json did the same with no way to repair it from the UI. Each root now reports its own error, a bad overrides file is ignored and rewritten by the next toggle.
  • Regular files in a root are skipped instead of listed as broken skills, the 1000-entry limit counts skill dirs only, an indented --- inside a block scalar no longer closes the frontmatter (the P2 from the earlier review), explicit null tool args take their defaults, and Windows reserved device names get their own message.

ab9cc6daf account scoping, bundled default, per-account cache

  • Discovery used Path.home() and the overrides file lived in studio_root(), so on a shared install (Studio: per-account isolation for shared installs and the desktop app #10588) any managed account could list and read the owner's skills, toggle them for everyone, and create_skill wrote into the owner's home. This is also why test_alice_bob_matrix::test_object_route_factory_completeness was red on the PR. The owner keeps ~/.agents/skills and ~/.claude/skills; a managed account gets workspace_root()/skills plus bundled, its own overrides file, and create_skill writes there. The catalog cache is keyed per account and the matrix has a Factory for the route.
  • The bundled skill-creator shipped enabled, so on a fresh install every tools-on request gained read_skill + create_skill plus a catalog paragraph (about 430 prompt tokens), and the frontend sent enable_tools: true with every pill off. Measured live: 44 to about 800 prompt tokens on a plain "OK" turn. Bundled skills now ship disabled; enabling one in the dialog is one click and persists. With no skill enabled the request is byte-for-byte what main sends.
  • read_skill stops halving its page below 64 characters and reports the missing room instead of 7-character slivers.
  • I tried offloading the catalog scan with asyncio.to_thread and reverted it: the api_monitor row is already open when tools are selected and only the generation hop finalizes it on CancelledError, so the extra await left a cancelled request's row running (test_non_streaming_safetensors_tool_task_cancel_finalizes_monitor). The 1 s cache bounds the cost.

bfef160ab frontend

  • buildLocalTokenCountExtras listed both skill tools unconditionally while the request gated them on an enabled skill, so the context meter counted schemas and a nudge the request never carried.
  • The mention regex accepted any whitespace-bounded @word (@example.com, @3pm, @Probe-Alpha), and an unknown one made every send await a full /api/skills rescan with no deadline. The pattern now follows the skill name rules and the settle races the rescan against 3 s.
  • Picker results capped at 50 (the P2 from the earlier review), and the dialog and picker strings moved into a skills i18n namespace in all 12 locales.

Answers to the two open questions

  • The bypass_permissions gate: the general tool nudge is not added on non-Full-access runs. The path uses full_access_only=True, which returns only the Full-access sentence (still gated on full_access and has_code) plus the skill catalog, and both append helpers are no-ops on an empty string. Without an enabled skill the Codex and external prompts are byte-identical to main. What did change is that the catalog rode on every run because of the bundled default above, which is now off.
  • Caching: _enabled_agent_skills() has a 1 s TTL cache, invalidated by both skills routes and by create_skill; it is now keyed per account.

Before and after screenshots of the plus menu and the dialog are at the end of the PR description.

Verification

  • Backend, Python 3.13, CPU venv: test_skills.py 28 to 41 tests, all new tests fail on 9aaed5f51 and pass after; skills + Anthropic + multi-account + tool-loop + passthrough suites 4042 passed; the full Backend CI job selection 42305 passed with the same 4 environment-only failures as main (landlock, /dev/nvidia7, offload planner); tests/studio 8156 passed. Frontend typecheck, 7436 unit tests, production build green.
  • A 55-case simulation suite (spec conformance, CRLF/BOM/unknown keys/anchors/python tags, traversal and link cases, FIFO, 2 MB limit, unreadable and overfull roots, corrupt and legacy overrides, concurrent creates, replace-during-create, toggle-during-read, code-point pagination, tool selection matrix, catalog budget): 16 failed on the PR head, 55 pass after.
  • Live Studio (Qwen3.5-4B Q4_K_M GGUF): fresh install, install from main then updated to this branch in the same UNSLOTH_STUDIO_HOME, @mention picker with keyboard and mouse, read_skill, disable, create_skill prompt with Deny leaving nothing on disk and Allow writing 0700/0600, in Chromium, Firefox and WebKit.
  • The wheel built from the branch ships bundled_skills/skill-creator/SKILL.md.
  • Cross-platform CI on a staging repo running test_skills.py + test_anthropic_messages.py per OS: Linux x64, Linux ARM64, macOS 15 Apple Silicon, macOS 15 Intel and a live-Studio Playwright job all green; Windows x64 green at 31b0a91 (434 passed, 4 skipped; one race test that depends on POSIX replace-while-open semantics is skipped there, the code path it covers is the same), and the full six-OS set is re-running on the current head. Windows ARM64 cannot run the backend suite at all because sqlite-vec==0.1.9 in studio.txt has no ARM64 wheel; that predates this PR.

Not changed, for the record: hard links inside a skill dir are readable (same trust boundary as the directory itself, your reply stands); Tab does not pick a mention in any browser while Enter, arrow keys and click do; the plus-menu items stay English like their neighbours.

@danielhanchen

Copy link
Copy Markdown
Member

@codex security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

I checked the Codex and external nudge paths again and the general tool guidance does stay off them, but since the bundled skill-creator ships enabled the skill catalog now lands in the system prompt for every tool-enabled chat, so could you confirm what a default install sends when the user has no skills of their own? Note #9355 is also open for the same request in #9290, so it is worth the two of you comparing before either lands.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: b2350baa0e

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member

Final cross-platform run on the current head, one staging job per OS running test_skills.py + test_anthropic_messages.py, plus a live-Studio Playwright job: Linux x64, Linux ARM64, macOS 15 Apple Silicon, macOS 15 Intel, Windows x64 and Playwright all green. Windows ARM64 cannot install the backend requirements at all (sqlite-vec==0.1.9 has no ARM64 wheel), which predates this PR.

On the org CI the three Core jobs are red on this head, but they fail on main at fa16bf759 with the same tests/test_alloc_conf_platform_matrix.py cases, so that is inherited, not from this PR. Everything Studio-related that has finished is green.

Every review item since 9aaed5f51 has a fix commit and a reply, and the last review round came back clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants