Skip to content

Commit 33bc6f1

Browse files
fix(server): agent-sent skill breaks only touch the recipient's known skill names (#24667)
The whitespace-bounded mention pass broke every `$TOKEN`, so unquoted shell variables like `$BUILD_DIR` and `$HOME` gained a word joiner whenever an agent sent them. That pass now applies the same recipient-skill-name guard as the punctuation pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 10af334 commit 33bc6f1

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎apps/server/src/orchestration-v2/ThreadManagementService.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ it.effect.each([
459459
{ text: "/tmp/report.txt holds the output. SUFFIX", mode: "steer", agent: true },
460460
{ text: 'Keep "$TECH_DIR" and use ($technical-writing).', mode: "auto", agent: true },
461461
{ text: "See [$technical-writing](/skills/writing/SKILL.md).", mode: "steer", agent: true },
462+
{
463+
text: "cd $BUILD_DIR && echo $HOME then use $technical-writing now.",
464+
mode: "auto",
465+
agent: true,
466+
},
462467
{ text: "PREFIX: $technical-writing mid-sentence. SUFFIX", mode: "auto", agent: false },
463468
] as const)(
464469
"sendToThread with agent=$agent mode=$mode keeps skill dispatch only for the user: $text",
@@ -545,7 +550,9 @@ it.effect.each([
545550
const dispatchesSkill =
546551
planClaudeSkillDispatch(providerText, skills) !== undefined ||
547552
/^\s*\/technical-writing(?:\s|$)/u.test(providerText) ||
548-
[...providerText.matchAll(SKILL_MENTION_PATTERN)].length > 0 ||
553+
[...providerText.matchAll(SKILL_MENTION_PATTERN)].some(
554+
([, , name]) => name === "technical-writing",
555+
) ||
549556
providerText.includes("$technical-writing");
550557
expect(dispatchesSkill).toBe(!agent && text.includes("technical-writing"));
551558
// Only a word joiner right after the skill's sigil or leading slash may change.

‎apps/server/src/orchestration-v2/ThreadManagementService.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,16 @@ import * as ServerSettings from "../serverSettings.ts";
6262

6363
export type ThreadManagementSendMode = "auto" | "queue" | "steer" | "restart";
6464

65-
// Another agent's message must not invoke the recipient's skills. A word joiner breaks mention
66-
// tokens and a leading `/name`; Codex also reads `$name` inside punctuation or `[$name](path)`,
67-
// so known skill names are broken there too. Shell vars, amounts, and paths stay byte-identical.
65+
// Another agent's message must not invoke the recipient's skills. A word joiner breaks a leading
66+
// `/name` and any mention naming one of its skills, including `$name` inside punctuation or
67+
// `[$name](path)`, which Codex also reads. Shell vars, amounts, and paths stay byte-identical.
6868
const LEADING_SLASH_COMMAND = /^\s*\/(?=[^\s/]+(?:\s|$))/u;
6969
const CODEX_SKILL_MENTION = /\$([a-zA-Z0-9_:-]+)/gu;
7070

7171
function breakAgentSkillSyntax(text: string, skillNames: ReadonlySet<string>): string {
7272
return text
73-
.replace(
74-
SKILL_MENTION_PATTERN,
75-
(match, _prefix: string, name: string) => `${match.slice(0, -name.length)}\u2060${name}`,
73+
.replace(SKILL_MENTION_PATTERN, (match, _prefix: string, name: string) =>
74+
skillNames.has(name) ? `${match.slice(0, -name.length)}\u2060${name}` : match,
7675
)
7776
.replace(CODEX_SKILL_MENTION, (match, name: string) =>
7877
skillNames.has(name) ? `$\u2060${name}` : match,

0 commit comments

Comments
 (0)