Cortex · API
agent.preview
agent.preview returns what a run would send, without calling a model: the messages in order, the tools under the names the model would see, the output strategy, and an estimated token count. No model turn is scripted, because no request is made.
const desk = defineAgent({
id: 'desk',
instructions: 'Help the member. Look seats up with the seatsLeft tool.',
tools: [seatsLeft],
});
const preview = await desk.preview('How many seats are left on Saturday?', { llm });system Help the member. Look seats up with the seatsLeft tool.
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.
user How many seats are left on Saturday?{
strategy: 'respond',
tools: ['seatsLeft', 'respond'],
estimatedTokens: 90,
modelCalls: 0,
}Runs in this page on the installed package. The input and the expected output are defined by the example.