fix(tools): remove tool:* prompt filtering per review feedback

LegGasai noted that filtering prompt sections by tool:* prefix is a poor
heuristic: it conflates section naming convention with presentation
semantics and would incorrectly drop tool:structured_output. The executor
collapse already enforces the boundary — a model-direct native call is
rejected as UNKNOWN_TOOL regardless of what the prompt says, so filtering
the prompt adds no security and only risks losing useful guidance.

The tool:read/tool:bash/etc sections describe capability usage patterns
that apply to both native and code presentations, and keeping them does
not reopen the native direct-call path because the executor blocks it.
This commit is contained in:
Chinesezjc
2026-08-11 02:32:24 +08:00
parent b558afc373
commit 2aef2d83fa
2 changed files with 3 additions and 16 deletions

View File

@@ -810,17 +810,6 @@ export class ToolRegistry extends Service {
if (this.defaultMode !== 'native') {
ctx.systemPrompt.section(this.sdkSection())
}
// Under `code` mode, filter out tool-specific guidance sections
// (`tool:*`) that instruct the model to call native tools directly.
// The `tools:sdk` section and SDK types remain — they teach the model
// how to call tools through `run_code`.
if (this.defaultMode === 'code') {
ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
const result = await next()
result.sections = result.sections.filter(s => !s.name.startsWith('tool:'))
return result
})
}
}
/**