fix(messaging): show tool argument values in chat, redacting only sensitive keys
This commit is contained in:
1 parent
e100b01c52
commit
2bcfcf6ea8
4 files changed
+39
-5
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package messaging
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSummarizeToolParameters(t *testing.T) {
|
||||
tests := []struct {
|
||||
name, input, want string
|
||||
}{
|
||||
{"plain values are shown", `{"command":"git diff --stat"}`, `{"command":"git diff --stat"}`},
|
||||
{"sensitive keys are redacted", `{"api_key":"sk-1","path":"a.go"}`, `{"api_key":"[redacted]","path":"a.go"}`},
|
||||
{"nested sensitive keys are redacted", `{"headers":{"Authorization":"Bearer x"}}`, `{"headers":{"Authorization":"[redacted]"}}`},
|
||||
{"unparseable input is withheld", `not json`, `[unavailable]`},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := SummarizeToolParameters(tt.input); got != tt.want {
|
||||
t.Fatalf("SummarizeToolParameters(%s) = %s, want %s", tt.input, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -284,8 +284,6 @@ func redactToolParameters(value any, sensitive bool) any {
|
||||
typed[i] = redactToolParameters(child, sensitive)
|
||||
}
|
||||
return typed
|
||||
case string:
|
||||
return "[string]"
|
||||
default:
|
||||
return value
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user