From 23922b72e6bc459de12b71b2868ddb1a528afbe3 Mon Sep 17 00:00:00 2001 From: garrytan Date: Thu, 8 Oct 2026 06:33:51 +0000 Subject: [PATCH] fix(hosts): rewrite every "Agent tool" phrasing for agent-runtime hosts The Agent-tool rewrite for hermes, gbrain, openclaw and factory keyed only on "use the Agent tool", but templates mostly say "via the Agent tool", "with the Agent tool", "multiple Agent tool calls" or "Use the Agent tool", so the Claude tool name leaked into those hosts' skills and sections. Add ordered rules after the existing key (possessive, "the Agent tool", then bare "Agent tool") mapping to sessions_spawn (gbrain/openclaw), delegate_task (hermes) and delegation (factory). No goldens change. Adopts #1935 (rewritten on current main, without the new goldens). Co-authored-by: katlun-lgtm <264247399+katlun-lgtm@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- hosts/define-host.ts | 3 +++ hosts/factory.ts | 3 +++ hosts/hermes.ts | 3 +++ test/host-config.test.ts | 27 +++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/hosts/define-host.ts b/hosts/define-host.ts index a4388a973..c361af7e9 100644 --- a/hosts/define-host.ts +++ b/hosts/define-host.ts @@ -55,6 +55,9 @@ export const EXEC_STYLE_TOOL_REWRITES: Record = { 'use the Read tool': 'use the read tool', 'use the Edit tool': 'use the edit tool', 'use the Agent tool': 'use sessions_spawn', + "Claude Code's Agent tool": 'sessions_spawn', + 'the Agent tool': 'sessions_spawn', + 'Agent tool': 'sessions_spawn', 'use the Grep tool': 'search for', 'use the Glob tool': 'find files matching', 'the Bash tool': 'the exec tool', diff --git a/hosts/factory.ts b/hosts/factory.ts index 9161d7faf..569dc1e15 100644 --- a/hosts/factory.ts +++ b/hosts/factory.ts @@ -32,6 +32,9 @@ const factory = defineHost({ 'use the Write tool': 'create this file', 'use the Read tool': 'read the file', 'use the Agent tool': 'dispatch a subagent', + "Claude Code's Agent tool": 'delegation', + 'the Agent tool': 'delegation', + 'Agent tool': 'delegation', 'use the Grep tool': 'search for', 'use the Glob tool': 'find files matching', }, diff --git a/hosts/hermes.ts b/hosts/hermes.ts index 73b9028ff..264766ad1 100644 --- a/hosts/hermes.ts +++ b/hosts/hermes.ts @@ -23,6 +23,9 @@ const hermes = defineHost({ 'use the Read tool': 'use the read_file tool', 'use the Edit tool': 'use the patch tool', 'use the Agent tool': 'use delegate_task', + "Claude Code's Agent tool": 'delegate_task', + 'the Agent tool': 'delegate_task', + 'Agent tool': 'delegate_task', 'use the Grep tool': 'search for', 'use the Glob tool': 'find files matching', 'the Bash tool': 'the terminal tool', diff --git a/test/host-config.test.ts b/test/host-config.test.ts index f1f17526f..521351fc6 100644 --- a/test/host-config.test.ts +++ b/test/host-config.test.ts @@ -26,6 +26,7 @@ import { } from '../hosts/index'; import { HOST_PATHS } from '../scripts/resolvers/types'; import { RESOLVERS } from '../scripts/resolvers'; +import { runGeneration } from '../scripts/gen-skill-docs'; const ROOT = path.resolve(import.meta.dir, '..'); const RESOLVER_NAMES = new Set(Object.keys(RESOLVERS)); @@ -790,3 +791,29 @@ describe('host renders name the host\'s own tools and identities (#2626, #2015, } }); }); + +describe('agent-runtime hosts never leak the Claude "Agent tool" name', () => { + const OUT = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-agent-tool-')); + afterAll(() => fs.rmSync(OUT, { recursive: true, force: true })); + + test.each([ + ['hermes', 'delegate_task'], + ['gbrain', 'sessions_spawn'], + ['openclaw', 'sessions_spawn'], + ['factory', 'delegation'], + ])('%s renders map every Agent tool phrasing to %s', async (host, token) => { + const result = await runGeneration({ host: host as 'hermes', outputRoot: path.join(OUT, host), contentLinkRoot: null }); + expect(result.exitCode).toBe(0); + const rendered = result.artifacts.filter(a => a.kind === 'skill' || a.kind === 'section'); + expect(rendered.length).toBeGreaterThan(20); + const leaks: string[] = []; + let mentions = 0; + for (const artifact of rendered) { + const content = fs.readFileSync(path.join(OUT, host, artifact.relativePath), 'utf8'); + if (/\bAgent tool\b/.test(content)) leaks.push(artifact.relativePath); + if (content.includes(`via ${token}`)) mentions++; + } + expect(leaks).toEqual([]); + expect(mentions).toBeGreaterThan(0); + }, 120_000); +});