The prompt accrue sends¶
You describe fields, and accrue writes the prompt around them. This page shows that prompt in full, how to read the one your own step sends, and three ways to change it: add context, restrict where answers come from, or replace it with your own.
What it looks like¶
This step:
from accrue import LLMStep
step = LLMStep("extract",
system_prompt_header="Listings come from UK office-furniture suppliers.",
fields={
"category": {"prompt": "What the product is", "enum": ["chair", "desk", "lamp", "other"]},
"unit_price_gbp": {"prompt": "Price per single item ex VAT, in pounds",
"type": "Number", "default": None},
},
)
sends this system message, the same for every row:
# Role
You are a structured data enrichment engine. Given one input row, a set of field specifications, and optional context from prior processing steps, produce a JSON object with exactly the requested fields as keys.
# Context
Listings come from UK office-furniture suppliers.
# Field Specification Keys
Each field below is described using these keys:
- **prompt**: the extraction instruction for this field
- **type**: expected output data type (String, Number, Boolean, Date, List[String], JSON)
- **enum**: constrained value list — the output MUST be one of these options exactly
- **default**: the value to return when the answer cannot be determined
# Output Rules
- Return ONLY a single valid JSON object. No prose, no code fences, no explanations.
- Top-level keys MUST be exactly: category, unit_price_gbp
- Keep outputs concise and information-dense.
- For enum fields, the value MUST match one of the listed options exactly. Do not paraphrase or combine options.
- Work from what you are given first: the row data, prior results, and any attached documents or search results. For anything they do not contain, you may use what you reliably know about the subject. Do not estimate, and do not infer a value from what is typical.
- A missing value is better than a guess, which nobody can tell from a fact.
- If you cannot determine a value, return the field's default.
- A default of null means: return JSON null for that field.
<field_specifications>
<field name="category">
<prompt>What the product is</prompt>
<enum>chair, desk, lamp, other</enum>
</field>
<field name="unit_price_gbp">
<prompt>Price per single item ex VAT, in pounds</prompt>
<type>Number</type>
<default>null</default>
</field>
</field_specifications>
and this user message, which changes per row:
<row_data>
{"sku": "A1", "listing": "LED desk lamp, USB. POA"}
</row_data>
Analyze the provided data and return the requested fields as JSON.
# Reminder
Return ONLY the JSON object with keys: category, unit_price_gbp. No additional text.
A step with depends_on also gets a <prior_results> block after the row. The sections under "Field Specification Keys" and "Output Rules" only mention the spec keys your fields use.
The split matters for cost. The system message is identical for every row, so providers cache it; the row goes in the user message. Keep anything row-specific out of system_prompt_header.
Read the prompt your step sends¶
Neither of these calls a model:
print(step.row_independent_system()) # one step
plan = pipeline.plan(data, sample_size=0) # every step in a pipeline
for s in plan.steps:
print(s.name, s.system_prompt, sep="\n")
Add context: system_prompt_header¶
Most jobs only need this. The text goes under # Context, and everything else is still generated. Use it for what is true of the whole job: what the rows are, who the output is for, definitions several fields share.
LLMStep("tag", fields={...},
system_prompt_header="Tickets from a UK broadband provider. If a ticket covers two topics, "
"choose the one the customer wants fixed.")
Restrict where answers come from: outside_knowledge¶
By default the model may fill a value from what it knows when the row does not contain it. That is what you want when the row is a company name and the field is its industry. It is not what you want when you are reading a contract or a product listing: there, a value that isn't on the page should come back empty, not be supplied from memory.
This swaps one output rule. The default reads:
Work from what you are given first: the row data, prior results, and any attached documents or search results. For anything they do not contain, you may use what you reliably know about the subject. Do not estimate, and do not infer a value from what is typical.
With outside_knowledge=False it reads:
Use only what you are given: the row data, prior results, and any attached documents or search results. Do not add facts from memory, even ones you are sure of. If what you are given does not say, the value is missing.
Give the fields somewhere to put a missing value: "default": None, or an enum option such as "not stated" (field specifications).
Use the switch, not a sentence in the header. A header that says "use only the row" sits above a rule that says the model may use what it knows, and models differ in which they follow. Changing outside_knowledge changes the cache key, so the step re-runs.
In a test over 16 listings for well-known products, asking for three facts that were not in the text, the cells filled from memory were:
| gpt-6-luna | claude-haiku-5-5 | gemini-3.5-flash-lite | |
|---|---|---|---|
| Default | 29 of 48 | 27 of 48 | 37 of 48 |
outside_knowledge=False |
0 of 48 | 1 of 48 | 8 of 48 |
One run each on 2026-11-28, so treat the numbers as a guide. The switch greatly reduces filling from memory, but it is an instruction to the model, not a guarantee: some cells were still filled. Check extraction that matters.
Replace it: system_prompt¶
system_prompt replaces the Role, Context, Field Specification Keys and Output Rules sections with your text. Accrue still appends the <field_specifications> block after it, and still builds the user message, so your prompt can refer to both.
MY_PROMPT = """You read supplier listings for a procurement team.
For each listing in <row_data>, fill the fields described in <field_specifications>.
Return one JSON object whose keys are exactly the field names. No other text.
Rules:
- Use only the listing text.
- Where a field has an enum, return one of its options exactly.
- If the listing does not give a value, return the field's default.
"""
LLMStep("extract", fields={...}, system_prompt=MY_PROMPT)
What your prompt has to cover, because the generated rules are gone:
- Return a single JSON object with the field names as keys.
- What to do when a value is missing.
- Anything you relied on from the default rules: exact enum matching, formats, where answers may come from.
What still applies:
- The strict JSON schema built from your field specs (on OpenAI, Anthropic and Gemini), so types and enums are still enforced.
defaulthandling and validation after the call.- Caching. A custom prompt is part of the cache key, so editing it re-runs the step. An accrue release that changes the generated prompt does not.
system_prompt_header and outside_knowledge are ignored when system_prompt is set. Keep the prompt the same for every row, or provider prompt caching stops working.
A good way to start is to print the generated prompt, copy it, and edit.
Which to use¶
| You want to | Use |
|---|---|
| Tell the model about the job | system_prompt_header |
| Greatly reduce filling gaps from memory (not a guarantee) | outside_knowledge=False |
| Change one field's behaviour | That field's prompt, examples or enum |
| Change the role, the rules or the wording throughout | system_prompt |