Stop base64 encoding LLM responses in debug output
This commit is contained in:
@@ -3700,7 +3700,8 @@ func assertDistinctRoots(t *testing.T, roots ...string) {
|
||||
}
|
||||
}
|
||||
|
||||
var debugBase64FieldPattern = regexp.MustCompile(`"(?:content_base64|content)"\s*:\s*"([^"]*)"`)
|
||||
var debugBase64FieldPattern = regexp.MustCompile(`"content_base64"\s*:\s*"([^"]*)"`)
|
||||
var debugRawLLMResponseContentPattern = regexp.MustCompile(`"content"\s*:\s*"(?:\\.|[^"\\])*"`)
|
||||
|
||||
func assertDebugTreeDoesNotContain(t *testing.T, root string, forbidden ...string) {
|
||||
t.Helper()
|
||||
@@ -3715,7 +3716,7 @@ func assertDebugTreeDoesNotContain(t *testing.T, root string, forbidden ...strin
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
text := string(data)
|
||||
text := debugRawLLMResponseContentPattern.ReplaceAllString(string(data), `"content":"[RAW_LLM_RESPONSE]"`)
|
||||
for _, value := range forbidden {
|
||||
if strings.Contains(text, value) {
|
||||
t.Fatalf("debug artifact %q contains forbidden value %q", path, value)
|
||||
|
||||
@@ -538,7 +538,7 @@ func debugCompletionRequest(req contracts.StructuredCompletionRequest) debugStru
|
||||
|
||||
func debugCompletionResponse(response contracts.StructuredCompletionResponse) debugStructuredCompletionResponse {
|
||||
return debugStructuredCompletionResponse{
|
||||
Content: base64.StdEncoding.EncodeToString(redactSecretBytes(response.Content)),
|
||||
Content: string(response.Content),
|
||||
Provider: response.Provider,
|
||||
Model: response.Model,
|
||||
ProfileID: response.ProfileID,
|
||||
|
||||
@@ -2,7 +2,6 @@ package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -1323,9 +1322,8 @@ func TestRunDebugFailedChunkAttemptReferencesScopedLLMOutput(t *testing.T) {
|
||||
if !ok {
|
||||
t.Fatalf("scoped payload type = %T, want debugStructuredLLMCall", scoped.Payload)
|
||||
}
|
||||
wantContent := base64.StdEncoding.EncodeToString([]byte(`{"raw":true}`))
|
||||
if scopedPayload.Response.Content != wantContent {
|
||||
t.Fatalf("scoped response content = %q, want %q", scopedPayload.Response.Content, wantContent)
|
||||
if scopedPayload.Response.Content != `{"raw":true}` {
|
||||
t.Fatalf("scoped response content = %q, want raw LLM response", scopedPayload.Response.Content)
|
||||
}
|
||||
_ = recorder.envelope(t, call.CanonicalPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user