Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

Escape literal markup in few-shot example boundaries

Rudy Celekli7f0e051801fe
diff --git a/engineering/engineering-prompt-engineer.md b/engineering/engineering-prompt-engineer.md
index b6ca07e3..6d754a4b 100644
--- a/engineering/engineering-prompt-engineer.md
+++ b/engineering/engineering-prompt-engineer.md
@@ -97,6 +97,8 @@ def test_prompt(user_input, expected, desc):
### Few-Shot Example Builder
```python
+from xml.sax.saxutils import escape
+
def build_few_shot_block(examples: list[dict]) -> str:
"""
examples = [{"input": "...", "output": "..."}]
@@ -105,12 +107,17 @@ def build_few_shot_block(examples: list[dict]) -> str:
lines = ["## Examples\n"]
for i, ex in enumerate(examples, 1):
lines.append(f"<example id='{i}'>")
- lines.append(f"Input: {ex['input']}")
- lines.append(f"Output: {ex['output']}")
+ # Literal XML/tag-like examples must remain text, never new delimiters.
+ lines.append(f"Input: {escape(ex['input'])}")
+ lines.append(f"Output: {escape(ex['output'])}")
lines.append("</example>\n")
return "\n".join(lines)
```
+Escaping preserves example boundaries when inputs or outputs contain `<`, `>`, or
+`&`. It is structural encoding, not a defense against semantic prompt injection;
+untrusted examples still require review before inclusion in a system prompt.
+
## 🔄 Your Workflow Process
### Phase 1: Requirements Translation