C.W.K.
Stream
Lesson 09 of 10 · published

Multi-Document Prompts — Order, Boundaries, Naming

~16 min · context, multi-document, structure

Level 0Apprentice
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

Where blob-of-text falls apart

Pasting five documents into the user message with no separators is a recipe for the model conflating them, picking the wrong one, or summarizing the union. Multi-document prompts need explicit boundaries, names, and ordering decisions.

Boundary tags

Use XML-like tags or fenced sections with stable ids. Each document gets a name the model can reference and the user can verify.

Ordering decisions

  • By relevance — most-relevant first. Default for RAG.
  • By recency — useful for support tickets, news.
  • By authority — official docs first, community second. Useful for reference questions.
  • By source — group multi-source results. Useful when you need to compare.

The instruction to read the boundaries

The synthesis prompt should explicitly tell the model how to use the structure. "Each document is wrapped in <doc id=…>. Cite by id. Treat each document as independent — do not merge claims across documents unless they corroborate."

Code

Multi-document prompt with boundaries·xml
<docs>
  <doc id="d1" source="manual" date="2026-01-12">
    ... document text ...
  </doc>
  <doc id="d2" source="changelog" date="2026-04-01">
    ... document text ...
  </doc>
  <doc id="d3" source="forum" date="2026-03-15">
    ... document text ...
  </doc>
</docs>

<task>
Answer the user question using only <docs>.
Cite each claim with [<id>]. Treat each doc independently.
</task>

External links

Exercise

Take a multi-document prompt where you currently concatenate sources with line breaks. Add explicit XML boundaries and stable ids. Run the same five queries before and after. Note where outputs improved.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.