LearnThatStack Ace your next interview
AI Agents · question
Question 7 of 54

What role does the system prompt play in an agent?

beginner
← All AI Agents questions
Re-explain

The system prompt is the agent's standing instructions. It is the one block of context that stays fixed while the reason-act-observe loop rewrites everything else.

It sets the role and scope, the policy for using tools, and the rule for when to stop and answer.

Role and scope:   what you are; what you must refuse
Tool policy:      search before answering; never write without approval
Stopping rule:    stop when the task is done; ask if inputs are missing
Output format:    short markdown; cite the file you read

Two things matter in practice. Keep it stable, because a fixed prefix is what prompt caching can reuse. Keep it small: durable policy belongs here, and per-task detail belongs in the user message.

It steers the model but enforces nothing. Text arriving from a tool can still argue against it.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for AI Agents One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

  • Text from a tool result can argue against the system prompt. What is that attack, and how do you defend against it? Name prompt injection. Defenses sit outside the prompt: treat tool output as data, give least-privilege tools, require approval before writes.
  • Why would editing the system prompt on every request hurt cost and latency? Prompt caching reuses an identical prefix, so a change near the start misses the cache for everything after it.
  • Should a tool's usage rules live in the system prompt or in the tool's description? Per-tool when-and-how belongs in the description. Cross-tool policy, such as approval before any write, belongs in the system prompt.
  • The prompt says stop when the task is done. What else keeps an agent from looping forever? Limits in code: a max step count, a token or time budget, and repeated-call detection, ending in a clean stop or an escalation.
  • How would you check that a system prompt change didn't make the agent worse? A fixed set of eval tasks run before and after, scoring outcomes and tool choices, with the prompt versioned and reviewed like code.

What you can say

  1. The system prompt is the agent's standing instructions, the one part of the context that stays fixed while the loop rewrites everything else.
  2. It sets the role and scope, including what to refuse, and the tool policy, for example search before answering and never write without approval.
  3. It also says when to stop and answer, and to ask when inputs are missing, plus the output format, like short markdown that cites the file it read.
  4. In practice I keep it stable, because prompt caching can only reuse a fixed prefix, and small, so durable policy lives there and per-task detail goes in the user message.
  5. The limit is that it steers the model but enforces nothing, and text coming back from a tool can still argue against it, so anything that must never happen needs a check in code.

Weak answers to avoid

  • Treats the system prompt as a security boundary It steers but enforces nothing, and tool output can argue against it. Say which limits you enforce in code, like approval gates and scoped permissions.
  • Stuffs every task detail into the system prompt A big prompt that changes per task breaks the cached prefix and buries the policy. Keep durable rules there and put per-task detail in the user message.
  • Only says it sets the persona Role is one part. Interviewers want the tool policy and the stopping rule too, because those decide how the agent behaves inside the loop.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the AI Agents cheatsheet.

← Back to all AI Agents questions
Pro · $10/mo

47 of 54 AI Agents answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime