Prompt-Context-Separator
April 29, 2026 · View on GitHub
A pattern, prompt library, and reference dataset for separating the asks from the surrounding context in a user message before it hits a downstream LLM.
The idea
A typical message to an AI mixes two distinct things:
- Prompts — the discrete asks. What the user actually wants answered or done.
- Context — background that grounds the asks but is not itself a question: prior thinking, motivation, references to past work, constraints.
A small prompt processing agent sits in front of the main model and splits the input into these two fields. Downstream systems then consume them differently.
Architecture
flowchart LR
U[User message] --> S[Prompt separation agent]
S -->|prompts| I[Inference model]
S -->|context| V[(Vector database<br/>persistent memory)]
S -->|context| I
V -.retrieved memory.-> I
I --> R[Response to user]
The same separated context serves two purposes: it is passed to the answering model and stored in a vector database so future turns can retrieve it.
Use cases
This pattern is useful in two distinct situations:
1. Better targeted responses
By sharply isolating "what is the user actually asking?" from "what is the surrounding background?", the downstream model spends its attention on the right thing. Long, meandering inputs that get vague answers when sent raw produce sharper answers when the asks are surfaced cleanly. See system-prompts/variants/for-targeted-inference.md.
2. Persistent memory pipeline
The context array is exactly the shape a vector database wants: discrete, self-contained, third-person facts that embed cleanly and retrieve atomically. Running every user message through a separation agent produces a clean stream of memory chunks as a side effect of normal interaction. See system-prompts/variants/for-vector-memory.md.
The two use cases compose: separated context can simultaneously feed the answering model now and the vector store for later.
Output schema
The separation agent returns:
{
"prompts": ["string", "..."],
"context": ["string", "..."]
}
prompts— array of self-contained asks. Light cleanup, no paraphrasing.context— array of third-person background chunks, each prefixed{{user}}. One discrete idea per chunk.
Prompt library
| File | Structured output | Natural-language output | Use case |
|---|---|---|---|
system-prompts/zero-shot.md | ✅ | — | General — instructions only, no examples |
system-prompts/one-shot.md | ✅ | — | General — one worked example |
system-prompts/few-shot.md | ✅ | — | General — three worked examples |
system-prompts/natural-language.md | — | ✅ | General — markdown output instead of JSON |
system-prompts/variants/for-targeted-inference.md | ✅ | — | Specific — downstream is the answering model |
system-prompts/variants/for-vector-memory.md | ✅ | — | Specific — downstream is a vector DB |
system-prompts/variants/for-dictation.md | ✅ | — | Specific — voice-typed / dictated input |
The shared structured-output contract lives in system-prompts/_schema.md.
General-purpose prompt (in full)
The simplest, model-agnostic, structured-output baseline:
You are a prompt processing agent. Your job is to take a single user
message and decompose it into two structural fields so that downstream
systems can route, store, or answer the message more effectively.
Separate the input into:
1. `prompts` — the discrete asks. Each prompt is one self-contained
question or task the user is putting to the AI. If the input contains
multiple distinct asks, return each as its own item.
2. `context` — surrounding background that grounds the asks but is not
itself a question: prior thinking, motivation, anecdotes, framing,
references to previous conversations or work. Each context chunk is
one discrete idea, written in the third person and prefixed with
`{{user}}`.
Drop greetings, sign-offs, and pure filler. Light cleanup is allowed
(fixing obvious typos or dictation artefacts). Do not paraphrase,
summarise, or invent content. Preserve the user's original wording
wherever possible.
Return a single JSON object:
{
"prompts": ["..."],
"context": ["..."]
}
No prose outside the JSON.
Reference dataset
data/gold.csv and data/gold.jsonl contain 10 human-annotated rows pulled from the upstream danielrosehill/Prompt-Separation dataset on Hugging Face — included as canonical examples of correct separation.
The JSONL form collapses the wide promptN / contextN columns into prompts and context lists, matching the live agent's output shape.
Related
- Dataset: https://huggingface.co/datasets/danielrosehill/Prompt-Separation
- Upstream pipeline / labelling code: https://github.com/danielrosehill/MWP-Prompts-0426
License
MIT (code and prompts) — gold rows derived from the upstream dataset retain its CC-BY-4.0 license.