> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wandb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# runIsolated

> TypeScript SDK reference

# runIsolated

▸ **runIsolated**\<`T`>(`fn`): `T`

Run `fn` in a fresh, isolated GenAI state frame. Any Session / Turn / LLM
started inside `fn` lives in this frame only — it does not clash with
sibling `runIsolated` frames running concurrently, and it does not leak
to the outer async chain.

Use this to safely run parallel GenAI work:

```typescript theme={null}
await Promise.all([
  weave.runIsolated(async () => { ... }),
  weave.runIsolated(async () => { ... }),
]);
```

Sequential single-flight usage doesn't require this wrapper — the
process-wide default state handles it.

#### Type parameters

| Name |
| :--- |
| `T`  |

#### Parameters

| Name | Type      |
| :--- | :-------- |
| `fn` | () => `T` |

#### Returns

`T`

#### Defined in

[genai/context.ts:90](https://github.com/wandb/weave/blob/6538626556c93d6f31ae725fdefe4e6b8b71bc2c/sdks/node/src/genai/context.ts#L90)

***
