XML tags in prompts — CCA-F Exam Prep

PencilPrepPencilPrep
L2.04|XML tags in prompts
1/12
Something's wrong
A developer staring at two outputs from the same prompt. Left output: a perfectly formatted JSON response. Right output: a rambling paragraph that includes fragments of the few-shot examples mixed with real data. The developer has circled a section where example data leaked into the real output. Dim office, late night.

The prompt had instructions, examples, and user input. Claude followed the example instead of the instruction.

A developer built a contract analysis tool. The prompt contained: instructions for how to analyze contracts, three example analyses, and the actual contract to analyze.

Sometimes Claude analyzed the real contract correctly. Other times, it produced output that looked suspiciously like Example 2 -- same structure, same phrasing, even fragments of the example contract mixed into the real analysis.

The developer rewrote the instructions four times. Added bold text. Added caps. Added "IMPORTANT: analyze the ACTUAL contract below, not the examples."

It still happened. 1 in 8 requests. Randomly. Unpredictably.