Cortex · Prompt and context
Message order
A run’s prompt is put together once, when it starts, in this order: instructions, the tool guides, the output schema where one is sent, the finish protocol, the agent’s context, the run’s producers, then the input. The first four are the same on every run of an agent, so a provider’s prompt cache holds them.
const desk = defineAgent({
id: 'desk',
instructions: 'Help the member, in one sentence.',
context: ['Doors open thirty minutes before the show.'],
tools: [seatsLeft], // with a guide
});
const preview = await desk.preview('How many seats are left on Saturday?', {
llm,
producers: ['The member asking is Grace.'],
});system Help the member, in one sentence.
system TOOL GUIDES — how to use the tools on this run:
── seatsLeft ──
Pass the night as YYYY-MM-DD.
A night with no show answers left: 0.
system FINISH PROTOCOL: To finish, call the `respond` tool
ALONE in its own turn with the envelope {
"reasoning"?: string, "response": string } as
its arguments — or reply with ONLY that JSON
envelope as your entire message.
system Doors open thirty minutes before the show.
system The member asking is Grace.
user How many seats are left on Saturday?[ 'instructions', 'tool guides', 'finish protocol', 'context', 'producers', 'input', ]
Runs in this page on the installed package. The input and the expected output are defined by the example.