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); +});