Observe a QiForge oracle: tracing, events and logs

Trace turns to LangSmith or IXO Traces, subscribe to plugin status events and background errors, log the boot snapshot, and use the plugin-scoped logger.

This guide shows how to see what a running oracle is doing. It points to tracing (LangSmith or IXO Traces), subscribes to plugin status events and background errors, logs which plugins loaded at boot, and writes plugin-scoped log lines.

Tracing

The Workers runtime can trace every turn to LangSmith, to IXO Traces (IXO's own trace store, hosted by IXO or run on your own Cloudflare account), or to both at once. Nothing is traced until you set it up, and no code change is needed.

# LangSmith
LANGSMITH_API_KEY=lsv2_...        # secret
LANGSMITH_TRACING=true            # or LANGSMITH_TRACED_DIDS=did:ixo:...,did:ixo:...
LANGSMITH_PROJECT=my-oracle

# IXO Traces (runtime 0.63.0 or later)
TRACES_API_KEY=ixt_w_...          # secret
TRACES_ENDPOINT=https://traces.ixo.earth   # or a TRACES service binding
# 0.64.0+: same users as LangSmith; TRACES_TRACED_DIDS=* traces everyone

The runtime reads these from the Worker's env. Setup, cost, what one turn sends, privacy, checks and a troubleshooting table: Tracing.

What QiForge gives you out of the box

QiForge gives you four signals and nothing more. Bring your own log aggregator and metrics.

  1. Traces to LangSmith, IXO Traces or both, driven by env vars and covered above.
  2. Plugin status events: app.onPluginStatusChange(handler).
  3. A plugin-scoped logger: ctx.logger (boot) and rtCtx.logger (per-request).
  4. A call trace (Workers runtime). Every model call logs [llm] start role=<role> model=<id> and [llm] end … in N ms at debug level, and a still running after N s heartbeat every 60 s while it is open. The stream liveness guard warns [llm] <lane> <role> <model>: no bytes for N s when a provider stalls. Every completed tool call logs [tool-execution] <tool> (<call id>): ok in N ms (or returned an error in N ms). Only the role, model id, tool name and timings are logged, never message content or credentials.

Subscribe to plugin status events

Register a handler after createOracleApp returns

app.onPluginStatusChange((event) => {
  Logger.log(
    `[plugin] ${event.plugin} ${event.from} → ${event.to}` +
      (event.reason ? ` (${event.reason})` : ''),
  );
});

Live example: apps/qiforge-example/src/main.ts.

Listen for the matrix plugin transitions specifically

The plugin that reliably emits transitions is matrix. It starts pending at boot and flips to either loaded or failed once Matrix init completes in the background.

app.onPluginStatusChange((event) => {
  if (event.plugin === 'matrix' && event.to === 'loaded') {
    // safe to send messages, mint UCANs, etc.
  }
});

Use this to gate operations on Matrix being up, or to alert when it fails.

The event shape:

{
  plugin: string;
  from: 'pending' | 'loaded' | 'failed';
  to:   'pending' | 'loaded' | 'failed';
  reason?: string;
}

Capture background errors with onError

app.onError((err, source) => {
  Logger.error(`[runtime] ${source}: ${err.message}`);
});

source is a short label like 'matrix-init'. Use this for background failures (Matrix sync errors, key setup failures). Boot-time errors (env validation, manifest validation, dependency cycles) throw from createOracleApp itself, so your try/catch around the call sees them.

Log the boot resolution snapshot

app.plugins.status() returns the loader's resolution snapshot. Log it once at boot so operators see what came up.

const status = app.plugins.status();
Logger.log(`[boot] loaded plugins: ${status.loaded.join(', ') || '(none)'}`);
if (status.excluded.length > 0) {
  Logger.log(
    '[boot] excluded plugins:',
    status.excluded.map((e) => `${e.plugin} (${e.reason})`).join(', '),
  );
}

The snapshot has the shape of the PluginStatusReport defined in packages/oracle-runtime/src/bootstrap/create-oracle-app.ts:

{
  loaded: string[];                                  // plugin names that came up
  excluded: Array<{
    plugin: string;
    reason: string;                                  // e.g. "auto-detect precondition not met (COMPOSIO_API_KEY)"
  }>;
  softDepGaps: Array<{ plugin: string; missing: string }>;
}

Use the plugin-scoped logger

Every PluginContext and RuntimeContext carries a logger field prefixed with the plugin's name. See Logger in types.ts.

override getTools(ctx: PluginContext): PluginTool[] {
  ctx.logger.log('Building weather tools');
  // ...
}

handler: async (args, rtCtx: RuntimeContext) => {
  rtCtx.logger.log(`Looking up ${args.city}`);
  // ...
}

The Logger interface:

MethodRequiredPurpose
log(message, ...optional)yesInfo-level output.
error(message, ...optional)yesError-level output.
warn(message, ...optional)yesWarn-level output.
debug(message, ...optional)noDebug-level. Implementation-defined.
verbose(message, ...optional)noVerbose-level. Implementation-defined.
child(bindings)noReturns a logger with additional context fields. Falls back to the same logger if not implemented.

Use NestJS's default Logger format in development, where pnpm dev prints it. Pipe to your aggregator in production. Override the global logger with createOracleApp({ logger }) if you want a custom format. See the createOracleApp reference.

UI-facing tool-call events

To show the user what the agent did, the runtime emits typed events through rtCtx.emit. The bundled clients (Portal, Slack, Matrix) consume these and render the right UI. You only emit them yourself when writing a custom client.

rtCtx.emit.toolCall({ /* ... */ });
rtCtx.emit.actionCall({ /* ... */ });
rtCtx.emit.renderComponent({ /* ... */ });
rtCtx.emit.reasoning({ /* ... */ });
rtCtx.emit.browserToolCall({ /* ... */ });
rtCtx.emit.router({ /* ... */ });
rtCtx.emit.messageCacheInvalidation({ /* ... */ });

The seven event types are defined on RuntimeContext.emit in types.ts.