Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor: consume inference policy from tinyinference

Steven Enamakeld2f810a32b29
diff --git a/crates/openhuman-core/src/inference/README.md b/crates/openhuman-core/src/inference/README.md
index a4d7145f4c..2bc491fa69 100644
--- a/crates/openhuman-core/src/inference/README.md
+++ b/crates/openhuman-core/src/inference/README.md
@@ -1,13 +1,19 @@
# inference
-Unified inference domain: the canonical home for everything LLM/STT/TTS/embedding-related. It owns the local-runtime manager (Ollama / LM Studio / Piper), native TinyAgents `ChatModel` construction for managed/cloud/local/CLI routes, host credential and access policy, voice transcription and TTS inference, OpenAI/Codex subscription OAuth, and an OpenAI-compatible `/v1/chat/completions` HTTP endpoint. It consolidates the previously separate `local_ai/`, `providers/`, and inference parts of `voice/` (all from the pre-crates single-crate layout) under one domain root. The RPC surface is `inference.*`; older `local_ai_*` method names are compatibility aliases in `crates/openhuman-core/src/core/legacy_aliases.rs`.
+OpenHuman's inference integration domain. Reusable model, provider transport,
+embedding, capability, temperature, and failure behavior belongs to
+`tinyinference`; this domain owns product configuration, credentials, access
+policy, local process lifecycle (Ollama / LM Studio / Piper), RPC/controller
+surfaces, OpenAI/Codex subscription OAuth, and the OpenAI-compatible HTTP
+endpoint. The RPC surface is `inference.*`; older `local_ai_*` method names are
+compatibility aliases in `crates/openhuman-core/src/core/legacy_aliases.rs`.
## Responsibilities
- Resolve workload names (`chat`, `reasoning`, `agentic`, `coding`, `memory`, `embeddings`, `heartbeat`, `learning`, etc.) and provider strings (`openhuman`, `cloud`, `ollama:<model>`, `lmstudio:<model>`, `claude_agent_sdk:<model>`, `claude-code:<model>`, `<slug>:<model>[@<temp>]`) to a concrete `Arc<dyn tinyinference::ChatModel<()>>` + model id.
- Manage the local AI runtime: detect/spawn/adopt `ollama serve`, probe LM Studio over HTTP (never spawned), install/run Piper (TTS), track download progress, and enforce a minimum-context-window floor. Local STT (whisper.cpp) was retired; STT is now cloud/engine-configurable via `voice_server.stt_engine` (see `config/migrations/retire_local_whisper_stt.rs`).
- Provide chat, vision (multimodal), summarization, embeddings, sentiment, and "should react" inference operations.
-- Preserve config-rejection, billing, authentication, and retry classification while TinyAgents owns model-call retry execution.
+- Preserve product-specific config-rejection, billing, and authentication policy while TinyInference owns provider-failure classification and TinyAgents owns model-call retry execution.
- Resolve abstract tier names (`reasoning-v1`, `agentic-v1`, `coding-v1`, etc.) through the TinyAgents `ModelRouter` in `crates/openhuman-core/src/agent/tinyagents/routes.rs` and the provider factory here.
- Run ChatGPT/Codex OAuth (PKCE) for the `openai` cloud slug and persist tokens in the encrypted auth-profile store.
- Expose an OpenAI-compatible `/v1/*` HTTP endpoint guarded by a stable user-managed external bearer.
@@ -24,8 +30,8 @@ Unified inference domain: the canonical home for everything LLM/STT/TTS/embeddin
| `ops.rs` | Canonical handler file — `inference_*` business logic returning `RpcOutcome<T>`; delegates to `local`, `provider`, `sentiment`, `device`, `presets`, `openai_oauth`. Includes Sentry-noise suppression for expected provider/user-config failures. |
| `schemas.rs` + `schemas/` (`catalog.rs`, `prompt_handlers.rs`, `oauth_handlers.rs`, `claude_code_handlers.rs`, `settings_handlers.rs`) | `inference.*` controller schemas + `handle_*` fns + param DTOs. |
| `auth_error_registry.rs` | Process-lived registry of rejected BYO keys (401/403): `record`/`clear`/`snapshot` feed `inference.provider_auth_errors` and the one-shot `DomainEvent::ProviderApiKeyRejected`. |
-| `vision_models.rs` | `is_vision_capable` — which local model ids accept image input; every vision path resolves through it first. |
-| `temperature.rs` | `temperature_for_model` — omits `temperature` for models listed in `config.temperature_unsupported_models` (shell-style `*` globs). |
+| `tinyinference::model::model_id_supports_vision` | Upstream capability hint used directly for local model ids when the runtime cannot return an authoritative profile. |
+| `tinyinference::model::effective_temperature` | Applies unsupported-model glob patterns and overrides before provider serialization. |
| `types.rs` | Serde DTOs: `LocalAiStatus`, `LocalAiAssetsStatus`, `LocalAiDownloadsProgress`, `LocalAiEmbeddingResult`, `LocalAiSpeechResult`, `LocalAiTtsResult`, etc. |
| `device.rs` | `DeviceProfile` hardware detection (RAM/CPU/GPU/OS), cached. |
| `model_ids.rs` | Effective chat/vision/embedding/STT/TTS/quantization model id resolution from config. |
@@ -54,7 +60,7 @@ Unified inference domain: the canonical home for everything LLM/STT/TTS/embeddin
| `provider/claude_agent_sdk/` | Claude Agent SDK subprocess provider (`protocol.rs`, `subprocess.rs`). |
| `provider/claude_code/` | Claude Code CLI provider (`claude-code:<model>`). Drives the `claude` CLI over stream-json; see `provider/claude_code/README.md`. |
| `provider/config_rejection.rs`, `provider/billing_error.rs`, `provider/error_classify.rs`, `provider/error_code.rs`, `provider/fallback_diagnostics.rs`, `provider/chat_template.rs` | Error classifiers (unknown-model / config rejection / budget exhausted / chat-template rejection / backend error codes / background-workload fallback diagnostics). |
-| `provider/auth.rs` | `AuthStyle` (`None`/`Bearer`/`XApiKey`/`Anthropic`/`Custom`) — wire auth style shared by the crate-native builders. |
+| `tinyinference::providers::openai::AuthStyle` | Wire auth style consumed directly by crate-native builders. |
| `provider/ops/` | Split from a single `ops.rs`: `sanitize` (secret scrubbing), `http_error` (HTTP error classification, Sentry routing, `api_error`), `models` (`list_configured_models`), `provider_factory` (`ProviderRuntimeOptions`, `list_providers`). |
| `provider/schemas.rs` | Defines a `providers.list_models` controller that is **not** wired into `core/all.rs`; the live method is `inference.list_models` (`openhuman.providers_list_models` survives only as a legacy alias). |
| `voice/` | Inference implementations imported by `crate::voice`. |
diff --git a/crates/openhuman-core/src/inference/embeddings/factory.rs b/crates/openhuman-core/src/inference/embeddings/factory.rs
index d08e5b0f66..a4354a78a9 100644
--- a/crates/openhuman-core/src/inference/embeddings/factory.rs
+++ b/crates/openhuman-core/src/inference/embeddings/factory.rs
@@ -8,26 +8,16 @@ use super::cloud::{
};
use super::provider_trait::{EmbeddingProvider, TinyAgentsEmbeddingProvider};
use crate::config::Config;
-use tinyinference::embeddings::EmbeddingModel;
use tinyinference::embeddings::{
- CohereEmbeddingModel, NoopEmbeddingModel, OllamaEmbeddingModel, OpenAiEmbeddingModel,
- VoyageEmbeddingModel,
+ model_supports_dimensions, CohereEmbeddingModel, NoopEmbeddingModel, OllamaEmbeddingModel,
+ OpenAiEmbeddingModel, VoyageEmbeddingModel,
};
/// Build the provider for an OpenAI-compatible custom endpoint.
///
-/// `dims == 0` is the dimension-agnostic PROBE mode (issue #4056): send no
-/// `dimensions` param, accept whatever length comes back, let the caller adopt
-/// it. tinyinference's `OpenAiEmbeddingModel::embed` used to implement exactly
-/// that (its `parse_vectors` still skips the length guard when
-/// `dimensions == 0`), but the tinyagents pointer refresh brought a version
-/// whose `embed()` rejects `dimensions == 0` outright before the request is
-/// built — the two halves of that file now contradict, and the refusal breaks
-/// the Test-connection and save-time probes for every model outside the
-/// `text-embedding-3-*` family. Until that is reconciled upstream, the probe
-/// mode is served host-side by [`DimensionAgnosticOpenAiProbe`]; delete that
-/// type and route `dims == 0` back through `openai_model` once upstream
-/// honours it again.
+/// `dims == 0` is the TinyInference dimension-discovery mode (issue #4056):
+/// send no `dimensions` parameter, accept the returned vector length, and let
+/// the caller adopt it.
fn custom_openai_provider(
base_url: &str,
api_key: &str,
@@ -35,127 +25,9 @@ fn custom_openai_provider(
dims: usize,
) -> anyhow::Result<Box<dyn EmbeddingProvider>> {
let base_url = validate_custom_endpoint(base_url, !api_key.is_empty())?;
- if dims == 0 {
- Ok(Box::new(DimensionAgnosticOpenAiProbe::new(
- openai_model(&base_url, api_key, model, 0, false),
- api_key,
- )))
- } else {
- Ok(TinyAgentsEmbeddingProvider::boxed(openai_model(
- &base_url, api_key, model, dims, false,
- )))
- }
-}
-
-/// The dimension-agnostic probe for an OpenAI-compatible endpoint.
-///
-/// Exists only because upstream's `embed()` refuses `dimensions == 0` (see
-/// [`custom_openai_provider`]). One request shape, deliberately minimal: POST
-/// `{model, input}` — never a `dimensions` param — bearer auth when a key is
-/// present, and no vector-length guard, because learning the endpoint's real
-/// length is the entire point of the call.
-struct DimensionAgnosticOpenAiProbe {
- /// Used for URL building, naming and the signature — not for `embed`.
- inner: OpenAiEmbeddingModel,
- /// Kept host-side because the inner model does not expose its key.
- api_key: String,
-}
-
-impl DimensionAgnosticOpenAiProbe {
- fn new(inner: OpenAiEmbeddingModel, api_key: &str) -> Self {
- Self {
- inner,
- api_key: api_key.to_owned(),
- }
- }
-}
-
-#[async_trait::async_trait]
-impl EmbeddingProvider for DimensionAgnosticOpenAiProbe {
- fn name(&self) -> &str {
- self.inner.name()
- }
-
- fn model_id(&self) -> &str {
- self.inner.model_id()
- }
-
- fn dimensions(&self) -> usize {
- 0
- }
-
- fn signature(&self) -> String {
- self.inner.signature()
- }
-
- async fn embed(&self, texts: &[&str]) -> anyhow::Result<Vec<Vec<f32>>> {
- if texts.is_empty() {
- return Ok(Vec::new());
- }
- let url = self.inner.embeddings_url();
- let mut request = reqwest::Client::new().post(&url).json(&serde_json::json!({
- "model": self.inner.model(),
- "input": texts,
- }));
- if !self.api_key.is_empty() {
- request = request.header("Authorization", format!("Bearer {}", self.api_key));
- }
- let response = request
- .send()
- .await
- .map_err(|e| anyhow::anyhow!("openai embeddings request to {url} failed: {e}"))?;
- let status = response.status();
- let text = response
- .text()
- .await
- .map_err(|e| anyhow::anyhow!("openai embeddings body read failed: {e}"))?;
- if !status.is_success() {
- anyhow::bail!("openai embeddings returned HTTP {status}: {text}");
- }
- let value: serde_json::Value = serde_json::from_str(&text)?;
- let data = value
- .get("data")
- .and_then(serde_json::Value::as_array)
- .ok_or_else(|| anyhow::anyhow!("openai embeddings response missing `data` array"))?;
- if data.len() != texts.len() {
- anyhow::bail!(
- "openai embed count mismatch: sent {} texts, got {} embeddings",
- texts.len(),
- data.len()
- );
- }
- let mut vectors: Vec<Option<Vec<f32>>> = vec![None; texts.len()];
- for item in data {
- let index = item
- .get("index")
- .and_then(serde_json::Value::as_u64)
- .and_then(|v| usize::try_from(v).ok())
- .filter(|i| *i < texts.len())
- .ok_or_else(|| anyhow::anyhow!("openai embedding is missing a valid `index`"))?;
- let embedding = item
- .get("embedding")
- .and_then(serde_json::Value::as_array)
- .ok_or_else(|| {
- anyhow::anyhow!("openai embeddings response missing `embedding` array")
- })?;
- let vector = embedding
- .iter()
- .map(|n| {
- n.as_f64().map(|v| v as f32).ok_or_else(|| {
- anyhow::anyhow!("openai embeddings response contains a non-numeric value")
- })
- })
- .collect::<anyhow::Result<Vec<f32>>>()?;
- vectors[index] = Some(vector);
- }
- vectors
- .into_iter()
- .enumerate()
- .map(|(i, v)| {
- v.ok_or_else(|| anyhow::anyhow!("openai embeddings response is missing index {i}"))
- })
- .collect()
- }
+ Ok(TinyAgentsEmbeddingProvider::boxed(openai_model(
+ &base_url, api_key, model, dims, false,
+ )))
}
fn openai_model(
@@ -205,27 +77,6 @@ fn validate_custom_endpoint(endpoint: &str, has_credentials: bool) -> anyhow::Re
Ok(endpoint.to_owned())
}
-/// Whether to send the OpenAI `dimensions` request-body parameter for this
-/// model. Only the `text-embedding-3-*` family honors it (it's how 3-large is
-/// pinned to 1024 = `EMBEDDING_DIM`). Sending it to other models or to
-/// arbitrary OpenAI-compatible servers (vLLM, text-embeddings-inference,
-/// stricter LocalAI builds) makes those servers 400 on an unknown field, so we
-/// gate on the model id rather than the provider kind. (Reviewer sanil-23, #3076.)
-pub(crate) fn model_supports_dimensions(model: &str) -> bool {
- model.starts_with("text-embedding-3-")
-}
-
-/// The members of that family, by name, for a consumer that cannot call the
-/// predicate.
-///
-/// The tinymemory module's `EmbeddingHost::model_supports_dimensions` is
-/// synchronous and runs inside the module, so it is told a list at load time
-/// (`modules::ops::module_config`) rather than asking over the bus. Absent from
-/// the list means "does not support it", the safe direction: the engine omits
-/// the parameter instead of writing a batch the provider rejects halfway.
-pub(crate) const MODELS_SUPPORTING_DIMENSIONS: [&str; 2] =
- ["text-embedding-3-small", "text-embedding-3-large"];
-
/// Creates an embedding provider based on the specified name and configuration.
///
/// Supported provider names:
diff --git a/crates/openhuman-core/src/inference/embeddings/mod.rs b/crates/openhuman-core/src/inference/embeddings/mod.rs
index 5e94775fae..6242f8edcd 100644
--- a/crates/openhuman-core/src/inference/embeddings/mod.rs
+++ b/crates/openhuman-core/src/inference/embeddings/mod.rs
@@ -46,21 +46,6 @@ pub use factory::{
create_embedding_provider_with_credentials, default_embedding_provider,
default_embedding_provider_with_config, default_local_embedding_provider,
};
-// `pub(crate)` helper — reused by the memory-tree OpenAI-compat adapter to gate
-// configs whose dimension the fixed-1024 tree can't store (#4056). Not part of
-// the public surface, so it can't ride the `pub use` above (E0364).
-// Read only by `modules::ops`, so gated with it — otherwise every feature set
-// without `modules` (the `flows` lane among them) carries an unused-import
-// warning. Pre-dates #5560; fixed here because the line next to it moved.
-#[cfg(feature = "modules")]
-pub(crate) use factory::MODELS_SUPPORTING_DIMENSIONS;
-// `model_supports_dimensions` used to be re-exported here beside it, for
-// `memory::host_impls`. That file is gone with the in-process engine
-// (openhuman#6161), and so is the re-export — the function is not test-only,
-// and `factory` and `embeddings::rpc` both reach it directly through
-// `super::factory::`, so nothing else had to move.
-// #002 FR-015: the memory-tree OpenAI-compat embedder reuses the same key
-// resolution the embeddings RPC uses, so there is one source of truth.
pub use noop::NoopEmbedding;
pub use provider_trait::{
format_embedding_signature, EmbeddingProvider, TinyAgentsEmbeddingProvider,
diff --git a/crates/openhuman-core/src/inference/embeddings/rpc/probe.rs b/crates/openhuman-core/src/inference/embeddings/rpc/probe.rs
index fd1863d550..50dce7aab5 100644
--- a/crates/openhuman-core/src/inference/embeddings/rpc/probe.rs
+++ b/crates/openhuman-core/src/inference/embeddings/rpc/probe.rs
@@ -3,7 +3,7 @@
use crate::rpc::RpcOutcome;
-use crate::inference::embeddings::factory::model_supports_dimensions;
+use tinyinference::embeddings::model_supports_dimensions;
/// Send one OpenAI-compatible embedding request without requesting or
/// validating a vector width. This is intentionally separate from the live
diff --git a/crates/openhuman-core/src/inference/http/server.rs b/crates/openhuman-core/src/inference/http/server.rs
index f545d2b18c..7a85d797c6 100644
--- a/crates/openhuman-core/src/inference/http/server.rs
+++ b/crates/openhuman-core/src/inference/http/server.rs
@@ -130,8 +130,12 @@ async fn chat_completions_handler(
// check on the outbound body, so this is belt-and-suspenders for logging.
let temperature = {
let raw = req.temperature.unwrap_or(config.default_temperature);
- let suppressed =
- crate::inference::temperature::temperature_for_model(&model_id, raw, &config);
+ let suppressed = tinyinference::model::effective_temperature(
+ &model_id,
+ Some(raw),
+ None,
+ &config.temperature_unsupported_models,
+ );
if suppressed.is_none() && req.temperature.is_some() {
tracing::warn!(
model = %model_id,
diff --git a/crates/openhuman-core/src/inference/mod.rs b/crates/openhuman-core/src/inference/mod.rs
index 9c4888f511..09141e2a84 100644
--- a/crates/openhuman-core/src/inference/mod.rs
+++ b/crates/openhuman-core/src/inference/mod.rs
@@ -1,6 +1,7 @@
-//! Unified inference domain.
+//! OpenHuman inference integration domain.
//!
-//! This module is the canonical home for all inference concerns:
+//! TinyInference owns reusable model/provider behavior. This module owns the
+//! product-facing configuration, policy, process lifecycle, and RPC seams:
//! - `local/` — Ollama / LM Studio / Piper runtime management
//! (was `local_ai/`)
//! - `provider/` — native chat models, cloud/local routing, auth and errors
@@ -38,10 +39,8 @@ pub mod presets;
pub mod provider;
mod schemas;
pub mod sentiment;
-pub mod temperature;
pub mod tokenjuice;
pub mod types;
-pub mod vision_models;
pub mod voice;
pub use ops as rpc;
diff --git a/crates/openhuman-core/src/inference/model_context.rs b/crates/openhuman-core/src/inference/model_context.rs
index 19b13f6a38..a5233f9370 100644
--- a/crates/openhuman-core/src/inference/model_context.rs
+++ b/crates/openhuman-core/src/inference/model_context.rs
@@ -83,45 +83,6 @@ pub fn context_window_for_model(model: &str) -> Option<u64> {
return Some(window);
}
- // The crate's `context_window_for_model_id` resolves the canonical o1/o3
- // ids (`o1`, `o1-mini`, `openai/o1-preview`, …) but does not match an
- // `o1`/`o3` token embedded mid-name (e.g. `ollama/mistral-for-o1-benchmark`).
- // OpenHuman keeps that segment heuristic host-side to preserve the
- // pre-port behavior (regression guard from PR #2100) until the crate
- // matcher covers internal segments.
- if let Some(window) = o1_o3_segment_context(normalized) {
- tracing::debug!(
- model = normalized,
- context_window = window,
- "[model_context] matched host o1/o3 segment heuristic"
- );
- return Some(window);
- }
-
- None
-}
-
-/// Match a bounded `o1`/`o3` segment anywhere in the model id and map it to the
-/// OpenAI reasoning-model 200K window. The token must be delimited by a
-/// non-alphanumeric boundary (or string start/end) on both sides so substrings
-/// like `solo1-7b`, `proto3-chat`, or `octo3thing` do **not** over-match.
-fn o1_o3_segment_context(model: &str) -> Option<u64> {
- const O_SERIES_CONTEXT: u64 = 200_000;
- let bytes = model.as_bytes();
- let n = bytes.len();
- let mut i = 0;
- while i + 1 < n {
- let is_o = bytes[i] == b'o' || bytes[i] == b'O';
- if is_o && (bytes[i + 1] == b'1' || bytes[i + 1] == b'3') {
- let before_ok = i == 0 || !bytes[i - 1].is_ascii_alphanumeric();
- let after = i + 2;
- let after_ok = after >= n || !bytes[after].is_ascii_alphanumeric();
- if before_ok && after_ok {
- return Some(O_SERIES_CONTEXT);
- }
- }
- i += 1;
- }
None
}
diff --git a/crates/openhuman-core/src/inference/model_ids.rs b/crates/openhuman-core/src/inference/model_ids.rs
index acc15ea1d7..321a7ebc55 100644
--- a/crates/openhuman-core/src/inference/model_ids.rs
+++ b/crates/openhuman-core/src/inference/model_ids.rs
@@ -11,7 +11,9 @@
use crate::config::Config;
use crate::inference::local::provider::{provider_from_config, LocalAiProvider};
-use crate::inference::vision_models::{self, VISION_MODEL_SUGGESTIONS};
+
+const VISION_MODEL_SUGGESTIONS: &[&str] =
+ &["moondream:1.8b-v2-q4_K_S", "llava:7b", "gemma3:4b-it-qat"];
pub(crate) const DEFAULT_OLLAMA_MODEL: &str = "gemma3:1b-it-qat";
@@ -120,7 +122,7 @@ fn enforce_mvp_chat_allowlist(resolved: &str) -> String {
/// came about. Both that bug and its replacement failed the same way: they
/// answered "which model?" with something the user never asked for.
fn enforce_vision_capability(resolved: &str) -> Result<String, String> {
- if vision_models::is_vision_capable(resolved) {
+ if tinyinference::model::model_id_supports_vision(resolved) {
return Ok(resolved.to_string());
}
tracing::warn!(
@@ -248,7 +250,7 @@ pub(crate) fn effective_vision_model_id(config: &Config) -> String {
return String::new();
}
let resolved = apply_vision_alias(raw);
- if vision_models::is_vision_capable(resolved) {
+ if tinyinference::model::model_id_supports_vision(resolved) {
resolved.to_string()
} else {
String::new()
diff --git a/crates/openhuman-core/src/inference/model_ids_tests.rs b/crates/openhuman-core/src/inference/model_ids_tests.rs
index 28d9ebe76d..bc9b217486 100644
--- a/crates/openhuman-core/src/inference/model_ids_tests.rs
+++ b/crates/openhuman-core/src/inference/model_ids_tests.rs
@@ -168,7 +168,9 @@ fn chat_only_vision_model_resolves_to_nothing_usable() {
#[test]
fn default_vision_model_is_vision_capable() {
assert!(!DEFAULT_LOW_VISION_MODEL.is_empty());
- assert!(vision_models::is_vision_capable(DEFAULT_LOW_VISION_MODEL));
+ assert!(tinyinference::model::model_id_supports_vision(
+ DEFAULT_LOW_VISION_MODEL
+ ));
}
/// #5146 §Part 1: an unconfigured vision model must produce an actionable
@@ -211,7 +213,7 @@ fn resolve_vision_model_id_still_applies_the_moondream_alias() {
let resolved = resolve_vision_model_id(&config)
.unwrap_or_else(|e| panic!("alias {alias} must resolve, got: {e}"));
assert_eq!(resolved, DEFAULT_LOW_VISION_MODEL);
- assert!(vision_models::is_vision_capable(&resolved));
+ assert!(tinyinference::model::model_id_supports_vision(&resolved));
}
}
diff --git a/crates/openhuman-core/src/inference/presets_tests_2_tests.rs b/crates/openhuman-core/src/inference/presets_tests_2_tests.rs
index d78d18cd26..b9880c7084 100644
--- a/crates/openhuman-core/src/inference/presets_tests_2_tests.rs
+++ b/crates/openhuman-core/src/inference/presets_tests_2_tests.rs
@@ -167,7 +167,7 @@ fn preset_model_ids_are_fully_qualified() {
/// fabricated description of an image the model never saw.
#[test]
fn preset_vision_models_are_vision_capable() {
- use crate::inference::vision_models::is_vision_capable;
+ use tinyinference::model::model_id_supports_vision;
for preset in all_presets() {
match preset.vision_mode {
@@ -178,7 +178,7 @@ fn preset_vision_models_are_vision_capable() {
preset.vision_model_id
),
VisionMode::Ondemand | VisionMode::Bundled => assert!(
- is_vision_capable(preset.vision_model_id),
+ model_id_supports_vision(preset.vision_model_id),
"preset {:?} routes vision at `{}`, which is not vision-capable",
preset.tier,
preset.vision_model_id
@@ -193,10 +193,10 @@ fn preset_vision_models_are_vision_capable() {
/// tier's `Bundled` vision mode is real rather than nominal.
#[test]
fn high_tier_preset_uses_one_multimodal_build_for_chat_and_vision() {
- use crate::inference::vision_models::is_vision_capable;
+ use tinyinference::model::model_id_supports_vision;
let preset = preset_for_tier(ModelTier::Ram16PlusGb).expect("16 GB+ preset");
assert_eq!(preset.chat_model_id, "gemma4:e4b-it-q8_0");
assert_eq!(preset.vision_model_id, preset.chat_model_id);
- assert!(is_vision_capable(preset.vision_model_id));
+ assert!(model_id_supports_vision(preset.vision_model_id));
}
diff --git a/crates/openhuman-core/src/inference/provider/auth.rs b/crates/openhuman-core/src/inference/provider/auth.rs
deleted file mode 100644
index 5f3ff49cfe..0000000000
--- a/crates/openhuman-core/src/inference/provider/auth.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//! Wire authentication styles shared by crate-native provider builders.
-
-#[derive(Debug, Clone)]
-pub enum AuthStyle {
- None,
- Bearer,
- XApiKey,
- Anthropic,
- Custom(String),
-}
diff --git a/crates/openhuman-core/src/inference/provider/chat_template.rs b/crates/openhuman-core/src/inference/provider/chat_template.rs
deleted file mode 100644
index ae806120a9..0000000000
--- a/crates/openhuman-core/src/inference/provider/chat_template.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-//! Host compatibility path for TinyAgents' provider-neutral chat-template
-//! rejection classifier.
-//!
-//! OpenHuman retains the user-facing error mapping in `web_chat::web_errors`;
-//! reusable recognition of LM Studio, llama.cpp, and Ollama template-engine
-//! failures belongs to the default inference driver.
-
-pub use tinyinference::providers::openai::is_chat_template_rejection_message;
diff --git a/crates/openhuman-core/src/inference/provider/crate_anthropic.rs b/crates/openhuman-core/src/inference/provider/crate_anthropic.rs
index 45b7562eeb..c9f41454e4 100644
--- a/crates/openhuman-core/src/inference/provider/crate_anthropic.rs
+++ b/crates/openhuman-core/src/inference/provider/crate_anthropic.rs
@@ -19,7 +19,7 @@
use std::sync::Arc;
-use tinyinference::model::{ChatModel, ModelRequest, ModelResponse, ModelStream};
+use tinyinference::model::ChatModel;
use tinyinference::providers::anthropic::AnthropicModel;
/// Whether an endpoint is known to speak the Anthropic Messages API.
@@ -51,75 +51,6 @@ pub(crate) struct CrateAnthropicConfig<'a> {
pub temperature_unsupported_models: &'a [String],
}
-struct TemperatureUnsupportedAnthropicModel {
- inner: Arc<dyn ChatModel<()>>,
- default_model: String,
- patterns: Vec<String>,
- temperature_override: Option<f64>,
-}
-
-impl TemperatureUnsupportedAnthropicModel {
- fn suppress_temperature(&self, request: &mut ModelRequest) {
- let model = request.model.as_deref().unwrap_or(&self.default_model);
- request.temperature = temperature_for_model(
- model,
- request.temperature,
- &self.patterns,
- self.temperature_override,
- );
- }
-}
-
-fn temperature_for_model(
- model: &str,
- request_temperature: Option<f64>,
- patterns: &[String],
- temperature_override: Option<f64>,
-) -> Option<f64> {
- if patterns
- .iter()
- .any(|pattern| crate::inference::temperature::glob_match(pattern, model))
- {
- None
- } else {
- // The adapter's fixed override is deliberately not configured when
- // this wrapper is active: unlike the wrapper, the adapter cannot see
- // the effective per-request model before applying it. Preserve the
- // caller/default-model temperature when no explicit suffix override
- // was supplied.
- temperature_override.or(request_temperature)
- }
-}
-
-#[async_trait::async_trait]
-impl ChatModel<()> for TemperatureUnsupportedAnthropicModel {
- fn profile(&self) -> Option<&tinyinference::model::ModelProfile> {
- self.inner.profile()
- }
-
- fn cache_identity(&self) -> Option<String> {
- self.inner.cache_identity()
- }
-
- async fn invoke(
- &self,
- state: &(),
- mut request: ModelRequest,
- ) -> tinyinference::Result<ModelResponse> {
- self.suppress_temperature(&mut request);
- self.inner.invoke(state, request).await
- }
-
- async fn stream(
- &self,
- state: &(),
- mut request: ModelRequest,
- ) -> tinyinference::Result<ModelStream> {
- self.suppress_temperature(&mut request);
- self.inner.stream(state, request).await
- }
-}
-
/// Build a crate-native [`AnthropicModel`] (`ChatModel`) for the given config.
pub(crate) fn build_crate_anthropic_model(
config: CrateAnthropicConfig<'_>,
@@ -130,29 +61,11 @@ pub(crate) fn build_crate_anthropic_model(
config.model,
config.temperature_override
);
- // If there are unsupported-model patterns, defer the override to the
- // wrapper below. AnthropicModel applies its fixed override after the
- // request is prepared and therefore cannot honour a per-request model's
- // suppression decision.
- let adapter_temperature_override = if config.temperature_unsupported_models.is_empty() {
- config.temperature_override
- } else {
- None
- };
let model = AnthropicModel::with_base_url(config.api_key, config.endpoint)
.with_model(config.model)
- .with_temperature_override(adapter_temperature_override);
- let model: Arc<dyn ChatModel<()>> = Arc::new(model);
- if config.temperature_unsupported_models.is_empty() {
- model
- } else {
- Arc::new(TemperatureUnsupportedAnthropicModel {
- inner: model,
- default_model: config.model.to_string(),
- patterns: config.temperature_unsupported_models.to_vec(),
- temperature_override: config.temperature_override,
- })
- }
+ .with_temperature_override(config.temperature_override)
+ .with_temperature_unsupported_models(config.temperature_unsupported_models.iter().cloned());
+ Arc::new(model)
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/inference/provider/crate_anthropic_tests.rs b/crates/openhuman-core/src/inference/provider/crate_anthropic_tests.rs
index 2ea9918858..22c41bf075 100644
--- a/crates/openhuman-core/src/inference/provider/crate_anthropic_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/crate_anthropic_tests.rs
@@ -33,24 +33,3 @@ fn builds_a_native_anthropic_model_with_the_configured_profile() {
assert!(identity.contains("api.anthropic.com"));
assert!(!identity.contains("sk-ant-secret"));
}
-
-#[test]
-fn temperature_override_follows_the_effective_model() {
- let patterns = vec!["claude-3-5-*".to_string()];
- assert_eq!(
- temperature_for_model("claude-3-5-sonnet", Some(0.7), &patterns, Some(0.2)),
- None
- );
- assert_eq!(
- temperature_for_model("claude-sonnet-4-6", Some(0.7), &patterns, Some(0.2)),
- Some(0.2)
- );
- assert_eq!(
- temperature_for_model("claude-sonnet-4-6", Some(0.7), &patterns, None),
- Some(0.7)
- );
- assert_eq!(
- temperature_for_model("claude-sonnet-4-6", None, &patterns, None),
- None
- );
-}
diff --git a/crates/openhuman-core/src/inference/provider/crate_openai.rs b/crates/openhuman-core/src/inference/provider/crate_openai.rs
index a6c7323c99..3562d13794 100644
--- a/crates/openhuman-core/src/inference/provider/crate_openai.rs
+++ b/crates/openhuman-core/src/inference/provider/crate_openai.rs
@@ -15,27 +15,13 @@
//! (`/v1/responses` + query-param auth) — stay as host `ChatModel` impls and do
//! **not** route through here.
//!
-//! The builder + auth mapping are the factory's default construction path and
-//! are covered by the provider wire-parity suite.
+//! The builder is the factory's default construction path and consumes
+//! TinyInference's auth style directly.
use std::sync::Arc;
use tinyinference::model::ChatModel;
-use tinyinference::providers::openai::{AuthStyle as CrateAuthStyle, OpenAiModel};
-
-use super::auth::AuthStyle as HostAuthStyle;
-
-/// Map the host [`AuthStyle`](HostAuthStyle) to the crate's `AuthStyle`. The
-/// variants are 1:1 (both were derived from the same OpenHuman provider catalog).
-pub(crate) fn map_auth_style(host: HostAuthStyle) -> CrateAuthStyle {
- match host {
- HostAuthStyle::None => CrateAuthStyle::None,
- HostAuthStyle::Bearer => CrateAuthStyle::Bearer,
- HostAuthStyle::XApiKey => CrateAuthStyle::XApiKey,
- HostAuthStyle::Anthropic => CrateAuthStyle::Anthropic,
- HostAuthStyle::Custom(header) => CrateAuthStyle::Custom(header),
- }
-}
+use tinyinference::providers::openai::{AuthStyle as HostAuthStyle, OpenAiModel};
/// The resolved config for one OpenAI-compatible provider, mirroring the inputs
/// the host [`build_compatible_provider`](super::factory) helper takes. Kept as a
@@ -119,7 +105,7 @@ pub(crate) fn build_crate_openai_model(config: CrateOpenAiConfig<'_>) -> Arc<dyn
config.endpoint,
config.model,
)
- .with_auth_style(map_auth_style(config.auth_style));
+ .with_auth_style(config.auth_style);
if !config.temperature_unsupported_models.is_empty() {
model = model
diff --git a/crates/openhuman-core/src/inference/provider/crate_openai_tests.rs b/crates/openhuman-core/src/inference/provider/crate_openai_tests.rs
index a9e8f73ebf..48873a78c9 100644
--- a/crates/openhuman-core/src/inference/provider/crate_openai_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/crate_openai_tests.rs
@@ -1,26 +1,5 @@
use super::*;
-#[test]
-fn maps_every_host_auth_style_one_to_one() {
- assert_eq!(map_auth_style(HostAuthStyle::None), CrateAuthStyle::None);
- assert_eq!(
- map_auth_style(HostAuthStyle::Bearer),
- CrateAuthStyle::Bearer
- );
- assert_eq!(
- map_auth_style(HostAuthStyle::XApiKey),
- CrateAuthStyle::XApiKey
- );
- assert_eq!(
- map_auth_style(HostAuthStyle::Anthropic),
- CrateAuthStyle::Anthropic
- );
- assert_eq!(
- map_auth_style(HostAuthStyle::Custom("x-key".to_string())),
- CrateAuthStyle::Custom("x-key".to_string())
- );
-}
-
#[test]
fn builds_a_chat_model_with_the_configured_profile() {
let model = build_crate_openai_model(CrateOpenAiConfig {
diff --git a/crates/openhuman-core/src/inference/provider/error_classify.rs b/crates/openhuman-core/src/inference/provider/error_classify.rs
index 1d2d229f92..c8fdedbc3c 100644
--- a/crates/openhuman-core/src/inference/provider/error_classify.rs
+++ b/crates/openhuman-core/src/inference/provider/error_classify.rs
@@ -1,7 +1,7 @@
-//! OpenHuman-specific policy layered on TinyAgents' provider-neutral retry classifier.
+//! OpenHuman-specific policy layered on TinyInference's provider-neutral classifier.
-use tinyagents_harness::retry::{
- classify_provider_failure, parse_retry_after_ms as parse_tinyagents_retry_after,
+use tinyinference::failure::{
+ classify_provider_failure, parse_retry_after_ms as parse_inference_retry_after,
ProviderFailureClass,
};
@@ -44,7 +44,7 @@ pub(crate) fn is_upstream_unhealthy(err: &anyhow::Error) -> bool {
}
pub(crate) fn parse_retry_after_ms(err: &anyhow::Error) -> Option<u64> {
- parse_tinyagents_retry_after(&err.to_string())
+ parse_inference_retry_after(&err.to_string())
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/inference/provider/factory.rs b/crates/openhuman-core/src/inference/provider/factory.rs
index dc29ee8f6e..f87d38fe0c 100644
--- a/crates/openhuman-core/src/inference/provider/factory.rs
+++ b/crates/openhuman-core/src/inference/provider/factory.rs
@@ -115,7 +115,6 @@ mod factory_tests;
use crate::config::schema::cloud_providers::AuthStyle;
use crate::config::Config;
-use crate::inference::provider::auth::AuthStyle as CompatAuthStyle;
use crate::inference::provider::claude_agent_sdk::subprocess::ClaudeAgentSdkProvider;
use crate::inference::provider::openai_codex::{
openai_codex_client_version, openai_codex_user_agent, resolve_openai_codex_routing,
@@ -126,6 +125,7 @@ use crate::inference::provider::ProviderRuntimeOptions;
use crate::security::credentials::AuthService;
use std::sync::Arc;
use tinyinference::model::{ChatModel, ModelRequest, ModelResponse, ModelStream};
+use tinyinference::providers::openai::AuthStyle as CompatAuthStyle;
/// Sentinel meaning "use the OpenHuman backend session JWT".
pub const PROVIDER_OPENHUMAN: &str = "openhuman";
diff --git a/crates/openhuman-core/src/inference/provider/mod.rs b/crates/openhuman-core/src/inference/provider/mod.rs
index 01dc01d180..304aea3e12 100644
--- a/crates/openhuman-core/src/inference/provider/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/mod.rs
@@ -5,10 +5,7 @@
//! inference concerns (local runtime, cloud providers, HTTP endpoint) share
//! a single domain root.
-pub mod auth;
pub mod billing_error;
-/// Chat-template rejections from local serving runtimes (issue #5291).
-pub mod chat_template;
pub mod claude_agent_sdk;
pub mod claude_code;
pub mod config_rejection;
@@ -34,7 +31,6 @@ pub use types::{
};
pub use billing_error::is_budget_exhausted_message;
-pub use chat_template::is_chat_template_rejection_message;
pub use config_rejection::{
is_openai_compatible_unknown_model_message, is_provider_config_rejection_message,
};
diff --git a/crates/openhuman-core/src/inference/temperature.rs b/crates/openhuman-core/src/inference/temperature.rs
deleted file mode 100644
index 88fc5b12a2..0000000000
--- a/crates/openhuman-core/src/inference/temperature.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-//! Host-owned per-model temperature suppression helpers.
-//!
-//! Some models (OpenAI o-series, GPT-5 reasoning variants) reject the
-//! `temperature` field in the request body and return an error when it is
-//! present. `temperature_for_model` consults the config's
-//! `temperature_unsupported_models` list (which accepts shell-style `*`
-//! globs) and returns `None` when the model matches, causing the
-//! serialisation layer to omit the field via `skip_serializing_if`.
-
-use crate::config::Config;
-
-/// Returns the effective temperature for `model`, or `None` if the model
-/// is listed in `config.temperature_unsupported_models`.
-///
-/// The list entries support shell-style `*` wildcard matching (no `?` or
-/// `[]`). Matching is case-sensitive and done against the full model ID.
-///
-/// # Examples
-///
-/// ```
-/// // model "o1-preview" matches pattern "o1*" → None
-/// // model "gpt-4o-mini" matches no pattern → Some(0.7)
-/// ```
-pub fn temperature_for_model(model: &str, default: f64, config: &Config) -> Option<f64> {
- if config
- .temperature_unsupported_models
- .iter()
- .any(|pat| glob_match(pat, model))
- {
- tracing::debug!(
- "[inference][temperature] model='{}' matched unsupported-temperature list — omitting temperature field",
- model
- );
- None
- } else {
- Some(default)
- }
-}
-
-/// Minimal shell-style glob matcher supporting only `*` (match any sequence
-/// of characters, including empty). Does not support `?` or `[...]`.
-///
-/// This avoids pulling in the `glob` crate for what is effectively a
-/// starts-with / ends-with / contains check.
-pub fn glob_match(pattern: &str, text: &str) -> bool {
- // Split on `*` and consume the text segment by segment.
- let parts: Vec<&str> = pattern.split('*').collect();
-
- if parts.is_empty() {
- // Pattern is purely `*` — matches everything.
- return true;
- }
-
- let mut remaining = text;
-
- for (i, part) in parts.iter().enumerate() {
- if part.is_empty() {
- // Consecutive stars or leading/trailing star — skip.
- continue;
- }
-
- if i == 0 {
- // First segment: must match the start of `text`.
- if !remaining.starts_with(part) {
- return false;
- }
- remaining = &remaining[part.len()..];
- } else {
- // Middle or last segment: find first occurrence in `remaining`.
- match remaining.find(part) {
- Some(pos) => {
- remaining = &remaining[pos + part.len()..];
- }
- None => return false,
- }
- }
- }
-
- // If the pattern did NOT end with `*`, the remaining text must be empty.
- if !pattern.ends_with('*') && !remaining.is_empty() {
- return false;
- }
-
- true
-}
-
-#[cfg(test)]
-#[path = "temperature_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/inference/temperature_tests.rs b/crates/openhuman-core/src/inference/temperature_tests.rs
deleted file mode 100644
index 18e085a486..0000000000
--- a/crates/openhuman-core/src/inference/temperature_tests.rs
+++ /dev/null
@@ -1,172 +0,0 @@
-use super::*;
-use crate::config::Config;
-
-// ── glob_match unit tests ─────────────────────────────────────────────────
-
-#[test]
-fn glob_exact_match() {
- assert!(glob_match("o1-preview", "o1-preview"));
-}
-
-#[test]
-fn glob_prefix_star() {
- assert!(glob_match("o1*", "o1-preview"));
- assert!(glob_match("o1*", "o1-mini"));
- assert!(glob_match("o1*", "o1"));
- assert!(!glob_match("o1*", "gpt-4o"));
-}
-
-#[test]
-fn glob_suffix_star() {
- assert!(glob_match("*mini", "gpt-4o-mini"));
- assert!(!glob_match("*mini", "gpt-4o-large"));
-}
-
-#[test]
-fn glob_contains_star() {
- assert!(glob_match("gpt*mini", "gpt-4o-mini"));
- assert!(!glob_match("gpt*mini", "gpt-4o-large"));
-}
-
-#[test]
-fn glob_pure_star() {
- assert!(glob_match("*", "anything"));
- assert!(glob_match("*", ""));
-}
-
-#[test]
-fn glob_no_star_mismatch() {
- assert!(!glob_match("o1", "o1-preview"));
- assert!(glob_match("o1", "o1"));
-}
-
-#[test]
-fn glob_gpt5_pattern() {
- assert!(glob_match("gpt-5*", "gpt-5"));
- assert!(glob_match("gpt-5*", "gpt-5-turbo"));
- assert!(!glob_match("gpt-5*", "gpt-4o"));
-}
-
-// ── temperature_for_model tests ───────────────────────────────────────────
-
-fn config_with_unsupported(patterns: Vec<String>) -> Config {
- let mut config = Config::default();
- config.temperature_unsupported_models = patterns;
- config
-}
-
-#[test]
-fn temperature_returned_for_normal_model() {
- let config = Config::default(); // has ["o1*","o3*","o4*","gpt-5*"] by default
- assert_eq!(
- temperature_for_model("gpt-4o-mini", 0.7, &config),
- Some(0.7)
- );
- assert_eq!(
- temperature_for_model("claude-3-opus", 0.5, &config),
- Some(0.5)
- );
-}
-
-#[test]
-fn temperature_suppressed_for_o1_model() {
- let config = Config::default();
- assert_eq!(temperature_for_model("o1-preview", 0.7, &config), None);
- assert_eq!(temperature_for_model("o1-mini", 0.7, &config), None);
- assert_eq!(temperature_for_model("o1", 0.7, &config), None);
-}
-
-#[test]
-fn temperature_suppressed_for_o3_o4() {
- let config = Config::default();
- assert_eq!(temperature_for_model("o3", 0.7, &config), None);
- assert_eq!(temperature_for_model("o3-mini", 0.7, &config), None);
- assert_eq!(temperature_for_model("o4-mini", 0.7, &config), None);
-}
-
-#[test]
-fn temperature_suppressed_for_gpt5() {
- let config = Config::default();
- assert_eq!(temperature_for_model("gpt-5", 0.7, &config), None);
- assert_eq!(temperature_for_model("gpt-5-turbo", 0.7, &config), None);
-}
-
-// -- #2076: Moonshot Kimi K2 family — only accepts temperature: 1 -------
-
-#[test]
-fn temperature_suppressed_for_kimi_k2() {
- // Regression for #2076 (146 Sentry events). The upstream API returns
- // "invalid temperature: only 1 is allowed for this model"
- // when a non-1 temperature is sent for any Kimi K2 variant. Omitting
- // the field entirely is correct — upstream defaults to 1.0.
- let config = Config::default();
- assert_eq!(temperature_for_model("kimi-k2.6", 0.7, &config), None);
- assert_eq!(
- temperature_for_model("kimi-k2-instruct", 0.5, &config),
- None
- );
- assert_eq!(temperature_for_model("kimi-k2-pro", 1.2, &config), None);
-}
-
-#[test]
-fn temperature_suppressed_for_moonshot_namespaced_kimi() {
- // OpenRouter and similar gateways namespace Kimi under
- // `moonshot/...` or `moonshotai/...`. The same temperature
- // constraint applies regardless of how the model id is namespaced.
- let config = Config::default();
- assert_eq!(
- temperature_for_model("moonshot/kimi-k2.6", 0.7, &config),
- None
- );
- assert_eq!(
- temperature_for_model("moonshotai/kimi-k2-instruct", 0.5, &config),
- None
- );
- assert_eq!(temperature_for_model("moonshot-v1-8k", 0.3, &config), None);
-}
-
-#[test]
-fn temperature_still_allowed_for_unrelated_models_after_kimi_additions() {
- // Regression guard: adding the `kimi-k2*` / `moonshot*` patterns
- // must NOT start suppressing temperature for unrelated models.
- // Pin a few common ones that share substrings.
- let config = Config::default();
- // "ki..." prefix that isn't kimi.
- assert_eq!(
- temperature_for_model("kimichat-legacy", 0.7, &config),
- Some(0.7)
- );
- // "moon..." prefix without the rest of the moonshot stem.
- assert_eq!(
- temperature_for_model("moonshine-asr", 0.7, &config),
- Some(0.7)
- );
- // Claude / GPT non-5 / Gemini all stay unaffected.
- assert_eq!(
- temperature_for_model("claude-sonnet-4.6", 0.5, &config),
- Some(0.5)
- );
- assert_eq!(
- temperature_for_model("gemini-2.5-pro", 0.3, &config),
- Some(0.3)
- );
-}
-
-#[test]
-fn temperature_uses_custom_unsupported_list() {
- let config = config_with_unsupported(vec!["custom-*".to_string()]);
- assert_eq!(temperature_for_model("custom-model", 0.7, &config), None);
- assert_eq!(
- temperature_for_model("gpt-4o-mini", 0.7, &config),
- Some(0.7)
- );
- // Default patterns no longer apply when list is replaced.
- assert_eq!(temperature_for_model("o1-preview", 0.7, &config), Some(0.7));
-}
-
-#[test]
-fn temperature_empty_list_always_returns_some() {
- let config = config_with_unsupported(vec![]);
- assert_eq!(temperature_for_model("o1-preview", 0.7, &config), Some(0.7));
- assert_eq!(temperature_for_model("gpt-5", 0.3, &config), Some(0.3));
-}
diff --git a/crates/openhuman-core/src/inference/vision_models.rs b/crates/openhuman-core/src/inference/vision_models.rs
deleted file mode 100644
index 7fb2362536..0000000000
--- a/crates/openhuman-core/src/inference/vision_models.rs
+++ /dev/null
@@ -1,123 +0,0 @@
-//! Which local model IDs can actually accept image input.
-//!
-//! Every vision path resolves its model through this registry first, so a
-//! vision tool-call either reaches a genuinely vision-capable model or surfaces
-//! a clear error. See [`crate::inference::model_ids`].
-//!
-//! ## Why resolve up front rather than let Ollama reject it
-//!
-//! This module originally claimed that routing a vision request at a chat-only
-//! model is *not* a loud failure — that Ollama accepts the `images` array
-//! against any model, silently discards it, and answers from the prompt text
-//! alone, yielding a confident hallucination.
-//!
-//! **That was measured against Ollama 0.32.5 and does not hold** (#5146 P5).
-//! All three endpoints — `/api/generate`, `/api/chat`, and the OpenAI-compatible
-//! `/v1/chat/completions` — reject the request cleanly:
-//!
-//! ```text
-//! HTTP 400 {"error":{"code":400,
-//! "message":"Multimodal data provided, but model does not support multimodal requests.",
-//! "type":"invalid_request_error"}}
-//! ```
-//!
-//! The registry is still worth having, for reasons that do not depend on the
-//! old claim:
-//!
-//! - a raw upstream 400 is not an actionable message — resolving first lets us
-//! name the model, the capability, and the remedy;
-//! - it lets the caller fail *before* spending a model load or a pull;
-//! - older Ollama builds, and other OpenAI-compatible local servers reached
-//! through the same code path, make no such guarantee.
-//!
-//! Keep this note accurate: a future reader deciding whether the registry can
-//! be deleted must not rely on a silent-discard premise that no current Ollama
-//! exhibits.
-//!
-//! The families below were verified against the live Ollama library registry
-//! (`GET https://registry.ollama.ai/v2/library/<name>/manifests/<tag>` plus the
-//! published capability badges on `ollama.com/library/<name>`).
-
-/// Model families where every published tag accepts image input.
-///
-/// Kept as whole-family entries (the segment before `:`) rather than loose
-/// substrings so a near-miss like `gemma3n` can never match a `gemma3` rule.
-const VISION_CAPABLE_FAMILIES: &[&str] = &[
- "moondream",
- "llava",
- "llava-llama3",
- "llava-phi3",
- "bakllava",
- "llama3.2-vision",
- "llama4",
- "minicpm-v",
- "granite3.2-vision",
- "qwen2-vl",
- "qwen2.5vl",
- "mistral-small3.1",
- "mistral-small3.2",
- // Gemma 4 is multimodal at every published size, including the `e2b` /
- // `e4b` edge builds. Contrast `gemma3n` below.
- "gemma4",
-];
-
-/// Families that look vision-capable by name but are text-only.
-///
-/// `gemma3n` is the load-bearing entry: it is a *separate* model from
-/// `gemma3`, shares its prefix, and ships **text input only** on Ollama. It
-/// was the 16 GB+ preset's vision model before #5146.
-const TEXT_ONLY_FAMILIES: &[&str] = &["gemma3n"];
-
-/// Substrings that identify a repackaged upstream vision model, e.g.
-/// `hf.co/user/llava-v1.6-mistral-7b` or a locally re-tagged `my-moondream`.
-/// Only consulted after the exact-family rules above.
-const VISION_MARKERS: &[&str] = &["llava", "moondream", "bakllava", "vision"];
-
-/// Vision models suggested to the user when none is configured. Every entry is
-/// pullable from the Ollama library with no extra setup.
-pub(crate) const VISION_MODEL_SUGGESTIONS: &[&str] =
- &["moondream:1.8b-v2-q4_K_S", "llava:7b", "gemma3:4b-it-qat"];
-
-/// Gemma 3 is split by size: `270m` and `1b` are text-only, while `4b`, `12b`
-/// and `27b` are multimodal. `gemma3:latest` resolves to the 4B build.
-fn gemma3_tag_is_multimodal(tag: &str) -> bool {
- if tag.is_empty() || tag == "latest" {
- return true;
- }
- !(tag.starts_with("270m") || tag.starts_with("1b"))
-}
-
-/// Returns `true` when `model_id` names a model that can accept image input.
-///
-/// Errs toward `false`: an unknown id is treated as chat-only so the caller
-/// reports "no vision model available" instead of shipping images to a model
-/// that will quietly ignore them.
-pub(crate) fn is_vision_capable(model_id: &str) -> bool {
- let normalized = model_id.trim().to_ascii_lowercase();
- if normalized.is_empty() {
- return false;
- }
-
- let (family, tag) = match normalized.split_once(':') {
- Some((family, tag)) => (family, tag),
- None => (normalized.as_str(), ""),
- };
-
- if TEXT_ONLY_FAMILIES.contains(&family) {
- return false;
- }
- if family == "gemma3" {
- return gemma3_tag_is_multimodal(tag);
- }
- if VISION_CAPABLE_FAMILIES.contains(&family) {
- return true;
- }
-
- VISION_MARKERS
- .iter()
- .any(|marker| normalized.contains(marker))
-}
-
-#[cfg(test)]
-#[path = "vision_models_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/inference/vision_models_tests.rs b/crates/openhuman-core/src/inference/vision_models_tests.rs
deleted file mode 100644
index c2709b7b97..0000000000
--- a/crates/openhuman-core/src/inference/vision_models_tests.rs
+++ /dev/null
@@ -1,96 +0,0 @@
-use super::*;
-
-#[test]
-fn dedicated_vision_families_are_capable() {
- assert!(is_vision_capable("moondream:1.8b-v2-q4_K_S"));
- assert!(is_vision_capable("moondream"));
- assert!(is_vision_capable("llava:7b"));
- assert!(is_vision_capable("llava:13b"));
- assert!(is_vision_capable("bakllava:latest"));
- assert!(is_vision_capable("llama3.2-vision:11b"));
- assert!(is_vision_capable("minicpm-v:8b"));
- assert!(is_vision_capable("qwen2.5vl:7b"));
-}
-
-#[test]
-fn gemma3_is_multimodal_only_at_4b_and_above() {
- // 270m / 1b ship without a vision encoder.
- assert!(!is_vision_capable("gemma3:270m-it-qat"));
- assert!(!is_vision_capable("gemma3:1b-it-qat"));
- assert!(!is_vision_capable("gemma3:1b"));
-
- assert!(is_vision_capable("gemma3:4b-it-qat"));
- assert!(is_vision_capable("gemma3:12b-it-qat"));
- assert!(is_vision_capable("gemma3:27b"));
- // `latest` is the 4B multimodal build.
- assert!(is_vision_capable("gemma3:latest"));
- assert!(is_vision_capable("gemma3"));
-}
-
-#[test]
-fn gemma3n_is_never_treated_as_vision_capable() {
- // Regression guard for #5146: `gemma3n` shares a prefix with `gemma3`
- // but is text-only, and it was previously wired in as the 16 GB+
- // tier's vision model.
- assert!(!is_vision_capable("gemma3n:e4b-it-q8_0"));
- assert!(!is_vision_capable("gemma3n:e2b"));
- assert!(!is_vision_capable("gemma3n"));
- assert!(!is_vision_capable("GEMMA3N:E4B-IT-Q8_0"));
-}
-
-#[test]
-fn gemma4_is_multimodal_at_every_size() {
- assert!(is_vision_capable("gemma4:e4b-it-q8_0"));
- assert!(is_vision_capable("gemma4:e2b-it-qat"));
- assert!(is_vision_capable("gemma4:12b"));
- assert!(is_vision_capable("gemma4"));
-}
-
-#[test]
-fn chat_only_models_are_rejected() {
- assert!(!is_vision_capable("llama3.1:8b"));
- assert!(!is_vision_capable("qwen2.5:14b"));
- assert!(!is_vision_capable("deepseek-r1:7b"));
- assert!(!is_vision_capable("phi4:latest"));
-}
-
-#[test]
-fn embedding_models_are_rejected() {
- assert!(!is_vision_capable("bge-m3"));
- assert!(!is_vision_capable("all-minilm:latest"));
- assert!(!is_vision_capable("nomic-embed-text:latest"));
-}
-
-#[test]
-fn empty_and_whitespace_are_rejected() {
- assert!(!is_vision_capable(""));
- assert!(!is_vision_capable(" "));
-}
-
-#[test]
-fn repackaged_upstream_vision_models_are_detected() {
- assert!(is_vision_capable("hf.co/user/llava-v1.6-mistral-7b"));
- assert!(is_vision_capable("my-moondream:custom"));
- assert!(is_vision_capable("someone/llama3.2-vision-abliterated"));
-}
-
-#[test]
-fn detection_is_case_insensitive() {
- assert!(is_vision_capable("LLaVA:7B"));
- assert!(is_vision_capable("MoonDream"));
- assert!(!is_vision_capable("Gemma3:1B-IT-QAT"));
-}
-
-#[test]
-fn every_suggested_vision_model_is_vision_capable() {
- // The suggestions are quoted verbatim in the user-facing errors from
- // `model_ids::resolve_vision_model_id` — both the "nothing configured"
- // and the "not vision-capable" arms. A chat-only entry here would send
- // a user straight back into the error they are trying to escape.
- for suggestion in VISION_MODEL_SUGGESTIONS {
- assert!(
- is_vision_capable(suggestion),
- "suggested vision model `{suggestion}` is not vision-capable"
- );
- }
-}
diff --git a/crates/openhuman-core/src/modules/ops.rs b/crates/openhuman-core/src/modules/ops.rs
index b7ebee02bf..31a3aec663 100644
--- a/crates/openhuman-core/src/modules/ops.rs
+++ b/crates/openhuman-core/src/modules/ops.rs
@@ -509,7 +509,7 @@ fn module_config(config: &Config, id: &str) -> serde_json::Value {
"cloud_embedding_dimensions":
crate::inference::embeddings::DEFAULT_CLOUD_EMBEDDING_DIMENSIONS,
"models_supporting_dimensions":
- crate::inference::embeddings::MODELS_SUPPORTING_DIMENSIONS,
+ tinyinference::embeddings::MODELS_SUPPORTING_DIMENSIONS,
// The periodic composio and workspace-source sync loops run INSIDE the
// module now (tinymemory#100), and these three are what let them run at
// all. Without the cadence the module answers manual-only and skips
diff --git a/crates/openhuman-core/src/web_chat/web_errors/classify.rs b/crates/openhuman-core/src/web_chat/web_errors/classify.rs
index 44338a9424..a947c73550 100644
--- a/crates/openhuman-core/src/web_chat/web_errors/classify.rs
+++ b/crates/openhuman-core/src/web_chat/web_errors/classify.rs
@@ -259,7 +259,7 @@ pub(crate) fn classify_inference_error(err: &str) -> ClassifiedError {
provider: None,
fallback_available: None,
}
- } else if crate::inference::provider::is_chat_template_rejection_message(err) {
+ } else if tinyinference::providers::openai::is_chat_template_rejection_message(err) {
// #5291: a local runtime (LM Studio / llama.cpp / Ollama) rendered the
// request through the model's OWN Jinja chat template and the template
// raised — `No user query found in messages.` on Qwen 3, against the
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 44afb2e688..d5539df36d 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 44afb2e6884690a59eb43e268a09868a9852c410
+Subproject commit d5539df36d8a64b67912fe20bf7a0d9387e17251