Skip to content

feat: sanitize skill descriptions in the skill index - #30341

Closed
jscottmiller wants to merge 1 commit into
scott/agent-plugins/3-skillsfrom
scott/agent-plugins/3a-sanitize-skill-descriptions
Closed

jscottmiller wants to merge 1 commit into
scott/agent-plugins/3-skillsfrom
scott/agent-plugins/3a-sanitize-skill-descriptions

Conversation

@jscottmiller

Copy link
Copy Markdown
Contributor

tl;dr: Sanitize and cap every skill description rendered in the chat skill index, so a description cannot break out of the <available-skills> block.

chattool.FormatResolvedSkillIndex now passes each description through sanitizeSkillDescription: invisible runes are removed, control runes and whitespace runs collapse to one space, < and > are escaped, and the result is truncated with ... at 4096 runes for personal skills (the upload limit) or 1024 runes otherwise (the Agent Skills limit). This changes how all skill descriptions render in the skill index, not only plugin skills: existing personal and workspace skills with multi-line or tag-bearing descriptions now render as one escaped line.

The chatd architecture document gains a Skill index section. SanitizesDescriptions and CapsDescriptionsPerSource in chattool cover the behavior; the plugin cases stay in #29323.


This PR was generated by Coder Agents on behalf of @jscottmiller.

@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3-skills branch from b5c65e6 to 89aa107 Compare October 4, 2026 23:13
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3a-sanitize-skill-descriptions branch from 90ea16c to f10b3ef Compare October 4, 2026 23:13
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3-skills branch from 89aa107 to b44574d Compare October 4, 2026 23:23
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3a-sanitize-skill-descriptions branch from f10b3ef to 2f64b42 Compare October 4, 2026 23:23
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3-skills branch from b44574d to 1d22c4d Compare October 4, 2026 23:49
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3a-sanitize-skill-descriptions branch from 2f64b42 to 3e9087c Compare October 4, 2026 23:49
@jscottmiller

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-10-05 01:48 UTC by @jscottmiller

Review history
  • R1 (2026-10-05): 11 reviewers, 2 Nit, 1 P2, 5 P3, 4 P4, COMMENT. Review
  • R2 (2026-10-05), 2 Nit, 1 P2, 5 P3, 4 P4, COMMENT. Review
  • R3 (2026-10-05): 12 reviewers, 2 Nit, 2 P2, 5 P3, 7 P4, COMMENT. Review

deep-review v0.13.0 | Round 3 | 1c5c928..6c12d9e

