Cortex · Prompt and context

System prompt (instructions)

instructions is the agent’s system prompt, the first message of every run. It is a string, or a function of the run’s deps, its input and the agent, called once when the run starts.

Agent
type Deps = { member: string; pass: string };

const desk = defineAgent<undefined, Deps>({
  id: 'desk',
  instructions: ({ deps }) =>
    `You sell seats to ${deps.member}, who holds a ${deps.pass} pass. Answer in one sentence.`,
});

const preview = await desk.preview('Can I bring a friend on Saturday?', {
  llm,
  deps: { member: 'Grace', pass: 'season' },
});
First message
{
  role: 'system',
  content: 'You sell seats to Grace, who holds a season pass. Answer in one sentence.',
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.