***

title: setStepCriteria
slug: /reference/typescript/agents/context-builder/step/set-step-criteria
description: Define when this step is considered complete.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[ref-step]: /docs/server-sdks/reference/typescript/agents/context-builder/step

Define when this step is considered complete. The AI evaluates this description
against the conversation state to determine whether to advance.

## **Parameters**

<ParamField path="criteria" type="string" required={true} toc={true}>
  Natural-language description of completion conditions.
</ParamField>

## **Returns**

[`Step`][ref-step] -- Self for method chaining.

<Tip>
  Be specific. Write "Customer has provided their full name AND phone number" rather
  than "Information collected". Include failure conditions when appropriate:
  "Verified OR after 3 failed attempts".
</Tip>

## **Example**

```typescript {7-11}
import { ContextBuilder } from '@signalwire/sdk';

const builder = new ContextBuilder();
const ctx = builder.addContext('default');
const step = ctx.addStep('verify_identity');
step.setText('Verify the caller\'s identity.');
step.setStepCriteria(
  'Complete when the customer has provided their account number ' +
  'AND verified it with the last four digits of their SSN, ' +
  'OR after 3 failed verification attempts.'
);
```