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

System Prompt and 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

The prompt is not a personality sticker

For agents, the system prompt is an operating contract. It tells the model what role it plays, what tools exist, when to use them, how to handle uncertainty, what must be escalated, and what output shape downstream code expects.

A vague system prompt turns tool choice into vibes. A good prompt makes the agent's decisions legible.

State belongs in a stable shape

Do not rely on hidden vibes like “remember the user prefers short answers.” Put stable facts in memory. Put run-specific state in a visible scratchpad or structured run object. Put policy in code and prompt.

The model can reason over messy text, but your executor should not. Use structured fields for pending approvals, budget used, completed steps, and current plan.

Escalation rules must be explicit

Tell the agent exactly when to ask a human: destructive file changes, spending money, sending messages externally, modifying credentials, uncertain high-stakes facts, or exceeding a budget. Then enforce those rules in code.

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

Write a system prompt for an agent that can read files and run tests but must ask before editing. Then list which parts must also be enforced in code.
Hint
The approval boundary is not safe if it exists only in natural language.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.