Foundations
Prompt Anatomy
A chat request is a list of messages with roles. Inside the messages, good prompts share a structure: a role, a task, context, constraints, and an output format.
Message rolesBeginner
The system (or developer) message sets standing instructions. User messages carry the request. Assistant messages are the model’s earlier replies, and tool messages return results of tool calls. Higher-priority roles should hold rules that users must not override.
| Role | Typical content |
|---|---|
| system / developer | Persona, rules, output format, safety constraints |
| user | The task and its input |
| assistant | Previous answers, or a partial answer to continue |
| tool | Results returned by a function or API call |
Parts of a strong promptBeginner
PromptFlowEngine’s structured mode rewrites prompts into these sections. Not every prompt needs all of them, but missing ones are a common cause of vague answers.
- Role: who the model should act as
- Task: one clear objective
- Context: background the model cannot guess
- Requirements and constraints: what must and must not happen
- Input: the data, clearly delimited (for example in tags)
- Output format: structure, length, and schema
Delimit variable inputIntermediate
Text inserted from users or documents should be wrapped in clear delimiters such as <ticket>…</ticket>. Without delimiters, inserted text can read like instructions, which is one path for prompt injection.
Instruction hierarchyAdvanced
Models are trained to weigh system instructions above user content, and user content above retrieved or tool content, but this is a tendency, not a guarantee. Security rules belong in application code as well as in the prompt.
Key takeaways
- Put durable rules in the system message.
- Delimit inserted data.
- State the output format explicitly.