refactor: stop rewriting tool descriptions; keep only system sentence rewrite

This commit is contained in:
cyhhao
2026-01-31 02:01:51 +08:00
parent fe17058700
commit 3a34746668
2 changed files with 7 additions and 17 deletions

View File

@@ -715,26 +715,15 @@ func sanitizeSystemText(text string) string {
return text
}
// sanitizeToolText is intentionally more aggressive than sanitizeSystemText because
// tool descriptions are not user chat content, and some upstreams may flag "opencode"
// strings as non-Claude-Code fingerprints.
func sanitizeToolText(text string) string {
if text == "" {
return text
}
text = sanitizeSystemText(text)
text = strings.ReplaceAll(text, "OpenCode", "Claude Code")
text = opencodeTextRe.ReplaceAllString(text, "Claude")
return text
}
func sanitizeToolDescription(description string) string {
if description == "" {
return description
}
description = toolDescAbsPathRe.ReplaceAllString(description, "[path]")
description = toolDescWinPathRe.ReplaceAllString(description, "[path]")
return sanitizeToolText(description)
// Intentionally do NOT rewrite tool descriptions (OpenCode/Claude strings).
// Tool names/skill names may rely on exact wording, and rewriting can be misleading.
return description
}
func normalizeToolInputSchema(inputSchema any, cache map[string]string) {