Why: a crash after a tool was about to run left the call unpaired, and workspace writes could not be rewound. Evidence: GOWORK=off go test ./runtime/ ./runtime/llm/ ./runtime/checkpoint/ ./runtime/telemetry/ ./runtime/tools/ ./runtime/session/ ./adapters/native/ Impact: pending calls rerun only when both the stored and current replay declarations are safe; otherwise the result is an error. Empty fallback lists and a nil checkpoint log keep the previous behavior. Refs: feature/durable-rewind Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package telemetry
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSpanOmitsPromptAndUsesAgreedName(t *testing.T) {
|
|
var body string
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Path != "/v1/traces" {
|
|
t.Errorf("path %s", r.URL.Path)
|
|
}
|
|
b, _ := io.ReadAll(r.Body)
|
|
body = string(b)
|
|
w.WriteHeader(http.StatusOK)
|
|
}))
|
|
defer srv.Close()
|
|
|
|
sp := Span{
|
|
Name: "chat", TraceID: "abc", SpanID: "def",
|
|
Start: time.Unix(0, 0), End: time.Unix(1, 0),
|
|
Attrs: map[string]string{"model": "m", "prompt": "用户的秘密提示词"},
|
|
}
|
|
if err := ExportOTLP(srv.URL, sp); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(body, `"name":"chat"`) {
|
|
t.Fatalf("span name missing: %s", body)
|
|
}
|
|
if strings.Contains(body, "用户的秘密提示词") || strings.Contains(body, "prompt") {
|
|
t.Fatalf("prompt leaked: %s", body)
|
|
}
|
|
got := publicAttrs(map[string]string{"tool": "read_file", "content": "全文"})
|
|
if _, ok := got["content"]; ok || got["tool"] != "read_file" {
|
|
t.Fatalf("%#v", got)
|
|
}
|
|
}
|