Skip to content

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

feat(observability): filter crash reports and list provider models

Steven Enamakel11eb64ba59ef
diff --git a/crates/openhuman-core/src/core/observability.rs b/crates/openhuman-core/src/core/observability.rs
index 1f3f87e062..2dfd9962ce 100644
--- a/crates/openhuman-core/src/core/observability.rs
+++ b/crates/openhuman-core/src/core/observability.rs
@@ -29,21 +29,6 @@ pub use availability::{
/// anything you'd want to facet on (`error_kind`, `tool_name`, `method`).
pub type Tag<'a> = (&'a str, &'a str);
-/// HTTP status codes that the reliable-provider layer already handles via
-/// retry + fallback, so per-attempt Sentry reports add noise without signal:
-///
-/// - **408** Request Timeout
-/// - **429** Too Many Requests
-/// - **502** Bad Gateway
-/// - **503** Service Unavailable
-/// - **504** Gateway Timeout
-///
-/// Single source of truth for both the call-site classifier
-/// (`crate::inference::provider::ops::should_report_provider_http_failure`) and the
-/// `before_send` filter (`is_transient_provider_http_failure`). Update here
-/// and both sites pick it up — keeps the two layers from drifting.
-pub const TRANSIENT_PROVIDER_HTTP_STATUSES: &[u16] = &[408, 429, 502, 503, 504, 520];
-
/// HTTP status codes that represent transient backend / integration transport
/// failures rather than application bugs. Keep this as strings because Sentry
/// tags are strings, and the before_send classifiers match tag values exactly.
@@ -541,7 +526,7 @@ pub fn expected_error_kind(message: &str) -> Option<ExpectedErrorKind> {
// reliable-provider layer retries + falls back over, with no client lever.
// Delegates to the single-source provider matcher so the phrasing can't
// drift. Distinct anchor from the matchers above, so it shadows nothing.
- if crate::inference::provider::is_ollama_cloud_internal_500_message(message) {
+ if tinyinference_llm::failure::is_ollama_cloud_internal_500_message(message) {
return Some(ExpectedErrorKind::TransientUpstreamHttp);
}
if is_backend_user_error_message(&lower) {
@@ -1416,7 +1401,7 @@ fn is_channel_supervisor_restart_message(lower: &str) -> bool {
/// status integer alone could collide with unrelated log lines containing
/// `"HTTP error: 5023"` (port number, runbook ID).
fn is_transient_upstream_http_message(lower: &str) -> bool {
- TRANSIENT_PROVIDER_HTTP_STATUSES.iter().any(|code| {
+ tinyinference_llm::failure::TRANSIENT_PROVIDER_HTTP_STATUSES.iter().any(|code| {
lower.contains(&format!("api error ({code}"))
|| lower.contains(&format!("api error {code} "))
|| lower.contains(&format!("http error: {code} "))
@@ -2571,7 +2556,7 @@ pub fn is_transient_provider_http_failure(event: &sentry::protocol::Event<'_>) -
let Some(status_u16) = tags.get("status").and_then(|s| s.parse::<u16>().ok()) else {
return false;
};
- TRANSIENT_PROVIDER_HTTP_STATUSES.contains(&status_u16)
+ tinyinference_llm::failure::TRANSIENT_PROVIDER_HTTP_STATUSES.contains(&status_u16)
}
/// Defense-in-depth `before_send` filter for managed-backend `errorCode`
@@ -3148,7 +3133,7 @@ pub fn is_quota_exhausted_event(event: &sentry::protocol::Event<'_>) -> bool {
/// generic 500 from another provider, or a local Ollama daemon crash (which
/// carries no `ref:` UUID), still reaches Sentry.
pub fn is_ollama_cloud_internal_500_message_any(text: &str) -> bool {
- if crate::inference::provider::is_ollama_cloud_internal_500_message(text) {
+ if tinyinference_llm::failure::is_ollama_cloud_internal_500_message(text) {
return true;
}
let lower = text.to_ascii_lowercase();
diff --git a/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rs b/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rs
index 0d5f5cbe6f..113b708ecd 100644
--- a/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rs
+++ b/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rs
@@ -629,7 +629,7 @@ fn ollama_cloud_internal_500_reraise_routes_through_expected_path() {
// demote to `TransientUpstreamHttp` when re-reported at the agent / RPC
// boundary (`provider_chat` → `report_error_or_expected`), so the
// `domain=agent` half of the flood is suppressed too.
- let reraise = crate::inference::provider::ollama_cloud_internal_500_user_message(
+ let reraise = tinyinference_llm::failure::ollama_cloud_internal_500_user_message(
Some("minimax-m3:cloud"),
reqwest::StatusCode::INTERNAL_SERVER_ERROR,
);
@@ -651,7 +651,7 @@ fn ollama_cloud_internal_500_before_send_matches_raw_and_reraised_shapes() {
&event_with_exception_value(raw)
));
- let reraise = crate::inference::provider::ollama_cloud_internal_500_user_message(
+ let reraise = tinyinference_llm::failure::ollama_cloud_internal_500_user_message(
None,
reqwest::StatusCode::INTERNAL_SERVER_ERROR,
);
diff --git a/crates/openhuman-core/src/inference/provider/factory/discovery.rs b/crates/openhuman-core/src/inference/provider/factory/discovery.rs
index 567fe6bbc5..7025113cad 100644
--- a/crates/openhuman-core/src/inference/provider/factory/discovery.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/discovery.rs
@@ -101,7 +101,7 @@ fn managed_limits_request(model: &str, config: &Config) -> Option<DiscoveryReque
let inference_base = crate::backend::inference_base_url(&config.api_url).ok()?;
let endpoint = format!("{}/openai/v1", inference_base.trim_end_matches('/'));
let api_base = crate::backend::base_url(&config.api_url).ok()?;
- let listing_url = crate::inference::provider::append_query_param(
+ let listing_url = tinyinference_llm::catalog::append_query_param(
&crate::util::url::join_url(&api_base, "/openai/v1/models"),
"catalog",
"openrouter",
diff --git a/crates/openhuman-core/src/inference/provider/ops/mod.rs b/crates/openhuman-core/src/inference/provider/ops/mod.rs
index 1e793209b1..e06f81081a 100644
--- a/crates/openhuman-core/src/inference/provider/ops/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/ops/mod.rs
@@ -13,25 +13,13 @@ mod provider_factory;
// ── public surface (preserves the original `pub use ops::*` contract) ──
pub use http_error::{
- api_error, is_backend_auth_failure, is_backend_error_code_owned, is_budget_exhausted_http_400,
- is_byo_provider_auth_failure_http, is_custom_openai_upstream_bad_request_http_400,
- is_local_provider_no_model_loaded, is_ollama_cloud_internal_500,
- is_ollama_cloud_internal_500_message, is_openai_oauth_session_expired_http,
- is_provider_access_policy_denied_http_403, is_provider_config_rejection_http,
- is_provider_insufficient_credits_402, is_provider_moderation_rejection_http_400,
- local_provider_no_model_loaded_user_message, log_backend_error_code_owned,
- log_budget_exhausted_http_400, log_byo_provider_auth_failure, log_context_window_exceeded,
- log_custom_openai_upstream_bad_request_http_400, log_local_provider_no_model_loaded,
- log_ollama_cloud_internal_500, log_openai_oauth_session_expired,
- log_provider_access_policy_denied_http_403, log_provider_config_rejection,
- log_provider_insufficient_credits_402, log_provider_moderation_rejection,
- log_provider_quota_exhausted, ollama_cloud_internal_500_user_message,
- publish_backend_session_expired, should_report_provider_http_failure,
+ api_error, is_backend_auth_failure, is_backend_error_code_owned,
+ log_byo_provider_auth_failure, publish_backend_session_expired,
+ should_report_provider_http_failure,
};
pub use models::{
- append_query_param, is_openrouter_provider, list_configured_models,
- list_configured_models_from_config, synthesize_local_runtime_entry,
+ list_configured_models, list_configured_models_from_config, synthesize_local_runtime_entry,
};
pub use provider_factory::{
diff --git a/crates/openhuman-core/src/inference/provider/ops/models.rs b/crates/openhuman-core/src/inference/provider/ops/models.rs
index cb62c3f0b7..baeeb2b554 100644
--- a/crates/openhuman-core/src/inference/provider/ops/models.rs
+++ b/crates/openhuman-core/src/inference/provider/ops/models.rs
@@ -25,17 +25,15 @@ mod local_runtime;
mod managed_provider;
mod openrouter;
use tinyinference_llm::catalog::{
+ append_query_param, endpoint_hosts_models_listing, is_openrouter_provider,
merge_openai_codex_model_hints, parse_models_response, ModelInfo,
};
#[cfg(test)]
use catalog_listing::resolve_local_runtime_key;
-pub use catalog_listing::{
- append_query_param, list_configured_models, list_configured_models_from_config,
-};
+pub use catalog_listing::{list_configured_models, list_configured_models_from_config};
pub use local_runtime::synthesize_local_runtime_entry;
-pub use openrouter::is_openrouter_provider;
// Cross-submodule wiring: each submodule reaches these through `use super::*;`
// (mirrors the pre-split `include!`-shared scope).
diff --git a/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs b/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs
index 042e07af49..2d154b97d3 100644
--- a/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs
+++ b/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs
@@ -33,33 +33,6 @@ pub(super) fn resolve_local_runtime_key(
looked_up
}
-/// Whether a provider entry can be probed at `{endpoint}/models`.
-///
-/// Claude Code is a local CLI provider, and a `cli://…` endpoint is a
-/// placeholder rather than an API base. Any other scheme (`ftp://…`) is a
-/// misconfiguration and is left to the request path to surface as an error.
-/// An endpoint that does not parse as `scheme://host` at all is left to the
-/// request path so a genuine misconfiguration still surfaces as an error.
-fn endpoint_hosts_models_listing(slug: &str, endpoint: &str) -> bool {
- if slug == "claude-code" {
- return false;
- }
- match reqwest::Url::parse(endpoint.trim()) {
- Ok(url) if url.has_host() => url.scheme() != "cli",
- _ => true,
- }
-}
-
-pub fn append_query_param(url: &str, key: &str, value: &str) -> String {
- if let Ok(mut parsed) = reqwest::Url::parse(url) {
- parsed.query_pairs_mut().append_pair(key, value);
- return parsed.to_string();
- }
-
- let separator = if url.contains('?') { '&' } else { '?' };
- format!("{url}{separator}{key}={value}")
-}
-
pub async fn list_configured_models(
provider_id: &str,
) -> Result<crate::core::Outcome<serde_json::Value>, String> {
@@ -245,7 +218,7 @@ pub async fn list_configured_models_from_config(
);
}
- if is_openrouter_provider(&entry) {
+ if is_openrouter_provider(&entry.slug, &entry.endpoint) {
validate_openrouter_api_key(&client, &routing.endpoint, &api_key).await?;
}
diff --git a/crates/openhuman-core/src/inference/provider/ops/models/openrouter.rs b/crates/openhuman-core/src/inference/provider/ops/models/openrouter.rs
index 669464436e..437fe26ace 100644
--- a/crates/openhuman-core/src/inference/provider/ops/models/openrouter.rs
+++ b/crates/openhuman-core/src/inference/provider/ops/models/openrouter.rs
@@ -2,19 +2,6 @@
use super::*;
-pub fn is_openrouter_provider(
- entry: &crate::config::schema::cloud_providers::CloudProviderCreds,
-) -> bool {
- if entry.slug.eq_ignore_ascii_case("openrouter") {
- return true;
- }
-
- reqwest::Url::parse(&entry.endpoint)
- .ok()
- .and_then(|url| url.host_str().map(|host| host.to_ascii_lowercase()))
- .is_some_and(|host| host == "openrouter.ai" || host.ends_with(".openrouter.ai"))
-}
-
pub(super) async fn validate_openrouter_api_key(
client: &reqwest::Client,
base: &str,