System vs. User vs. Tool Prompts: Roles that Change Results

System vs. User vs. Tool Prompts: Roles that Change Results

Prompt Engineering: Define Scope, Roles, and Reliable Prompts

Clear prompt design reduces hallucinations, improves reliability, and speeds integration — follow this practical guide and checklist to get consistent model behavior.

Effective prompt engineering starts with clear scope and role definitions, then applies concise instructions for system, user, and tool prompts. This guide gives templates, examples, and practical checks to make models predictable and useful.

  • Define scope and success criteria before writing prompts.
  • Use system prompts for constraints, user prompts for intent, and tool prompts for integrations.
  • Test iteratively with known inputs, include failure modes, and add guardrails.

Define scope and goals

Start by answering three concrete questions: What problem will the model solve? Who are the users? What constitutes success? Keep scope narrow initially to reduce ambiguity.

  • Problem statement (one sentence): e.g., “Summarize customer emails into action items.”
  • User personas: e.g., support agents, managers, end customers.
  • Success metrics: accuracy of action items, brevity target, time-to-summary.

Example scope: “Produce a 3–5 bullet action list from support emails, each bullet with assignee and urgency (low/medium/high).” This would drive prompt choices and tests.

Quick answer (one-paragraph summary)

Define scope and roles, use system prompts for guardrails and constraints, user prompts to state intent and provide input, and tool prompts to integrate external data or actions; test with representative cases, include explicit failure handling, and iterate until outputs match your success metrics.

Differentiate system, user, and tool prompts

Each prompt layer has a distinct purpose and persistence level. Keep responsibilities separate to avoid mixing long-term rules with per-request details.

  • System prompts: Persistent instructions that define voice, constraints, and non-negotiable rules (safety, privacy, format). Example: “Always respond in JSON with fields: summary, actions.”
  • User prompts: Transient, per-request intent and data. Example: “Summarize the following email and list action items.”
  • Tool prompts: Instructions for external integrations (APIs, retrieval, calculators). They tell the model how to call tools and how to handle results.

Keeping them separate improves maintainability: change voice via system prompts, change task via user prompts, change data sources via tool prompts.

Map roles to expected model behavior

Document role-to-behavior mappings so stakeholders know what to expect from the model in each context.

Role behavior matrix (example)
RolePrimary ResponsibilityOutput StyleFailure Mode
SystemEnforce constraints & formatStrict, terseOverriding helpful elaboration
UserProvide intent & dataFlexible, contextualAmbiguous requests
ToolSupply external facts/actionsStructured responsesStale or failed calls

Example mapping: For a “Support Triage Agent” persona, system behavior enforces a polite professional tone and JSON output, user behavior provides the raw ticket, and tool behavior retrieves customer profile then annotates the ticket with SLA data.

Craft system prompts for reliability and constraints

System prompts should be concise, prioritized, and testable. Start with safety and legal constraints, then formatting and tone, then special-case overrides.

  • Prioritize: list non-negotiable rules first (data privacy, no personal opinions, no hallucinations).
  • Format enforcement: require machine-parseable output when downstream systems consume model output.
  • Examples: include positive and negative examples of acceptable outputs.

System prompt template:

System: You are a professional assistant. Always follow these rules:
1) Output valid JSON with fields: summary, actions.
2) Never invent facts; if unsure, say "unknown".
3) Keep tone neutral and professional.
4) Limit summary to 2 sentences. Examples: {...}

Test system prompts by sending identical user prompts across variations and verifying the system-level constraints always hold.

Write user prompts to express intent and elicit outputs

User prompts should be short, explicitly state the desired output, and include any context or preferences. Use templates to standardize requests.

  • Start with the task command: “Summarize”, “Classify”, “Rewrite”.
  • State format expectations: “Return as 3 bullets with assignee and urgency.”
  • Provide context and examples only when necessary to disambiguate.

User prompt template examples:

Summarize the email below into 3–5 action items. For each item include: assignee, deadline (ISO date if present), and urgency (low/medium/high). Email: "..."

Concrete tip: include a short “if information missing” rule: e.g., “If assignee is not specified, set assignee to ‘unassigned’.” This prevents inconsistent outputs.

Configure tool prompts and tool-integration instructions

Tool prompts explain how to query external services, interpret responses, and handle failures. Keep them minimal and machine-friendly.

  • Describe the tool purpose and expected schema for input and output.
  • Include retry logic and explicit error signals.
  • Define caching or staleness rules if applicable.

Tool prompt example for a knowledge-retrieval tool:

Tool: retrieve_faq
Input: { "query": "" }
Output: { "results": [ { "id": string, "score": number, "text": string } ] }
Rules:
- If no results (empty array), return { "results": [] }.
- Annotate each result with source and timestamp.
- Do not synthesize answers; return only retrieved documents.

When combining retrieved content with model output, instruct the model to quote or cite source IDs and to mark any content not found in tools as “unsupported”.

Common pitfalls and how to avoid them

  • Ambiguous scope — Remedy: write a one-sentence problem statement and acceptance criteria.
  • Overloaded system prompts — Remedy: keep system prompts ≤6 rules and use examples for edge cases.
  • Mixing roles in one prompt — Remedy: separate system/user/tool instructions and store them in distinct configuration fields.
  • Unstructured outputs — Remedy: require a strict schema (JSON, XML) and include validation in CI tests.
  • Silent failures from tools — Remedy: return explicit error objects and have the model handle them with fallback messaging.
  • Hallucinations — Remedy: instruct “do not invent”; prefer retrieval-first and make unknowns explicit.

Implementation checklist

  • Define scope, user personas, and success metrics.
  • Create concise system prompt with prioritized rules and examples.
  • Draft user prompt templates including missing-data rules.
  • Design tool prompts with schemas, errors, and retry policies.
  • Write unit tests for format and edge cases (e.g., missing fields).
  • Run A/B tests on tone, brevity, and factuality with representative inputs.
  • Deploy monitoring: validation, error rates, and user feedback loop.

FAQ

How long should a system prompt be?
Short: aim for 3–6 prioritized rules plus 1–2 examples. Keep it focused on non-negotiables.
When should I require JSON output?
Require JSON whenever downstream systems parse model outputs; include a JSON schema and validate server-side.
How do I handle private data in prompts?
Exclude sensitive data from prompts when possible; use tokenized identifiers or retrieval tools that mask PII. Enforce privacy rules in the system prompt.
What’s the best way to reduce hallucinations?
Use retrieval-first flows, strict “do not invent” rules, requiring “unknown” responses when evidence is missing, and add verification steps.
How often should prompts be reviewed?
Review prompts whenever success metrics change or quarterly as part of model governance; re-test after model version changes.