Last posted: Round 3, 16 findings (2 P2, 5 P3, 7 P4, 2 Nit), COMMENT. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Author fixed (49d2520) skill.go:123 Rune cap counts escaped output; in-limit descriptions truncated, entity split, "never truncated" comment false R1 Netero, Gon P2, Mafu-san Note Yes
CRF-2 Note Note (body) skill.go:84 Alias not escaped; coderd relies on agent-side name validation R1 Netero No
CRF-3 P2 Author fixed (49d2520) skill.go:113 Unicode tag characters and variation selectors survive; "invisible runes are removed" is false R1 Kurapika P2, Mafuuu P3, Hisoka P3 Yes
CRF-4 P3 Author fixed (49d2520) ARCHITECTURE.md:1066 Doc frames escaping as neutralizing untrusted text; it only keeps the block well-formed R1 Pariston P3, Ryosuke Note, Kurapika Note Yes
CRF-5 P4 Author fixed (49d2520) skill.go:120 Fullwidth and small angle-bracket lookalikes pass unescaped R1 Kurapika Yes
CRF-6 P3 Author fixed (49d2520) ARCHITECTURE.md:1066 "upload limit (4096 runes)" uses wrong unit; upload limit is bytes R1 Gon P3, Mafu-san P3, Leorio P4, Mafuuu Nit, Meruem Nit Yes
CRF-7 P3 Author fixed (49d2520) skill.go:27 maxWorkspaceSkillDescriptionRunes applies to every non-personal source, including plugin R1 Gon P3, Ryosuke P4, Leorio Nit Yes
CRF-8 P3 Author fixed (49d2520) skill.go:123 No test at the cap boundary; <= to < mutation survives R1 Bisky Yes
CRF-9 P4 Author fixed (49d2520) skill.go:100 Personal cap only fires through CRF-1; test uses a description the DB rejects R1 Bisky P4, Meruem P4 Yes
CRF-10 P4 Author fixed (49d2520) skill.go:123 Hand-rolled rune truncation duplicates strutil.Truncate R1 Ryosuke P4, Kurapika Nit Yes
CRF-11 Nit Author fixed (49d2520) skill.go:107 Doc comment lists the steps the body shows instead of the guarantee R1 Gon P2 Yes
CRF-12 Nit Author fixed (49d2520) skill_test.go:191 HasPrefix + TrimPrefix instead of strings.CutPrefix R1 Ging-Go Yes
CRF-13 P4 Author fixed (6c12d9e) extending-agents.md:83 User docs do not mention description flattening, escaping, and caps R1 Leorio Yes
CRF-14 Note Dropped by orchestrator (accurate restating comments, convention only; Leorio judged test comment useful) skill.go:24, skill.go:73, skill_test.go:170 Other comments restate code R1 Gon P2 No
CRF-15 Note Dropped by orchestrator (test failure on constant change already points at the literal) skill_test.go:196 Literal 1024 duplicates unexported constant R1 Gon Nit No
CRF-16 Note Dropped by orchestrator (PR description is accurate and states the behavior change) PR description Description restates the function step by step R1 Leorio P4 No
CRF-17 Note Note (body) skill.go:121 Model sees &lt;/&gt; as literal text, e.g. List&lt;T&gt; R1 Pariston No
CRF-18 OOS Out of scope (body) codersdk/promptsanitize.go:54 isVisible keeps tag characters and variation selectors for every caller R1 Kurapika, Mafuuu, Hisoka No
CRF-19 OOS Out of scope (body) coderd/x/chatd/instruction.go:49 workspace-context content rendered raw, can close tags R1 Pariston, Ryosuke No
CRF-20 P4 Open extending-agents.md:84 User docs say control characters are removed; they become spaces R3 Netero Yes
CRF-21 Note Note (body) skill.go:111 Blanket Cf removal differs from SanitizePromptText's explicit list (drops subdivision flag tags) R3 Netero No
CRF-22 P4 Open extending-agents.md:84 Personal skills docs section says nothing about description flattening and escaping R3 Pen Botter Yes
CRF-23 P4 Open skill.go:103 SanitizePromptText call only adds U+034F removal; deleting it passes tests R3 Bisky P4, Meruem P4 Yes
CRF-24 P2 Open skill.go:110 Comment says U+200C joins scripts; it is the zero-width non-joiner and omits why a second pass exists R3 Mafu-san P2, Gon P2 Yes
CRF-25 P2 Open PR description PR description still states round 1 truncation behavior (4096 runes personal, ...) R3 Mafu-san No (body, no file line)
CRF-26 P4 Open commit 6c12d9e body Commit body parenthetical reads as if variation selectors are kept R3 Leorio No (body, no file line)
CRF-27 Note Dropped by orchestrator (comment states the output contract of the function; Leorio verified it as guarantee-style, CRF-11 fixed) skill.go:95 sanitizeSkillDescription doc comment still narrates steps R3 Gon P2 No
CRF-28 Note Dropped by orchestrator (same comment as CRF-14, no new evidence) skill.go:68 "regardless of source" comment restates purpose R3 Gon P2 No
CRF-29 Note Note (body) skill.go:108 Comment range U+E0000 to U+E007F includes 31 unassigned codepoints the code keeps R3 Mafu-san No
CRF-30 Note Note (body) ARCHITECTURE.md:1064 Alias list omits plugin//; accurate while chatd passes nil plugin skills R3 Ryosuke, Leorio No
CRF-31 OOS Out of scope (body) extending-agents.md:175-177 Personal skills docs omit the 4096-byte description limit R3 Pen Botter No

