Cortex · Prompt and contextOutput schema in the prompt (
Output schema in the prompt (output.doc)
Signal sends the output schema one of three ways, by what the provider can do: with the request as a JSON Schema (native), as the parameters of a respond tool, or, under emit, as a system message, OUTPUT SCHEMA, after the tool guides. output.doc puts a string of yours in place of that message, or leaves it out with 'off'.
const Order = z.object({ night: z.string().describe('YYYY-MM-DD'), seats: z.number().int() });
const clerk = defineAgent({ id: 'clerk', instructions: 'Read the order.', output: { schema: Order } });
const ownDoc = defineAgent({ id: 'clerk', instructions: 'Read the order.', output: { schema: Order, doc: '…' } });
// each previewed on three providers: one that takes a JSON Schema with a request,
// one that keeps tool arguments to their schema, and one that mangles them
await clerk.preview('Two seats on Saturday.', { llm });{
takes a JSON Schema: {
strategy: 'native',
system: [
'Read the order.',
'FINISH PROTOCOL: To finish, reply with no tool calls…',
],
},
keeps tool arguments: {
strategy: 'respond',
system: [
'Read the order.',
'FINISH PROTOCOL: To finish, call the `respond` tool …',
],
},
mangles tool arguments: {
strategy: 'emit',
system: [
'Read the order.',
'OUTPUT SCHEMA — your output MUST validate against th…',
'FINISH PROTOCOL: Your ENTIRE final message must be O…',
],
},
mangles them, with doc: {
strategy: 'emit',
system: [
'Read the order.',
'OUTPUT SCHEMA: an order, the night as YYYY-MM-DD.',
'FINISH PROTOCOL: Your ENTIRE final message must be O…',
],
},
}Runs in this page on the installed package. The input and the expected output are defined by the example.