Cortex · Failed runs

stopped: step limit

A run fails with code stopped and stop set to steps when it reaches its step limit. Each model turn is one step; the default limit is 20 steps, and stopWhen: [stepCount(n)] sets another. Here the limit is 3 and the model requests another tool call on every turn; its turns are scripted and no model is called.

Agent
const desk = defineAgent({
  id: 'desk',
  instructions: 'Help the member.',
  tools: [seatsLeft],
  stopWhen: [stepCount(3)],
});

const result = await desk.run('Which night should I come?', { llm }).result;
Scripted model turns
1  calls seatsLeft {"night":"2026-10-23"}
2  calls seatsLeft {"night":"2026-10-24"}
3  calls seatsLeft {"night":"2026-10-25"}
Result
{
  ok: false,
  error: {
    code: 'stopped',
    stop: 'steps',
    message: 'step limit reached (3)',
  },
  meta: { steps: 3 },
}
Output matches the expected value

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