Skip to main content

Inference Passthrough

Every Kernle user with a working AI application already has a model. Inference passthrough eliminates the need to configure a separate model binding for Kernle — your existing model “just works.”

How It Works

Kernle supports two integration patterns, each with its own inference source:

Model Binding Priority

When a tool is called, Kernle binds a model in this order:
  1. Explicit model — if you’ve already called k.entity.set_model(), that model is used
  2. Persisted config — if you ran kernle model set, that config is loaded
  3. MCP sampling — if the MCP client supports sampling, the host agent’s model is used
  4. Capture-only — no model available; memory capture works, inference-dependent features are skipped

MCP Integration (Automatic)

If your MCP client supports the sampling capability (Claude Code, Claude Desktop), Kernle automatically uses the host agent’s model for inference. No configuration needed.
The MCP server detects sampling support at the first tool call and binds it transparently. You’ll see this in logs:
If the client doesn’t support sampling, Kernle operates in capture-only mode — capture-tier operations (episodes, notes, raw) still work, but identity-tier operations (beliefs, values, goals, drives, relationships) raise InferenceRequiredError, and inference-dependent features like emotion detection and contradiction finding are skipped.

Library Embedding (CallableModelAdapter)

For Python library users, wrap any (prompt, system) -> str callable:

Message Flattening

CallableModelAdapter flattens the message list into a single prompt string:
This is intentionally simple. If you need full message-structure fidelity (tool calls, structured content), implement ModelProtocol directly instead.

No Model? Capture Still Works

Kernle operates in two tiers when no model is bound:
  • Capture tierraw(), episode(), note() always work without a model
  • Identity tierbelief(), value(), goal(), drive(), relationship() require a bound inference model and raise InferenceRequiredError without one
Inference-dependent features return safe defaults:

Exports

CallableModelAdapter is available at the top level:
SamplingModelAdapter is internal to the MCP server and not exported at the package top level. The server instantiates it automatically when sampling is available.