Cortex · API
createManifold
createManifold creates a catalog of agents: register adds agents, run starts one by id, and the llm option is the fallback model for all of them. onRun receives every run started through the manifold. The model’s one turn is scripted; no model is called.
const manifold = createManifold({ llm, onRun: (run) => tapped.push(run.agentPath.join(' > ')) });
const desk = defineAgent({ id: 'desk', instructions: 'Answer the member in one sentence.' });
const clerk = defineAgent({
id: 'clerk',
instructions: 'Read what the member wants into an order.',
output: { schema: Order },
});
manifold.register(desk, clerk);
const result = await manifold.run('clerk', 'Two seats for Sunday, please.').result;1 writes {"data":{"night":"2026-10-25","seats":2}}{
agents: ['desk', 'clerk'],
tapped: ['clerk'],
result: {
ok: true,
output: { data: { night: '2026-10-25', seats: 2 } },
},
}Runs in this page on the installed package. The input and the expected output are defined by the example.