C.W.K.
Stream
Lesson 01 of 05 · published

Stable Prefix, Variable Tail

~25 min · prompt-caching, prefix, structure

Level 0Window Watcher
0 XP0/50 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

Cache는 sameness 보상

Prompt caching은 안정적 콘텐츠가 시작에, 변동 콘텐츠가 뒤에 있을 때 best. Instructions, tool schema, reusable example, 안정적 corpus material이 prefix에 속해. 현재 사용자 질문, fresh diff, timestamp, run-specific ID는 tail에.

두 효과, 한 rule

Cost trick뿐 아니야. 좋은 context hygiene 강화 — 안정적 rule은 안정적, live input은 명백히 live. Cache-friendly shape와 attention-friendly shape가 같은 모양인 건 우연 X, 좋은 API 설계.

다음 백 turn 위해 구조화

Cache-friendly prompt는 reason 쉽고, diff 쉽고, behavior 바뀔 때 debug 쉬워. 다음 single turn 위해 설계는 초보, 다음 백 turn 위해 설계가 sustained-cost 승리.

Code

Cache-aware prompt shape·yaml
prompt:
  stable_prefix:
    - system rules
    - tool definitions
    - style contract
    - reusable examples
    - corpus snippets re-read often
  variable_tail:
    - current user request
    - latest diff
    - latest tool result
    - timestamp if truly needed
Anthropic cache_control 예·python
messages = [{
    "role": "user",
    "content": [
        {"type": "text", "text": SYSTEM_RULES,
         "cache_control": {"type": "ephemeral"}},
        {"type": "text", "text": TOOL_SCHEMAS,
         "cache_control": {"type": "ephemeral"}},
        {"type": "text", "text": current_question},
    ],
}]

External links

Exercise

긴 prompt 하나 stable prefix와 variable tail로 split. Volatile한 거 prefix에서 다 빼. provider 지원하면 prefix boundary에 cache_control breakpoint 추가.
Hint
매 request 변하면 prefix에 안 속해.

Progress

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

댓글 0

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

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