Contested and acknowledged

Round log

Round 1

Full panel (round 1). Netero: 1 P3, 1 Note. Panel: ging-go, kurapika, ryosuke, pariston, mafuuu, bisky, hisoka, gon, leorio, mafu-san, meruem (wildcard, random). 11 panel reviewers, multi-domain target (security-sensitive input handling). Result: 1 P2, 5 P3, 4 P4, 2 Nit, 2 Note (body), 3 dropped, 2 out of scope. Orchestrator corrected CRF-10 evidence: plugin.go:264 calls strutil.Truncate without TruncateWithEllipsis. Tag-character pass-through and entity split reproduced by orchestrator. Reviewed against 1d22c4d..3e9087c.

Round 2 update

BLOCKED. CRF-13 (P4, user docs) silent; 11 other open findings addressed in amended commit 49d2520 (unverified by panel). No review panel. Reviewed against 3e9087c..49d2520.

Round 3

Restructure round (docs file added to the PR diff; PR rebased onto new base 1c5c928). Churn guard PROCEED: CRF-13 addressed. Netero: reused R1 agent did not write output, spawned a new agent; 1 P4, 1 Note. Full panel: ging-go, kurapika, ryosuke, pen-botter (docs trigger), pariston, mafuuu, bisky, hisoka, gon, leorio, mafu-san, meruem (wildcard, random). 12 panel reviewers. Fixes for CRF-1, 3 to 12 verified by Netero, Kurapika, Ryosuke, Bisky (mutation), Leorio, Mafu-san. New: 2 P2, 4 P4, 3 Note (body), 2 dropped, 1 out of scope. CRF-25 and CRF-26 have no file line, posted in the review body. Reviewed against 1c5c928..6c12d9e.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot 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.

This PR sanitizes and caps skill descriptions rendered in the <available-skills> index. Findings: 1 P2, 5 P3, 4 P4, 2 Nit.

Out of scope (needs a ticket or explicit acceptance by a human):

  • codersdk/promptsanitize.go:54: isVisible keeps Unicode tag characters (U+E0000 to U+E007F) and variation selectors, so every SanitizePromptText caller (custom system prompts, workspace context files, plugin descriptions) passes hidden ASCII-encoded text to the model.
  • coderd/x/chatd/instruction.go:49: workspace context file content is written into <workspace-context> without escaping, so it can close that block and open any tag in the system prompt, which is the case this PR blocks for skill descriptions.

Notes:

  • coderd/x/chatd/chattool/skill.go:84: the alias next to each description is not escaped, and coderd does not validate workspace skill names (context_prompt.go:270-286); the index relies on the agent rejecting names that fail SkillNamePattern.
  • coderd/x/chatd/chattool/skill.go:121: the prompt is not parsed as XML, so the model reads &lt; and &gt; literally; Use for List<T> generics reaches it as List&lt;T&gt;.

docs/ai-coder/agents/extending-agents.md:83

P4 [CRF-13] The user docs say each skill contributes its name and description to <available-skills> but do not say the description is now flattened to one line, has < and > escaped, and is cut at 1024 runes for workspace skills. (Leorio)

A skill author whose long or multi-line description worked before this PR gets a truncated single line with nothing in the docs to explain it. Add one sentence after this line describing the rendering.

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/chattool/skill_test.go Resolved
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3a-sanitize-skill-descriptions branch from 3e9087c to 49d2520 Compare October 5, 2026 00:38
@jscottmiller

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot 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.

The amended commit 49d2520 changes the code for 11 of the 12 findings from the previous review. One finding has no change and no reply:

  • docs/ai-coder/agents/extending-agents.md:83 (P4, CRF-13): the user docs still say each skill contributes its name and description to <available-skills>, without saying that descriptions are now flattened to one line, have < and > escaped, and are cut at 1024 runes for non-personal skills. This finding was in the previous review body because the file is outside the diff.

