Skip to content

fix(agent-server): Playbooks show descriptions for comma-separated allowed-tools — one bad frontmatter field no longer nulls the record (#2850) - #2851

Merged
vybe merged 1 commit into
devfrom
feature/2850-skill-allowed-tools-string
Sep 16, 2026
Merged

vybe merged 1 commit into
devfrom
feature/2850-skill-allowed-tools-string

Conversation

@trinity-ability

Copy link
Copy Markdown
Contributor

Summary

  • The agent-server skill scanner rejected Claude Code's canonical allowed-tools: Read, Bash string at the Pydantic boundary and fell back to a name-only record, so every such skill showed "No description available" in the Playbooks tab, the / popup and the chat empty state, with the warning re-firing on every request.
  • allowed-tools is now normalized: the comma-separated string and the YAML list yield the same List[str] (including Bash(git:*), and Bash(npm run lint, npm test) stays one entry). Absent/empty → null.
  • Fields are normalized one at a time: a value the record cannot represent drops that field to null and is warned once per (file, field, value); description, argument hint, automation and user-invocable survive. YAML 1.1 scalars coerce to text; argument-hint: [file] (Claude Code's idiom, a YAML list once parsed) is restored to the bracketed string.
  • allowed_tools is documented in code and in the flow doc as display metadata only — nothing enforces it.

Release note — ships in the agent base image

This fix lives in docker/base-image/agent_server/routers/skills.py. An existing instance sees it only after ./scripts/deploy/build-base-image.sh and an agent recreate (the #2213 trap). Backend and frontend are unchanged; the guide and marketplace scaffolds keep the string form, which is the Claude Code contract.

Changes

  • docker/base-image/agent_server/routers/skills.py — normalize_allowed_tools (linear depth-0 comma split, groups tracked, quotes deliberately not), FieldSkipped + per-field _field wiring, warn-once ledger _SKIPPED_FIELD_WARNED, _display_path fallback outside /home/developer
  • tests/unit/test_2850_skill_allowed_tools_forms.py — 50 tests: string/list parity, normalizer table, one-bad-field-keeps-the-rest, bracket argument hints, YAML 1.1 scalars, warn-once across scans, truncated log value, unreadable-file last resort
  • docs/memory/feature-flows/playbooks-tab.md — normalization table, error-handling rows, scanner unit tests, base-image note

Review

  • Plan reviewed (strategy + engineering + security voices); pre-landing code review and /cso --diff-style security audit run on the diff — no findings above the gate. The review's medium (apostrophe in shell text dropped the field under quote tracking) is fixed by not tracking quotes; its lows ([] hint → null, bool list items rejected) are in.

Test Plan

  • cd tests && .venv/bin/pytest unit/test_2850_skill_allowed_tools_forms.py — 50 passed
  • pytest unit/ -k "agent_server or 2850 or skills or safe_yaml" — 355 passed, 1 skipped
  • Manual: after a base-image rebuild + agent recreate, open the Playbooks tab of an agent whose SKILL.md uses allowed-tools: Read, Bash — description and argument hint render; container log shows one warning per malformed field, not one per request

Fixes #2850

🤖 Generated with Claude Code

… — one bad frontmatter field no longer nulls the skill record (#2850)

The skill scanner fed the raw `allowed-tools` frontmatter value into
`SkillInfo.allowed_tools: Optional[List[str]]`. Claude Code's canonical form
is the comma-separated string (`allowed-tools: Read, Bash`) — what the agent
guide teaches and the marketplace wizards scaffold — so Pydantic rejected the
record, the outer `except` caught it, and the fallback re-added the skill with
only its directory name. Every such skill rendered "No description available"
in the Playbooks tab, the `/` popup and the chat empty state, and the warning
re-fired on every `GET /api/skills`.

- `normalize_allowed_tools`: both spellings (`Read, Bash(git:*)` and
  `[Read, 'Bash(git:*)']`) yield the same list. Linear scan splitting on
  commas at group depth 0, so `Bash(npm run lint, npm test)` stays one entry;
  quotes are deliberately not tracked (an apostrophe in shell text must not
  drop the field). Bool / mapping / number / unbalanced group → field skipped.
- Every field is normalized on its own (`_field`), so a bad value drops THAT
  field to None and the rest survive; the outer `except` is a last resort for
  an unreadable file only. YAML 1.1 scalars (dates, numbers) coerce to text;
  `argument-hint: [file]` — Claude Code's idiom, a YAML list once parsed — is
  restored to the bracketed string.
- A skipped field is warned once per (file, field, value), then DEBUG.
- `path` falls back to the absolute path outside `/home/developer` instead
  of raising (also what made the scanner untestable under tmp_path).
- `allowed_tools` is documented as display metadata only — nothing enforces it.

Release note: the fix lives in the AGENT BASE IMAGE. Existing instances see it
only after `./scripts/deploy/build-base-image.sh` and an agent recreate (the
#2213 trap); the backend and frontend are unchanged.

Fixes #2850

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

merge-train 2026-09-16: validated at lane C (/validate-pr, /review, /cso --diff), no critical findings. The new test runs the real parser (50 passed). The earlier journey-smoke and verify-non-root failures were an npm propagation race on rolldown 1.2.9, and both re-runs are green. No file overlap with the other members, so it merges individually.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants