Skip to main content

Two contexts, two lifetimes

The distinction matters because the wrong context can’t see what your code needs. A boot-time hook can’t ask “who is the user” — there is none yet. A per-request hook can’t be used to register a Nest module — it’s already too late.

What each context carries

PluginContext — boot-time, no user

  • config — the merged, Zod-validated env (base + every plugin’s configSchema).
  • identity — your oracle’s identity (name, org, description, entityDid, prompt).
  • availablePlugins — set of names of all loaded plugins; useful for soft-dependency branching.
  • logger — a plugin-scoped logger.

RuntimeContext — per request, authenticated user

Everything in PluginContext, plus: Full field list and types: RuntimeContext reference.

Registration vs execution

A tool registered via boot-time getTools(ctx) still receives a fresh RuntimeContext when its handler fires. “Boot-time” applies to when the tool is registered, not to when it runs. Both contexts coexist over the lifetime of any tool.

Choosing the right hook

If a hook exists in both forms, pick by what your code reads: When both hooks fire on the same plugin, their outputs are merged — no need to choose one or the other.

Write a plugin

See both contexts in real code.

RuntimeContext reference

The full field list.
Source: packages/oracle-runtime/src/runtime-context/ and PluginContext / RuntimeContext.