The next full review runs after you add the docs sentence, file an issue for it, or reply with why the docs should not change.

🤖 This review was automatically generated with Coder Agents.

@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3-skills branch from 1d22c4d to 1c5c928 Compare October 5, 2026 01:46
@jscottmiller jscottmiller changed the title feat(coderd/x/chatd): sanitize skill descriptions in the skill index feat: sanitize skill descriptions in the skill index Oct 5, 2026
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3a-sanitize-skill-descriptions branch from 49d2520 to 6c12d9e Compare October 5, 2026 01:47
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@jscottmiller

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot 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.

This PR sanitizes and caps skill descriptions rendered in the <available-skills> index. Findings this round: 2 P2, 4 P4 (two of them, on the PR description and the commit message, are in this body because they have no file line).

The changes in 49d2520 and 6c12d9e address all 13 findings from the first review. Truncation now runs before escaping, tag characters and variation selectors are removed, the docs state what escaping does and does not guarantee, and tests check the cap boundary with inputs that upload accepts.

  • PR description (P2): it still says descriptions are "truncated with ... at 4096 runes for personal skills (the upload limit) or 1024 runes otherwise". The code no longer truncates personal descriptions, cuts other descriptions with … before escaping, and 4096 is a byte limit. Rewrite that sentence to match the commit message and mention the extending-agents.md change, since the description is what reviewers and the squash commit read.
  • Commit 6c12d9e body (P4): "(codersdk.SanitizePromptText, plus every format rune except U+200C, including Unicode tag characters, and variation selectors)" can be read as "variation selectors are kept". The code removes them. For example: "everything codersdk.SanitizePromptText strips, every format rune (Cf) except U+200C, which includes Unicode tag characters, and every variation selector."

Out of scope (needs a ticket or explicit acceptance by a human):

  • docs/ai-coder/agents/extending-agents.md:175-177: the Personal skills section gives the 64 KB file limit but not the 4096-byte description limit (coderd/x/skills/skills.go:23), so users learn about it only from the upload error.

Notes:

  • coderd/x/chatd/chattool/skill.go:108: the comment's range U+E0000 to U+E007F includes 31 unassigned codepoints (U+E0000, U+E0002 to U+E001F) that unicode.Cf does not match; they have no ASCII mapping.
  • coderd/x/chatd/ARCHITECTURE.md:1064: the alias list omits plugin/<plugin>/<name> from the new base. It is accurate while mergeTurnSkills passes nil plugin skills; the change that passes them needs to update this paragraph and the read_skill_file wording.
  • coderd/x/chatd/chattool/skill.go:111: removing all of unicode.Cf differs from the explicit list in codersdk.SanitizePromptText, which avoids blanket Cf stripping to keep subdivision flag emoji. A description with the England flag renders as a plain black flag.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/chattool/skill.go Resolved
Comment thread coderd/x/chatd/chattool/skill.go Resolved
FormatResolvedSkillIndex now sanitizes every skill description before
rendering it in the <available-skills> block, whatever the skill's
source: invisible runes are removed (everything
codersdk.SanitizePromptText strips, every format rune (Cf) except
U+200C, which includes Unicode tag characters, and every variation
selector), control runes and whitespace runs collapse to one
space, and ASCII < and > are escaped as &lt; and &gt; so a description
cannot end the block or add entries. The text is still read by the
model; this keeps the block's structure, it does not make the text
trusted. Non-personal descriptions are cut to the Agent Skills limit
of 1024 runes, ending in an ellipsis, before escaping; personal
descriptions are already bounded at 4096 bytes on upload.

This changes how personal and workspace skill descriptions render
today: a multi-line or tag-bearing description becomes one escaped
line. The chatd architecture document gains a Skill index section
covering the block, the skill tools and the sanitization, and
extending-agents.md describes how workspace and personal skill
descriptions render.
@jscottmiller
jscottmiller force-pushed the scott/agent-plugins/3a-sanitize-skill-descriptions branch from 6c12d9e to 0a8167f Compare October 5, 2026 02:08
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant