Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Apply redaction/truncation to Devin Cloud GCS snapshots

shukieshah6e15376e77f3
diff --git a/cli/beacon/internal/devincloud/pull.go b/cli/beacon/internal/devincloud/pull.go
index 137cb390..1e7e4417 100644
--- a/cli/beacon/internal/devincloud/pull.go
+++ b/cli/beacon/internal/devincloud/pull.go
@@ -128,10 +128,13 @@ func emit(ev schema.Event, opts PullOptions) error {
return nil
}
+// marshalEvents builds the per-session JSONL snapshot for upload. Events are run
+// through the same redaction/truncation/size controls as the local writer so
+// the GCS snapshot never carries more raw content than the local log.
func marshalEvents(mapped []MappedEvent) ([]byte, error) {
var buf []byte
for _, me := range mapped {
- data, err := json.Marshal(me.Event)
+ data, err := json.Marshal(writer.SanitizeEvent(me.Event, writer.MaxEventBytes))
if err != nil {
return nil, err
}
diff --git a/cli/beacon/internal/devincloud/pull_test.go b/cli/beacon/internal/devincloud/pull_test.go
index 820c658f..0ee0d1fb 100644
--- a/cli/beacon/internal/devincloud/pull_test.go
+++ b/cli/beacon/internal/devincloud/pull_test.go
@@ -72,6 +72,35 @@ func TestPullOnceWritesAndUploads(t *testing.T) {
}
}
+func TestUploadSnapshotIsRedacted(t *testing.T) {
+ dir := t.TempDir()
+ up := &fakeUploader{}
+ srv := fakeDevinAPI(t, `{"items":[
+ {"session_id":"s1","status":"suspended","user_id":"user-1","created_at":1000,"updated_at":1600}
+ ],"has_next_page":false,"total":1}`, map[string]string{
+ "s1": `{"items":[
+ {"event_id":"e1","source":"user","message":"deploy with token=supersecretvalue123456","created_at":1000}
+ ],"has_next_page":false}`,
+ })
+ defer srv.Close()
+
+ _, err := PullOnce(context.Background(), testClient(t, srv), PullOptions{
+ Write: true,
+ LogPath: filepath.Join(dir, "runtime.jsonl"),
+ StatePath: filepath.Join(dir, "state.json"),
+ Upload: up,
+ UploadPrefix: "agent-traces",
+ })
+ if err != nil {
+ t.Fatalf("PullOnce: %v", err)
+ }
+ for obj, body := range up.objects {
+ if strings.Contains(string(body), "supersecretvalue123456") {
+ t.Fatalf("uploaded object %q leaked an unredacted secret:\n%s", obj, body)
+ }
+ }
+}
+
func TestPullOnceDedupsAcrossRuns(t *testing.T) {
dir := t.TempDir()
logPath := filepath.Join(dir, "runtime.jsonl")