Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
3a347466
Commit
3a347466
authored
Jan 31, 2026
by
cyhhao
Browse files
refactor: stop rewriting tool descriptions; keep only system sentence rewrite
parent
fe170587
Changes
2
Show whitespace changes
Inline
Side-by-side
backend/internal/service/gateway_sanitize_test.go
View file @
3a347466
...
...
@@ -13,8 +13,9 @@ func TestSanitizeOpenCodeText_RewritesCanonicalSentence(t *testing.T) {
require
.
Equal
(
t
,
strings
.
TrimSpace
(
claudeCodeSystemPrompt
),
got
)
}
func
TestSanitizeTool
Text_RewritesOpenCod
eKeywords
(
t
*
testing
.
T
)
{
func
TestSanitizeTool
Description_DoesNotRewrit
eKeywords
(
t
*
testing
.
T
)
{
in
:=
"OpenCode and opencode are mentioned."
got
:=
sanitizeToolText
(
in
)
require
.
Equal
(
t
,
"Claude Code and Claude are mentioned."
,
got
)
got
:=
sanitizeToolDescription
(
in
)
// We no longer rewrite tool descriptions; only redact obvious path leaks.
require
.
Equal
(
t
,
in
,
got
)
}
backend/internal/service/gateway_service.go
View file @
3a347466
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment