# StepContext.cancelled
URL: https://lsd.tools/docs/api-context-cancelled
Updated: 2026-07-17

## Example

```python
@tool.shape
def heavy(t: Table, ctx: StepContext) -> Table:
    for chunk in chunks(t):
        if ctx.cancelled:
            return t          # stop early, cleanly
        ...
    return t
```

## Notes

Read-only. Poll it inside long loops — nothing interrupts your function for you. Returning early on
cancel leaves whatever partial work you have done, so return a safe value.

## See also

**API:** [progress](/docs/api-context-progress) · [step_id](/docs/api-context-step-id) · [StepContext](/docs/api-context)

**Guides:** [Parameters vs ports](/docs/tools-params-ports)
