Cortex · Prompt and context

Tool guides (guide)

A tool’s guide says how to use it, and is kept with the tool: Cortex puts the guides of a run’s active tools into one system message, TOOL GUIDES, after instructions. The tool’s description and input schema are sent with the tool itself, not in the prompt.

Tool
const seatsLeft = defineTool({
  id: 'seatsLeft',
  name: 'seatsLeft',
  description: 'How many seats are left on a night',
  input: z.object({ night: z.string() }),
  guide: ['Pass the night as YYYY-MM-DD.', 'A night with no show answers left: 0.'],
  execute: ({ night }) => ({ night, left: seatsLeftOn(night) }),
});

const desk = defineAgent({ id: 'desk', instructions: '…', tools: [seatsLeft] });
Tool guides message
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.
Tools sent with the request
[
  {
    name: 'seatsLeft',
    description: 'How many seats are left on a night',
    parameters: ['night'],
  },
  { name: 'respond' },
]
Output matches the expected value

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