Skip to main content

Runtime API Reference

PrimitivePack

A named collection of primitives with a shared backend.

Example


@primitive

Decorator that registers a function as a runtime primitive.

Requirements

  • First parameter must be ctx: PrimitiveCallContext
  • Docstring must include Best Practices section
  • Must be async def

PrimitiveCallContext

Runtime context passed to every primitive handler.

ForkContext

Information about the current fork execution context.

PrimitiveSpec

The contract exposed to the model for discoverability.

PrimitiveParameterSpec


PrimitiveRegistry

Manages installed packs and routes primitive calls.

Key Methods


RuntimePrimitiveBackend

Base class for primitive pack backends. Subclass to create stateful backends.

Built-in Meta-Primitives

Always available in PyRepl without any pack installation:

SelfRef Pack Registration

The selfref pack provides primitives under runtime.selfref.context.* and runtime.selfref.fork.*.