Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix(qwen): map WebSearch to web_search instead of dropping it

zakyirsyaad7695b99348a6
diff --git a/scripts/qwen-adapt-agents.js b/scripts/qwen-adapt-agents.js
index 1b47a8f90..763a922e5 100644
--- a/scripts/qwen-adapt-agents.js
+++ b/scripts/qwen-adapt-agents.js
@@ -9,8 +9,7 @@ const { normalizeAgentTools } = require('./lib/agent-tools');
// entries deliberately differ from gemini-adapt-agents.js:
//
// Edit -> edit (Gemini uses `replace`)
-// WebSearch -> dropped (Gemini has `google_web_search`; Qwen has no
-// web search tool, only `web_fetch`)
+// WebSearch -> web_search (Gemini uses `google_web_search`)
// mcp__* -> unchanged (Gemini lowercases to mcp_server_tool; Qwen
// keeps the double-underscore form)
const TOOL_NAME_MAP = new Map([
@@ -24,14 +23,16 @@ const TOOL_NAME_MAP = new Map([
['Grep', 'grep_search'],
['Glob', 'glob'],
['WebFetch', 'web_fetch'],
+ // `web_search` is a deferred tool and only resolves for providers that offer a
+ // search agent, so it is not universally present. Mapping it is still the
+ // better default than dropping it: where the provider supports it the agent
+ // gains the capability, and where it does not Qwen Code ignores an unresolvable
+ // entry in `tools:` without warning.
+ ['WebSearch', 'web_search'],
['TodoWrite', 'todo_write'],
['Task', 'agent'],
]);
-// Tools with no Qwen Code equivalent. Silently keeping them would leave an agent
-// definition advertising a capability it cannot use.
-const TOOL_NAME_DROP = new Set(['WebSearch']);
-
// Qwen Code supports `color:`, but only this palette. An unlisted value is
// dropped at load time with a SUBAGENT_MANAGER warning, so remap where the
// intent is clear and drop the rest rather than shipping a field that warns.
@@ -48,8 +49,8 @@ function usage() {
' node scripts/qwen-adapt-agents.js [agents-dir]',
'',
"Defaults to .qwen/agents under the current working directory.",
- 'Rewrites tools: to Qwen Code tool ids, drops tools Qwen Code does not have,',
- 'and remaps color: values outside the Qwen Code palette.',
+ 'Rewrites tools: to Qwen Code tool ids and remaps color: values outside the',
+ 'Qwen Code palette.',
].join('\n');
}
@@ -94,10 +95,6 @@ function adaptToolName(toolName) {
return mapped;
}
- if (TOOL_NAME_DROP.has(toolName)) {
- return null;
- }
-
// Qwen Code keeps the mcp__server__tool shape, so MCP entries pass through.
return toolName;
}
diff --git a/tests/scripts/qwen-adapt-agents.test.js b/tests/scripts/qwen-adapt-agents.test.js
index f4273002e..e6640ee4b 100644
--- a/tests/scripts/qwen-adapt-agents.test.js
+++ b/tests/scripts/qwen-adapt-agents.test.js
@@ -70,7 +70,7 @@ function runTests() {
assert.ok(result.stdout.includes('Usage:'));
})) passed++; else failed++;
- if (test('maps Claude Code tool names to Qwen Code ids and drops WebSearch', () => {
+ if (test('maps Claude Code tool names to Qwen Code ids', () => {
const tempDir = createTempDir();
const agentsDir = path.join(tempDir, '.qwen', 'agents');
@@ -95,12 +95,11 @@ function runTests() {
assert.ok(result.stdout.includes('Updated 1 agent file(s)'));
const updated = readAgent(agentsDir, 'gan-planner.md');
- // Edit maps to `edit`, not Gemini's `replace`.
- assert.ok(updated.includes('tools: read_file, write_file, edit, run_shell_command, grep_search, glob, web_fetch'));
- // Qwen Code has no web search tool, so the entry is dropped rather than
- // left advertising a capability the agent cannot use.
+ // Edit maps to `edit`, not Gemini's `replace`. WebSearch maps to
+ // `web_search`, not Gemini's `google_web_search`.
+ assert.ok(updated.includes('tools: read_file, write_file, edit, run_shell_command, grep_search, glob, web_search, web_fetch'));
assert.ok(!updated.includes('WebSearch'));
- assert.ok(!updated.includes('web_search'));
+ assert.ok(!updated.includes('WebFetch'));
} finally {
cleanupTempDir(tempDir);
}