C.W.K.
Stream
Lesson 03 of 10 · published

Prompt와 response logging — leak 안 시키고

~12 min · production, logging, privacy

Level 0수련생
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

데이터 필요한데 다 keep 못 해

Log이 debugging, eval mining, compliance에 necessary. Raw user input log이 liability — PII, regulated content, user가 실수로 paste한 secret. Discipline은 정책 허용 이상 keep 안 하면서 investigate할 만큼 log.

Log할 것

  • Prompt version, model, sampler param (항상).
  • Category당 토큰 사용량 (항상).
  • User input — sensitive면 redacted, 정책별 retention (보통 1–90일).
  • Tool call과 return — 같은 redaction rule.
  • Model output — 같은 redaction rule.
  • Output에 어떤 verifier / filter flag (항상).

어떻게 redact

  • Pre-log: regex / classifier가 email, phone number, SSN, credit card strip.
  • Aggregation: count와 category label 장기 keep; raw text 단기.
  • Retention: log tier — full text 7일, redacted 30일, aggregated indefinitely.

Code

Pre-log redaction·python
import re

PATTERNS = {
    "email": re.compile(r"[\w.+-]+@[\w-]+\.[\w.-]+"),
    "phone": re.compile(r"\b\d{3}-\d{3}-\d{4}\b"),
    "ssn":   re.compile(r"\b\d{3}-\d{2}-\d{4}\b"),
}

def redact(text: str) -> tuple[str, dict[str, int]]:
    counts = {}
    for name, p in PATTERNS.items():
        text, n = p.subn(f"[{name}]", text)
        if n: counts[name] = n
    return text, counts

External links

Exercise

한 endpoint의 log retention 정책 audit. 필요 이상으로 raw text keep하는 field 식별. Tiered retention schedule 제안.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.