include/entropic/inference/secondary_model_loader.h

← API

include/entropic/inference/secondary_model_loader.h

entropic::SecondaryModelLoader

Role-keyed lifecycle manager for non-primary models.

bool entropic::SecondaryModelLoader::ensure_loaded(const std::string &role, const ModelConfig &config)

Lazily load and activate a model for a role.

If the role is already loaded against the same config path, this is a no-op (idempotent). If the role is loaded against a different path, the existing backend is unloaded first. Idempotent against the same path (an already-loaded role short-circuits) and reloads when the configured path changes. A failed load is isolated: the role is simply not recorded, so a bogus draft path degrades the feature without blocking engine initialisation.

Parameters
  • role — Role name (e.g. "router", "draft").
  • config — ModelConfig for the secondary model.
Returns
  • true on successful activation, false on failure.
  • true on activation success (including the already-loaded short-circuit); false if the backend failed to activate.

InferenceBackend * entropic::SecondaryModelLoader::get(const std::string &role) const

Get the backend for a role.

Parameters
  • role — Role name.
Returns
  • Backend pointer if loaded, nullptr otherwise.
  • Backend pointer, nullptr if role is unknown.

std::shared_ptr< InferenceBackend > entropic::SecondaryModelLoader::get_shared(const std::string &role) const

Get the backend for a role as a shared_ptr.

Used when callers need to extend backend lifetime beyond the loader (e.g. holding a reference for the duration of a long generation while the loader could otherwise be released).

Parameters
  • role — Role name.
Returns
  • Backend shared_ptr (empty if not loaded).
  • Backend shared_ptr, empty if role is unknown.

bool entropic::SecondaryModelLoader::release_role(const std::string &role)

Unload and drop a role.

Parameters
  • role — Role name.
Returns
  • true if a role was unloaded, false if it was not loaded.
  • true if a role was unloaded, false if none was loaded under that name (an unknown role is not an error).

bool entropic::SecondaryModelLoader::is_loaded(const std::string &role) const

Check whether a role is currently loaded and active.

Check whether a role is currently loaded and non-COLD.

Parameters
  • role — Role name.
Returns
  • true if get(role) != nullptr and the backend reports it is loaded (state != COLD).
  • true if backend is present and is_loaded().

std::vector< std::string > entropic::SecondaryModelLoader::loaded_roles() const

Names of all roles with a currently-loaded backend.

Names of all loaded roles (sorted for deterministic output).

Returns
  • Sorted list of role names whose backend is non-COLD.
  • Sorted role names whose backend reports is_loaded(); a role whose load failed is absent, which is how callers observe the failure.

void entropic::SecondaryModelLoader::clear_all_prompt_caches()

Fanout: clear prompt/KV cache on every loaded backend.

Used by ModelOrchestrator::clear_all_prompt_caches() so the router and draft caches invalidate alongside the main pool when identity content changes (P1-7, v2.0.6-rc16 contract).

void entropic::SecondaryModelLoader::shutdown()

Unload every role.

Mirrors ModelOrchestrator::shutdown() — called during engine teardown. Safe to call repeatedly. Safe to call repeatedly. Idempotent on an empty loader, so an orchestrator that never loaded a router or draft still tears down cleanly.