Intelligence · function

entityContext

A context provider that samples a query into a list of references.

Explained in Agents and behaviour.

function entityContext(world: World, options: EntityContextOptions): ContextProvider<readonly string[]>
import { entityContext } from '@driftengine/ai';

Parameters

ParameterTypeDescription
worldWorld
optionsEntityContextOptions

In depth

This allocates, and that is correct here. A reference is a string and a sample is a list, so neither can be free. What matters is where it runs: context is assembled once per request, not once per tick, and a request already costs a network round trip. The floor is the per-tick path and it is the one with the allocation floor.

What wrapping the cursor must not do is make iteration allocate — that property is @driftengine/entities' and is floored in its own suite — so the loop reads the cursor directly rather than materialising it first.