Sanitize wizard remarks and make remark parsing robust

Đang mở
#812 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
security, tooling

Hướng nghiên cứu

Bắt đầu với src/lib/agent/output-signals.ts, bao gồm AgentOutputSignals.remark() và kiểm tra echo của REMARK_INSTRUCTION, sau đó lần theo lệnh gọi analytics.capture cho WIZARD_REMARK_EVENT_NAME. Xem lại luồng remark hiện có và xác định nơi nên kiểm thử việc phân phối có cấu trúc và việc làm sạch; được xem là hoàn tất khi đã kiểm thử việc phân phối remark có kiểu, các echo và giá trị rỗng bị từ chối, cùng các analytics payload đã được làm sạch.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

The end-of-run "remark" is free-form model output that we extract from the agent's prose by string-matching a [WIZARD-REMARK] marker (AgentOutputSignals.remark() in src/lib/agent/output-signals.ts) and then ship straight to analytics:

const remark = signals.remark();
if (remark) analytics.capture(WIZARD_REMARK_EVENT_NAME, { remark });

Two problems with this:

1. It's not sanitized (security)

The remark is untrusted, model-generated text captured from output and sent to PostHog analytics with no sanitization. It can carry things we don't want to ingest verbatim: secrets/API keys the model echoed from the environment, file paths or PII, prompt-injection payloads, or control/escape characters. We should sanitize before capturing — strip control chars, redact secret-shaped tokens, cap length, and validate it looks like a single reflection line rather than arbitrary content.

2. Parsing it out of prose is flaky

Marker-scanning the agent's output stream is fragile. We've already hit failure modes:

  • The model echoes the ask itself instead of a real remark (fixed narrowly in #806 / the REMARK_INSTRUCTION echo check in remark()).
  • Only the first line after the marker is captured; multi-line or marker-mid-line output is dropped or truncated.
  • Any change to prose formatting can silently break extraction.

As noted in the thread: parsing wizard logs/output for remarks is inherently flaky and should be reworked.

Proposed direction

Move remarks off free-text prose parsing onto a structured channel — e.g. have the agent emit the remark via a dedicated tool call / structured output field instead of an inline marker, so it arrives as a typed value we don't have to regex out of the stream. Then run whatever we receive through a sanitization pass before analytics.capture.

Acceptance criteria

  • Remark content is sanitized (control chars stripped, secret-shaped tokens redacted, length-capped) before being captured to analytics.
  • Remark delivery no longer depends on regex-scanning prose — it comes through a structured/typed channel.
  • Echo-of-the-ask and empty/garbage remarks are reliably rejected.
  • Tests cover sanitization and the new extraction path.

Context: found while debugging the Windows skill-install issue; remarks broke (#806) and Vincent flagged the parsing approach as flaky and wanting a rework.

Ngôn ngữ chính
TypeScript
Star
208
Fork
58
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
76

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PostHog/wizard

Tất cả issue của PostHog/wizard

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.