QiForge architecture: the three layers

The three layers of a QiForge oracle (your code, the runtime, the bundled plugins), how boot works, the six registries, and how the LLM is chosen.

Read this page to know which parts of an oracle you write and which parts the framework owns. It shows the three layers, how the runtime boots, where plugin contributions go, what you can swap, and how to change the model the agent calls.

The three layers

A QiForge deployment has exactly three layers.

Layer 1: your oracle

Typically apps/your-oracle/src/main.ts (a createOracleApp(...) call), a config.ts for identity, and any custom plugins or Nest modules.

You own the entry point, your oracle's identity, custom plugins and custom Nest modules.

You don't own the agent loop, the graph state shape, the checkpointer, the auth flow, the meta-tools or the bundled plugins' internals.

Layer 2: @ixo/oracle-runtime

The framework. It owns:

  • the bootstrap (createOracleApp)
  • the always-on Nest modules (Sessions, Messages, WebSocket, Secrets, UCAN, Auth, Subscription, Throttler, Health)
  • the per-request agent builder
  • the four always-on agent middleware (capability gate, tool validation, tool-repetition guard, tool retry), plus page-context and safety-guardrail when their hooks are set
  • the Matrix-backed SQLite checkpointer
  • the plugin API

You never edit this layer. Updates come through pnpm update @ixo/oracle-runtime.

Layer 3: bundled plugins

16 plugins ship inside the runtime package, each one toggled independently through features. See the Plugin catalog for what each one does.

How the runtime boots

The HTTP server accepts requests immediately. Auth-requiring routes return 401 until Matrix init finishes and the UCAN signing mnemonic loads.

Defined in create-oracle-app.ts.

The six registries

Plugins don't talk to the runtime directly. At boot they push contributions into one of six registries, and the agent builder reads from them per request.

RegistryHoldsCollision rule
ToolRegistryAll plugin toolsFlat namespace: collision is a boot error
SubAgentRegistryAll plugin sub-agentsFlat namespace: collision is a boot error
MiddlewareRegistryAll plugin middlewareOrdered topologically; no names
ManifestRegistryAll plugin manifestsTitle collision = soft warn
ConfigSchemaRegistryAll plugin Zod schemasMerged; later wins with warning
SharedStateRegistryPlugin shared-state accessorsFlat namespace: collision is a boot error

Source: packages/oracle-runtime/src/registries/.

What you can swap and what is fixed

PluggableFixed
Plugin set (bundled toggles + your plugins)Agent loop (LangChain createAgent)
nestModules (your Nest modules)Graph state shape (except one added loadedPlugins field)
authExcludedRoutes (host + plugin)Checkpointer (Matrix-backed SQLite)
LLM provider (env-driven)Auth flow (UCAN delegation)
hooks.checkpointerForUser (advanced)The four always-on middleware
System prompt (through OracleConfig.prompt)The Tier-1 block format
Anything inside a custom pluginThe six registries

If you want to swap something on the "Fixed" side, the framework does not allow it. Work within the model (for example, write a plugin) or fork the runtime.

Model resolution and hooks

This section answers how the agent picks which LLM to call, and how you change it.

The provider is env-driven. LLM_PROVIDER selects the whole per-role model map: openrouter (default) or nebius, each with its matching API key (OPEN_ROUTER_API_KEY / NEBIUS_API_KEY). The model id for each role (main, subagent, utility, vision, guard, …) is baked into the provider's model map. There is no env var to change a single role's model id on its own.

Resolution is per role, because different jobs use different models. The main agent resolves the main role. Sub-agents and utility calls resolve subagent / utility through ctx.llm.get(role). The runtime resolves the main model as resolveModel('main'), defaulting to the provider map.

To change the main agent's model, pass hooks.resolveModel to createOracleApp. Spreading params keeps the provider's fallback models and latency sorting:

import { createOracleApp, getProviderChatModel } from '@ixo/oracle-runtime';

const app = await createOracleApp({
  config,
  plugins,
  hooks: {
    // role is 'main' | 'subagent' | 'utility'. Spreading params preserves
    // the provider's fallback models + latency sort.
    resolveModel: (role, params) =>
      getProviderChatModel(role, {
        ...params,
        ...(role === 'main' && { model: 'google/gemini-3.1-flash-lite' }),
      }),
  },
});

The runtime only calls resolveModel('main') itself, so a hook that special-cases 'main' swaps only the main agent's model. Sub-agents and utility calls keep the provider defaults unless your own code routes them through the hook too.

resolveModel is one of several hooks, the framework's advanced extension points. Others include checkpointerForUser (swap the per-user checkpointer), safetyModel (enable the safety-guardrail middleware), getRoomTitle (enable the page-context middleware), and prompt-block overrides like operationalMode. See the createOracleApp reference for the full list.