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>
This commit is contained in:
committed 2026-10-08 06:33:51 +00:00
1 parent f6cb9d7fe0
commit 23922b72e6
4 files changed
+36

No files matched your search

+3
View File
@@ -55,6 +55,9 @@ export const EXEC_STYLE_TOOL_REWRITES: Record<string, string> = {
'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',
+3
View File
@@ -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',
},
+3
View File
@@ -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',
+27
View File
@@ -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);
});