Add appended message request validation

This commit is contained in:
2026-08-26 02:10:01 +00:00
parent 5064cf833d
commit ed0f7527d5
9 changed files with 277 additions and 24 deletions

View File

@@ -220,6 +220,14 @@ func TestRunRequestFormattingRedactsDirectAPIKey(t *testing.T) {
"transcript": promptkit.InlineWithURI(inputURI, inputBody),
},
Vars: map[string]string{"audience": variableValue},
AppendedMessages: []promptkit.RenderedMessage{{
Role: "private-role-sentinel",
Content: "private-appended-content-sentinel",
CacheControl: &promptkit.CacheControl{
Type: "private-cache-sentinel",
TTL: "private-ttl-sentinel",
},
}},
}
for _, formatted := range []string{
@@ -229,7 +237,7 @@ func TestRunRequestFormattingRedactsDirectAPIKey(t *testing.T) {
fmt.Sprintf("%+v", req),
fmt.Sprintf("%#v", req),
} {
for _, privateValue := range []string{secret, inputURI, inputBody, variableValue} {
for _, privateValue := range []string{secret, inputURI, inputBody, variableValue, "private-role-sentinel", "private-appended-content-sentinel", "private-cache-sentinel", "private-ttl-sentinel"} {
if strings.Contains(formatted, privateValue) {
t.Fatalf("formatted RunRequest leaked private value %q: %s", privateValue, formatted)
}
@@ -240,6 +248,7 @@ func TestRunRequestFormattingRedactsDirectAPIKey(t *testing.T) {
"APIKeySet:true",
"Inputs:1",
"Vars:1",
"AppendedMessages:1",
} {
if !strings.Contains(formatted, summary) {
t.Fatalf("formatted RunRequest omitted structural summary %q: %s", summary, formatted)