Skip to content

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

refactor(inference): delegate neutral failure copy to TinyInference

Steven Enamakel814ab0a85488
diff --git a/crates/openhuman-core/src/inference/README.md b/crates/openhuman-core/src/inference/README.md
index 65a6d753c1..8a2f0552b9 100644
--- a/crates/openhuman-core/src/inference/README.md
+++ b/crates/openhuman-core/src/inference/README.md
@@ -156,14 +156,14 @@ A failed provider call passes through several layers, each with one job:
|
v
provider/http_error.rs api_error(): tinyinference_llm::failure::http
- | classifies; HostErrorReporter applies backend guards, demotion, Sentry
+ | classifies; HostErrorReporter applies backend guards, upstream demotion, Sentry
|
+--> http_error.rs: 401 from managed backend -> SessionExpired event
| 401/403 on a BYO key -> auth_error_registry::record
| -> ProviderApiKeyRejected (once per episode)
v
registry.rs provider-owned classification metadata
- provider/error_classify.rs rate-limit / upstream-unhealthy / retry-after
+ TinyInference failure classifier and retry-after parser
v
failure_copy/table.rs class -> error_type, source, retryable, copy
(consumed by web_chat::web_errors)
@@ -200,7 +200,7 @@ picks the provider the same way a provider string does.
| `provider/factory.rs`, [`provider/factory/`](./provider/factory/) | Provider-string grammar and model construction: `routing`, `primary_cloud`, `access_gates`, `credentials`, `managed_backend`, `local_runtime`, `cloud_slug`, `cloud_spec`, `subprocess_providers`, `discovery`, `chat_model`, `turn_model`. |
| `provider_model.rs`, `registry.rs` | Provider-neutral model hooks and caller adapters; hosted aliases, model defaults, pricing, and request metadata are registered by `openhuman-tinyhumans`. |
| `provider/openai_codex.rs` | Codex routing metadata for the `openai` slug when Codex OAuth is connected. |
-| [`provider/error_classify.rs`](./provider/error_classify.rs), `registry.rs` | Provider-neutral retry classification and registered provider ownership metadata. |
+| `registry.rs` | Registered provider ownership metadata; provider-neutral retry classification is supplied by TinyInference. |
| `provider/fallback_diagnostics.rs` | Explains background-role fallback when it hits a provider with no credentials. |
| [`provider/`](./provider/) | [`http_error.rs`](./provider/http_error.rs) (host reporter over `tinyinference_llm::failure::http`, `api_error`), `models/` (model catalog listing, local-runtime and OpenRouter entries), `factory/` (chat-model construction and cloud provider resolution). |
| [`provider/types.rs`](./provider/types.rs) | Host DTOs kept at product and RPC boundaries: `ChatResponse`, `ProviderDelta`, `BilledUsage`, `AGENT_TURN_MAX_OUTPUT_TOKENS`. |
diff --git a/crates/openhuman-core/src/inference/failure_copy/table.rs b/crates/openhuman-core/src/inference/failure_copy/table.rs
index 03c6a61036..034e3c773c 100644
--- a/crates/openhuman-core/src/inference/failure_copy/table.rs
+++ b/crates/openhuman-core/src/inference/failure_copy/table.rs
@@ -1,36 +1,12 @@
-//! The one table mapping a chat-failure class to the `error_type` wire token,
-//! the `source` tag, the retry verdict and the user-facing copy.
+//! Product-specific overrides for TinyInference's provider-neutral failure copy.
//!
-//! Matching a raw error string to a class is the ladder in
-//! `web_chat::web_errors::classify`; the strings and wire values live only
-//! here. A literal fixture (`web_chat/web_tests_error_copy_fixture_tests.rs`)
-//! pins every row.
+//! OpenHuman owns its wire keys and branded messages. All neutral classes use
+//! TinyInference's defaults through `FailureCopyProvider`.
use tinyinference_llm::failure::copy::{
FailureCopy, FailureCopyClass, FailureCopyProvider, failure_copy_with,
};
-struct OpenHumanFailureCopy;
-
-impl FailureCopyProvider for OpenHumanFailureCopy {
- fn copy(&self, class: FailureCopyClass) -> Option<FailureCopy> {
- use FailureCopyClass::*;
- let copy = match class {
- ChatTemplateRejected => Some("This model's chat template rejected the request — it isn't the model, the temperature, or your API key. Local models without native tool calling are driven through their own chat template, and some templates refuse the message shape of a tool step. Start a new chat to reset the history, or pick a model with native tool support in Connections → API keys → LLM."),
- RateLimitedBilling => Some("Your AI provider is rejecting requests for billing or plan reasons (out of credits, plan limit, or unavailable model). Retrying won't help — open Settings to top up, upgrade your plan, or pick a different model."),
- Authentication => Some("There's an authentication issue with the AI provider. Please check your API key in settings."),
- EmptyResponse => Some("The model returned an empty response. Please retry. If it keeps happening, try a different model or check its setup in Connections → API keys → LLM."),
- ModelConfigRejected => Some("Your AI provider rejected the request's model or temperature setting. Check your model and routing in Settings → LLM."),
- CapabilityUnsupported => Some("This model can't process images. Remove the attachment or switch to a vision-capable model in Connections → API keys → LLM."),
- RequestRejected => Some("The AI provider rejected the request — this is usually a model or parameter incompatibility. Try a different model in Connections → API keys → LLM."),
- _ => None,
- }?;
- let mut row = tinyinference_llm::failure::copy::default_failure_copy(class)?;
- row.copy = copy;
- Some(row)
- }
-}
-
/// A failure class the chat surface renders copy for. Several classifier arms
/// share a class (the "temporarily unavailable" copy is reached from four).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -66,10 +42,33 @@ pub(crate) enum FailureClass {
ManagedInternal,
}
-/// The row for `class`.
+struct OpenHumanFailureCopy;
+
+impl FailureCopyProvider for OpenHumanFailureCopy {
+ fn copy(&self, class: FailureCopyClass) -> Option<FailureCopy> {
+ use FailureCopyClass::*;
+ let copy = match class {
+ ChatTemplateRejected => Some("This model's chat template rejected the request — it isn't the model, the temperature, or your API key. Local models without native tool calling are driven through their own chat template, and some templates refuse the message shape of a tool step. Start a new chat to reset the history, or pick a model with native tool support in Connections → API keys → LLM."),
+ RateLimited => Some("Your AI provider is rate-limiting requests. This is a transient upstream limit, not a thread-level block — you can retry in this thread."),
+ RateLimitedBilling => Some("Your AI provider is rejecting requests for billing or plan reasons (out of credits, plan limit, or unavailable model). Retrying won't help — open Settings to top up, upgrade your plan, or pick a different model."),
+ Authentication => Some("There's an authentication issue with the AI provider. Please check your API key in settings."),
+ EmptyResponse => Some("The model returned an empty response. Please retry. If it keeps happening, try a different model or check its setup in Connections → API keys → LLM."),
+ ModelConfigRejected => Some("Your AI provider rejected the request's model or temperature setting. Check your model and routing in Settings → LLM."),
+ CapabilityUnsupported => Some("This model can't process images. Remove the attachment or switch to a vision-capable model in Connections → API keys → LLM."),
+ RequestRejected => Some("The AI provider rejected the request — this is usually a model or parameter incompatibility. Try a different model in Connections → API keys → LLM."),
+ _ => None,
+ }?;
+ let mut row = tinyinference_llm::failure::copy::default_failure_copy(class)?;
+ row.copy = copy;
+ Some(row)
+ }
+}
+
+/// Looks up OpenHuman's branded row or falls back to TinyInference's neutral
+/// default for provider-owned failure classes.
pub(crate) fn failure_copy(class: FailureClass) -> FailureCopy {
use FailureClass::*;
- let upstream = match class {
+ let owner_class = match class {
ChatTemplateRejected => Some(FailureCopyClass::ChatTemplateRejected),
EmptyResponse => Some(FailureCopyClass::EmptyResponse),
RateLimited => Some(FailureCopyClass::RateLimited),
@@ -87,266 +86,38 @@ pub(crate) fn failure_copy(class: FailureClass) -> FailureCopy {
Inference => Some(FailureCopyClass::Inference),
_ => None,
};
- if let Some(class) = upstream {
- return failure_copy_with(&OpenHumanFailureCopy, class).expect("known failure copy");
+ if let Some(owner_class) = owner_class {
+ return failure_copy_with(&OpenHumanFailureCopy, owner_class)
+ .expect("known TinyInference failure copy class");
}
+
macro_rules! row {
- ($key:expr, $ty:expr, $src:expr, $retry:expr, $copy:expr) => {{
+ ($key:literal, $error_type:literal, $source:literal, $retryable:literal, $copy:literal) => {
FailureCopy {
key: $key,
- error_type: $ty,
- source: $src,
- retryable: $retry,
+ error_type: $error_type,
+ source: $source,
+ retryable: $retryable,
copy: $copy,
}
- }};
+ };
}
+
match class {
- CodexSessionExpired => row!(
- "chat_error.codex_session_expired",
- "provider_error",
- "auth",
- false,
- "Your Codex session has expired. Please reconnect it in \
- Settings → Integrations."
- ),
- SessionExpired => row!(
- "chat_error.session_expired",
- "session_expired",
- "auth",
- false,
- "Your OpenHuman session has expired. \
- Please sign in again to continue."
- ),
- // The offline local profile is a working sign-in with no TinyHumans
- // account behind it, so the managed model cannot run for it — but
- // nothing about it has expired (#6932). `auth_error`/`config` because
- // the fix is a setting the user owns; emphatically NOT
- // `session_expired`, whose wire token signs the user out.
- LocalSessionManagedUnavailable => row!(
- "chat_error.local_session_managed_unavailable",
- "auth_error",
- "config",
- false,
- "You're on the local offline profile, which has no OpenHuman account behind \
- it, so the managed (cloud) model can't run. Sign in to use managed models, \
- or switch routing to \"Use Your Own Models\" in Connections → API keys → LLM \
- and add your own provider."
- ),
- ActionBudget => row!(
- "chat_error.action_budget",
- "action_budget_exceeded",
- "openhuman_budget",
- true,
- "You've hit OpenHuman's per-hour action budget — this is a local safety cap, \
- not your AI provider. The window decays gradually; you can keep chatting in \
- this thread and tool-heavy steps will resume as the budget refills."
- ),
- MaxIterations => row!(
- "chat_error.max_iterations",
- "max_iterations",
- "agent_loop",
- true,
- "The agent ran the maximum number of tool steps for one turn without \
- finishing. This usually means a tool kept failing (often a rate limit on a \
- web fetch). You can retry the same question in this thread once the \
- underlying limit clears."
- ),
- TurnTimeout => row!(
- "chat_error.turn_timeout",
- "turn_timeout",
- "agent_loop",
- true,
- "This turn ran past its time budget without finishing and was \
- stopped so it wouldn't hang. This usually means a tool call or a \
- delegated sub-agent stalled. You can retry your question in this thread."
- ),
- EmptyResponse => row!(
- "chat_error.empty_response",
- "empty_response",
- "agent_loop",
- true,
- "The model returned an empty response. Please retry. If it keeps happening, \
- try a different model or check its setup in Connections → API keys → LLM."
- ),
- ChatTemplateRejected => row!(
- "chat_error.chat_template_rejected",
- "chat_template_rejected",
- "provider",
- true,
- "This model's chat template rejected the request — it isn't the model, the \
- temperature, or your API key. Local models without native tool calling are \
- driven through their own chat template, and some templates refuse the \
- message shape of a tool step. Start a new chat to reset the history, or \
- pick a model with native tool support in Connections → API keys → LLM."
- ),
- RateLimited => row!(
- "chat_error.rate_limited",
- "rate_limited",
- "provider",
- true,
- "Your AI provider is rate-limiting requests. This is a transient upstream \
- limit, not a thread-level block — you can retry in this thread."
- ),
- RateLimitedBilling => row!(
- "chat_error.rate_limited_billing",
- "rate_limited",
- "provider",
- false,
- "Your AI provider is rejecting requests for billing or plan reasons \
- (out of credits, plan limit, or unavailable model). Retrying won't \
- help — open Settings to top up, upgrade your plan, or pick a \
- different model."
- ),
- ManagedRateLimited => row!(
- "chat_error.managed_rate_limited",
- "rate_limited",
- "provider",
- true,
- "Your AI provider is rate-limiting requests. You can retry in this thread."
- ),
- Timeout => row!(
- "chat_error.timeout",
- "timeout",
- "transport",
- true,
- "The request timed out. Please check your connection and try again."
- ),
- AuthError => row!(
- "chat_error.auth_error",
- "auth_error",
- "config",
- false,
- "There's an authentication issue with the AI provider. Please check your API key in settings."
- ),
- // Source is `provider` instead when the 402 carries a non-OpenHuman
- // provider envelope; the classifier applies that override.
- BudgetExhausted => row!(
- "chat_error.budget_exhausted",
- "budget_exhausted",
- "openhuman_billing",
- false,
- "You're out of credits, so I can't run the managed (cloud) model right now. \
- You can top up your credits or pick a plan to continue — or, if you've enabled a \
- local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM."
- ),
- ManagedBudgetExhausted => row!(
- "chat_error.managed_budget_exhausted",
- "budget_exhausted",
- "openhuman_billing",
- false,
- "You're out of credits. Top up, or switch to 'Use Your Own Models' \
- in Settings."
- ),
- ProviderUnavailable => row!(
- "chat_error.provider_unavailable",
- "provider_error",
- "provider",
- true,
- "The AI provider is temporarily unavailable. Please try again later."
- ),
- ManagedUnavailable => row!(
- "chat_error.managed_unavailable",
- "provider_error",
- "provider",
- true,
- "The AI service is temporarily unavailable — we've been notified. \
- Please try again shortly."
- ),
- PayloadTooLarge => row!(
- "chat_error.payload_too_large",
- "payload_too_large",
- "config",
- false,
- "Your message or attachment is too large for this model. Shorten it \
- or remove the attachment — or start a new thread."
- ),
- ContextOverflow => row!(
- "chat_error.context_overflow",
- "context_overflow",
- "config",
- false,
- "The conversation is too long. Please start a new chat."
- ),
- ModelConfigRejected => row!(
- "chat_error.model_config_rejected",
- "model_unavailable",
- "config",
- false,
- "Your AI provider rejected the request's model or temperature setting. \
- Check your model and routing in Settings → LLM."
- ),
- ModelUnavailable => row!(
- "chat_error.model_unavailable",
- "model_unavailable",
- "config",
- false,
- "The selected model isn't available on your provider. Check your model settings."
- ),
- CapabilityUnsupported => row!(
- "chat_error.capability_unsupported",
- "capability_unsupported",
- "config",
- false,
- "This model can't process images. Remove the attachment or switch to a \
- vision-capable model in Connections → API keys → LLM."
- ),
- // The de-poison guard (`run_task.rs`) has already evicted the
- // offending warm session by the time this is shown, so "send it
- // again" is literally true.
- MalformedHistory => row!(
- "chat_error.malformed_history",
- "provider_request_rejected",
- "provider",
- true,
- "We hit a temporary glitch in this conversation — we've cleared it. \
- Please send your message again."
- ),
- RequestRejected => row!(
- "chat_error.request_rejected",
- "provider_request_rejected",
- "provider",
- false,
- "The AI provider rejected the request — this is usually a model or \
- parameter incompatibility. Try a different model in Connections → API keys → LLM."
- ),
- ManagedRequestRejected => row!(
- "chat_error.managed_request_rejected",
- "provider_request_rejected",
- "provider",
- false,
- "The request was rejected — usually a model or parameter \
- mismatch. Try a different model in Connections → API keys → LLM."
- ),
- ManagedMalformedRequest => row!(
- "chat_error.managed_malformed_request",
- "provider_request_rejected",
- "provider",
- false,
- "Something went wrong with this message. Try rephrasing it — \
- or start a new thread if it keeps happening."
- ),
- Network => row!(
- "chat_error.network",
- "network",
- "transport",
- true,
- "The connection to the AI service dropped mid-response — usually a \
- sleep/wake or network change. Please try again."
- ),
- Inference => row!(
- "chat_error.inference",
- "inference",
- "provider",
- true,
- "Something went wrong. Please try again."
- ),
- ManagedInternal => row!(
- "chat_error.managed_internal",
- "inference",
- "provider",
- true,
- "Something went wrong — we've been notified. Please try again."
- ),
+ CodexSessionExpired => row!("chat_error.codex_session_expired", "provider_error", "auth", false, "Your Codex session has expired. Please reconnect it in Settings → Integrations."),
+ SessionExpired => row!("chat_error.session_expired", "session_expired", "auth", false, "Your OpenHuman session has expired. Please sign in again to continue."),
+ LocalSessionManagedUnavailable => row!("chat_error.local_session_managed_unavailable", "auth_error", "config", false, "You're on the local offline profile, which has no OpenHuman account behind it, so the managed (cloud) model can't run. Sign in to use managed models, or switch routing to \"Use Your Own Models\" in Connections → API keys → LLM and add your own provider."),
+ ActionBudget => row!("chat_error.action_budget", "action_budget_exceeded", "openhuman_budget", true, "You've hit OpenHuman's per-hour action budget — this is a local safety cap, not your AI provider. The window decays gradually; you can keep chatting in this thread and tool-heavy steps will resume as the budget refills."),
+ MaxIterations => row!("chat_error.max_iterations", "max_iterations", "agent_loop", true, "The agent ran the maximum number of tool steps for one turn without finishing. This usually means a tool kept failing (often a rate limit on a web fetch). You can retry the same question in this thread once the underlying limit clears."),
+ TurnTimeout => row!("chat_error.turn_timeout", "turn_timeout", "agent_loop", true, "This turn ran past its time budget without finishing and was stopped so it wouldn't hang. This usually means a tool call or a delegated sub-agent stalled. You can retry your question in this thread."),
+ ManagedRateLimited => row!("chat_error.managed_rate_limited", "rate_limited", "provider", true, "Your AI provider is rate-limiting requests. You can retry in this thread."),
+ BudgetExhausted => row!("chat_error.budget_exhausted", "budget_exhausted", "openhuman_billing", false, "You're out of credits, so I can't run the managed (cloud) model right now. You can top up your credits or pick a plan to continue — or, if you've enabled a local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM."),
+ ManagedBudgetExhausted => row!("chat_error.managed_budget_exhausted", "budget_exhausted", "openhuman_billing", false, "You're out of credits. Top up, or switch to 'Use Your Own Models' in Settings."),
+ ManagedUnavailable => row!("chat_error.managed_unavailable", "provider_error", "provider", true, "The AI service is temporarily unavailable — we've been notified. Please try again shortly."),
+ MalformedHistory => row!("chat_error.malformed_history", "provider_request_rejected", "provider", true, "We hit a temporary glitch in this conversation — we've cleared it. Please send your message again."),
+ ManagedRequestRejected => row!("chat_error.managed_request_rejected", "provider_request_rejected", "provider", false, "The request was rejected — usually a model or parameter mismatch. Try a different model in Connections → API keys → LLM."),
+ ManagedMalformedRequest => row!("chat_error.managed_malformed_request", "provider_request_rejected", "provider", false, "Something went wrong with this message. Try rephrasing it — or start a new thread if it keeps happening."),
+ ManagedInternal => row!("chat_error.managed_internal", "inference", "provider", true, "Something went wrong — we've been notified. Please try again."),
+ _ => unreachable!("neutral failure classes use TinyInference defaults"),
}
}