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

System Prompt와 State Contract

~28 min · system-prompt, state, contracts

Level 0Observer
0 XP0/40 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

프롬프트는 성격 스티커가 아니야

에이전트에서 system prompt는 운영 계약서야. 모델이 어떤 역할인지, 어떤 도구가 있는지, 언제 도구를 쓰는지, 불확실성을 어떻게 처리하는지, 무엇을 escalation해야 하는지, downstream code가 어떤 output shape을 기대하는지 알려준다.

애매한 system prompt는 tool choice를 감으로 만든다. 좋은 prompt는 에이전트의 결정을 읽을 수 있게 만든다.

State는 안정된 모양에 둬

“사용자는 짧은 답을 좋아한다는 걸 기억해” 같은 숨은 분위기에 기대지 마. 안정적인 사실은 memory에, run-specific state는 보이는 scratchpad나 structured run object에, policy는 code와 prompt에 둬.

모델은 지저분한 텍스트도 읽을 수 있지만 executor는 그러면 안 돼. pending approval, budget used, completed steps, current plan은 structured field로 관리해.

Escalation rule은 명시해야 한다

에이전트가 언제 사람에게 물어야 하는지 정확히 적어. destructive file change, 돈 쓰기, 외부 메시지 보내기, credential 수정, high-stakes 불확실성, budget 초과 같은 것들. 그리고 이 규칙을 코드에서도 강제해.

Code

Agent system prompt template·text
You are a repo maintenance agent.

Capabilities:
- read_file: inspect project files.
- apply_patch: propose bounded edits.
- run_tests: run approved test commands.

Rules:
1. Inspect before editing.
2. Use the smallest tool that answers the question.
3. Ask for approval before destructive, external, or credential-related actions.
4. If a tool fails, report the error and choose a recovery path.
5. Stop when the acceptance criteria are met or a stop condition fires.

Output:
- Brief status updates during long runs.
- Final answer with changed files, verification, and residual risk.
Structured run state·json
{
  "goal": "fix failing checkout tests",
  "current_plan": ["inspect failure", "patch parser", "run targeted tests"],
  "completed_steps": [],
  "pending_approval": null,
  "budget": {"max_steps": 12, "steps_used": 0},
  "risk_flags": []
}

External links

Exercise

파일을 읽고 테스트를 돌릴 수 있지만 편집 전에는 반드시 물어야 하는 agent의 system prompt를 써봐. 그리고 어떤 부분은 코드에서도 강제해야 하는지 표시해.
Hint
승인 경계가 자연어에만 있으면 안전하지 않아.

Progress

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

댓글 0

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

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