# Context
URL: https://lsd.tools/docs/api-context
Updated: 2026-07-18

`StepContext` and `Context` are **injected** parameters — annotate one and LSD hands it to your
function. `StepContext` (inside a step's `run`) exposes only **cache-neutral** capabilities —
progress, cancellation, side outputs, scratch dirs — deliberately, so a step can't read state the
resume-cache key cannot see. `Context` (inside a command, action, or view) is the one discoverable
handle on the running application. Neither is part of the cache key, so touching them never
invalidates a cached result.

## Usage

```python
from lsdtools import Tool, Table, StepContext

tool = Tool("demo")

@tool.shape
def slow(t: Table, ctx: StepContext) -> Table:
    ctx.progress(0.5, "halfway")
    return t
# → ctx is injected at run time, excluded from the cache key
```

## Where to start

**Learn** — [Parameters vs ports](/docs/tools-params-ports) · [Commands & actions](/docs/tools-commands-actions)

**API** — [Tool](/docs/api-tool) · [Engine](/docs/api-engine) · [Source](/docs/api-source)

**Examples** — [Live node metrics](/docs/ex-graph-outputs) · [A CLI command](/docs/ex-cli-command)
