Module 04 Activity
Scenario
The prompt is the largest determinant of behaviour in the app, and it is currently a string literal.
What you build
Versioned templates with declared variables, input validation before the prompt is built, and rendering tests that need no key.
Steps
- Convert every prompt to a template with declared variables and prove one fails on a missing value.
- Validate input before the prompt is built: length bounds and at least one content rule.
- Put untrusted text in the user turn, delimited, and state in the system message that it is data.
- Try a prompt injection against your own app and record what happened.
- Version your prompts, keep retired versions readable, and record the version with every response.
- Test rendering with hostile inputs including a
$and a{.
Evidence to hand in
- Templates with a caught missing-variable failure.
- The input validator and its rejections.
- The delimited user turn and the system message.
- Your injection attempt and its result.
- The prompt version registry.
- Rendering tests with hostile characters.
Review checklist
- No prompt is built by concatenation.
- Input is validated before the prompt exists.
- Untrusted text is never in the system message.
- The injection attempt was actually run.
- Rendering is tested with formatting characters, without a key.
